mirror of
https://github.com/avem-labs/Avem.git
synced 2023-09-01 15:18:49 +08:00
[MOD]: More Readable
This commit is contained in:
parent
8aad5cb8d4
commit
9949fab058
@ -8,7 +8,7 @@ void delay_us(volatile unsigned int nus) {
|
||||
}
|
||||
|
||||
void IIC_init() {
|
||||
RCC->APB2ENR |= RCC_APB2RSTR_IOPBRST; //GPIOB enable
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; //GPIOB enable
|
||||
GPIOB->CRH &= 0x0F0FFFFF; //reset B13 & B15
|
||||
GPIOB->CRH |= 0x70700000; //Set B13 & B15 b0111
|
||||
GPIOB->ODR |= 5<<5;
|
||||
@ -18,7 +18,7 @@ void IIC_init() {
|
||||
//最终就会进入输入寄存器,导致在输出状态下,输入功能保持正常。
|
||||
//如果用推挽输出的话,IIC通讯时每次读取SDA之前都要配置SDA为输入,才能读取IDR
|
||||
|
||||
RCC->APB2ENR |= 1<<4; //GPIOC enable
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; //GPIOC enable
|
||||
GPIOC->CRL &= 0xF0FFFFFF;
|
||||
GPIOC->CRL |= 0x03000000; //推挽输出, AD0 ----> PC6
|
||||
AD0 = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "key.h"
|
||||
#include "stm32f10x.h"
|
||||
void Key_init() {
|
||||
RCC->APB2ENR |= 1<<4; //GPIOC
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; //GPIOC
|
||||
GPIOC->CRH &= 0xFF0FFFFF; //Clean Pin 13
|
||||
GPIOC->CRH |= 0x00800000; //上拉输入
|
||||
GPIOC->ODR |= 1<<13;
|
||||
|
@ -3,8 +3,11 @@
|
||||
|
||||
//A7
|
||||
void motor_PWM_Init(unsigned short arr, unsigned short psc) {
|
||||
RCC->APB1ENR |= 1<<1; //TIM3 enable
|
||||
RCC->APB2ENR |= 1<<2; //GPIOA enable
|
||||
//RCC->APB1ENR |= 1<<1; //TIM3 enable
|
||||
//RCC->APB2ENR |= 1<<2; //GPIOA enable
|
||||
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; //TIM3 Enable
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; //IO Port A Enable
|
||||
|
||||
GPIOA->CRL &= 0x00FFFFFF; //Clean
|
||||
GPIOA->CRL |= 0xBB000000; //复用推挽输出
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
void initLED() {
|
||||
RCC->APB2ENR |= 1<<5;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPDEN;
|
||||
GPIOD->CRL &= 0xFFFFF0FF;
|
||||
GPIOD->CRL |= 0x00000300;
|
||||
|
||||
|
@ -10,14 +10,14 @@ void uart_init(unsigned int pclk2, unsigned int bound) {
|
||||
fraction = (temp - mantissa) * 16;
|
||||
mantissa <<= 4;
|
||||
mantissa += fraction;
|
||||
RCC->APB2ENR |= 1<<2; //GPIOA Enable
|
||||
RCC->APB2ENR |= 1<<14; //USART1 Enable
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; //GPIOA Enable
|
||||
RCC->APB2ENR |= RCC_APB2ENR_USART1EN; //USART1 Enable
|
||||
|
||||
GPIOA->CRH &= 0xFFFFF00F;
|
||||
GPIOA->CRH |= 0x000008B0;
|
||||
|
||||
RCC->APB2RSTR |= 1<<14;
|
||||
RCC->APB2RSTR &= ~(1<<14);
|
||||
RCC->APB2RSTR |= RCC_APB2RSTR_USART1RST;
|
||||
RCC->APB2RSTR &= ~RCC_APB2RSTR_USART1RST;
|
||||
|
||||
USART1->BRR = mantissa;
|
||||
USART1->CR1 |= 0x200C;
|
||||
|
@ -12,14 +12,14 @@ void wifi_init() {
|
||||
mantissa <<= 4;
|
||||
mantissa += fraction;
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2RSTR_IOPBRST; //GPIOB Enable
|
||||
RCC->APB1ENR |= 1<<18; //USART3 Enable
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; //GPIOB Enable
|
||||
RCC->APB1ENR |= RCC_APB1ENR_USART3EN; //USART3 Enable
|
||||
|
||||
GPIOB->CRH &= 0xFFFF00FF;
|
||||
GPIOB->CRH |= 0x00008B00;
|
||||
|
||||
RCC->APB1RSTR |= 1<<18;
|
||||
RCC->APB1RSTR &= ~(1<<18);
|
||||
RCC->APB1RSTR |= RCC_APB1RSTR_USART3RST;
|
||||
RCC->APB1RSTR &= ~RCC_APB1RSTR_USART3RST;
|
||||
|
||||
USART3->BRR = mantissa;
|
||||
USART3->CR1 |= 0x200C;
|
||||
|
Loading…
x
Reference in New Issue
Block a user