From 9949fab05801fe2e87d5bab751c98b8008a180f7 Mon Sep 17 00:00:00 2001 From: but0n Date: Fri, 23 Sep 2016 10:52:46 +0800 Subject: [PATCH] [MOD]: More Readable --- .../Libraries/STM32F10x_StdPeriph_Driver/src/i2c.c | 4 ++-- .../Libraries/STM32F10x_StdPeriph_Driver/src/key.c | 2 +- .../Libraries/STM32F10x_StdPeriph_Driver/src/motor.c | 7 +++++-- .../Libraries/STM32F10x_StdPeriph_Driver/src/mpu6050.c | 2 +- .../Libraries/STM32F10x_StdPeriph_Driver/src/uart.c | 8 ++++---- .../Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c | 8 ++++---- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/i2c.c b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/i2c.c index 69fcc03..4551db4 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/i2c.c +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/i2c.c @@ -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; diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/key.c b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/key.c index 910bce7..42f12e7 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/key.c +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/key.c @@ -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; diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/motor.c b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/motor.c index a241db6..4a8fda4 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/motor.c +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/motor.c @@ -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; //复用推挽输出 diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/mpu6050.c b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/mpu6050.c index db8cc86..2d101e3 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/mpu6050.c +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/mpu6050.c @@ -7,7 +7,7 @@ void initLED() { - RCC->APB2ENR |= 1<<5; + RCC->APB2ENR |= RCC_APB2ENR_IOPDEN; GPIOD->CRL &= 0xFFFFF0FF; GPIOD->CRL |= 0x00000300; diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/uart.c b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/uart.c index 76c7985..7d3cdf1 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/uart.c +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/uart.c @@ -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; diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c index 79fe4e8..6f58816 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c @@ -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;