From 284c6ffc98cd4cc0eea5973c81ba5df199dec9dc Mon Sep 17 00:00:00 2001 From: WuKaiLi <784609794@qq.com> Date: Sun, 5 Sep 2021 21:40:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=81=94=E7=B3=BB=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/apm32/apm32f103xe-minibroard/README.md | 2 +- .../apm32f103xe-minibroard/project.uvprojx | 2 +- bsp/apm32/libraries/Drivers/Kconfig | 0 bsp/apm32/libraries/Drivers/drv_gpio.c | 146 +++++++++--------- bsp/apm32/libraries/Drivers/drv_usart.c | 74 +++++---- 5 files changed, 116 insertions(+), 108 deletions(-) delete mode 100644 bsp/apm32/libraries/Drivers/Kconfig diff --git a/bsp/apm32/apm32f103xe-minibroard/README.md b/bsp/apm32/apm32f103xe-minibroard/README.md index b27871a2eb..abb12fec47 100644 --- a/bsp/apm32/apm32f103xe-minibroard/README.md +++ b/bsp/apm32/apm32f103xe-minibroard/README.md @@ -81,4 +81,4 @@ msh > ## 联系人信息 -- \ No newline at end of file +-[abbbcc ](https://gitee.com/abbbcc) \ No newline at end of file diff --git a/bsp/apm32/apm32f103xe-minibroard/project.uvprojx b/bsp/apm32/apm32f103xe-minibroard/project.uvprojx index 409dc1824a..c10a97669c 100644 --- a/bsp/apm32/apm32f103xe-minibroard/project.uvprojx +++ b/bsp/apm32/apm32f103xe-minibroard/project.uvprojx @@ -10,7 +10,7 @@ rt-thread 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 diff --git a/bsp/apm32/libraries/Drivers/Kconfig b/bsp/apm32/libraries/Drivers/Kconfig deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bsp/apm32/libraries/Drivers/drv_gpio.c b/bsp/apm32/libraries/Drivers/drv_gpio.c index dffcb3f839..7f8413d7fb 100644 --- a/bsp/apm32/libraries/Drivers/drv_gpio.c +++ b/bsp/apm32/libraries/Drivers/drv_gpio.c @@ -17,40 +17,40 @@ #define PIN_PORT(pin) ((uint8_t)(((pin) >> 4) & 0xFu)) #define PIN_NO(pin) ((uint8_t)((pin) & 0xFu)) -#define PIN_STPORT(pin) ((GPIO_T *)(GPIOA_BASE + (0x400u * PIN_PORT(pin)))) +#define PIN_APMPORT(pin) ((GPIO_T *)(GPIOA_BASE + (0x400u * PIN_PORT(pin)))) -#define PIN_STPIN(pin) ((uint16_t)(1u << PIN_NO(pin))) +#define PIN_APMPIN(pin) ((uint16_t)(1u << PIN_NO(pin))) #if defined(GPIOZ) -#define __APM32_PORT_MAX 12u + #define __APM32_PORT_MAX 12u #elif defined(GPIOK) -#define __APM32_PORT_MAX 11u + #define __APM32_PORT_MAX 11u #elif defined(GPIOJ) -#define __APM32_PORT_MAX 10u + #define __APM32_PORT_MAX 10u #elif defined(GPIOI) -#define __APM32_PORT_MAX 9u + #define __APM32_PORT_MAX 9u #elif defined(GPIOH) -#define __APM32_PORT_MAX 8u + #define __APM32_PORT_MAX 8u #elif defined(GPIOG) -#define __APM32_PORT_MAX 7u + #define __APM32_PORT_MAX 7u #elif defined(GPIOF) -#define __APM32_PORT_MAX 6u + #define __APM32_PORT_MAX 6u #elif defined(GPIOE) -#define __APM32_PORT_MAX 5u + #define __APM32_PORT_MAX 5u #elif defined(GPIOD) -#define __APM32_PORT_MAX 4u + #define __APM32_PORT_MAX 4u #elif defined(GPIOC) -#define __APM32_PORT_MAX 3u + #define __APM32_PORT_MAX 3u #elif defined(GPIOB) -#define __APM32_PORT_MAX 2u + #define __APM32_PORT_MAX 2u #elif defined(GPIOA) -#define __APM32_PORT_MAX 1u + #define __APM32_PORT_MAX 1u #else -#define __APM32_PORT_MAX 0u -#error Unsupported APM32 GPIO peripheral. + #define __APM32_PORT_MAX 0u + #error Unsupported APM32 GPIO peripheral. #endif -#define PIN_STPORT_MAX __APM32_PORT_MAX +#define PIN_APMPORT_MAX __APM32_PORT_MAX static const struct pin_irq_map pin_irq_map[] = { @@ -95,7 +95,7 @@ static uint32_t pin_irq_enable_mask = 0; #define ITEM_NUM(items) sizeof(items) / sizeof(items[0]) -static rt_base_t apm32_pin_get(const char *name) +static rt_base_t _pin_get(const char *name) { rt_base_t pin = 0; int hw_port_num, hw_pin_num = 0; @@ -132,47 +132,47 @@ static rt_base_t apm32_pin_get(const char *name) return pin; } -static void apm32_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value) +static void _pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value) { GPIO_T *gpio_port; uint16_t gpio_pin; - if (PIN_PORT(pin) < PIN_STPORT_MAX) + if (PIN_PORT(pin) < PIN_APMPORT_MAX) { - gpio_port = PIN_STPORT(pin); - gpio_pin = PIN_STPIN(pin); + gpio_port = PIN_APMPORT(pin); + gpio_pin = PIN_APMPIN(pin); GPIO_WriteBitValue(gpio_port, gpio_pin, (uint8_t)value); } } -static int apm32_pin_read(rt_device_t dev, rt_base_t pin) +static int _pin_read(rt_device_t dev, rt_base_t pin) { GPIO_T *gpio_port; uint16_t gpio_pin; int value = PIN_LOW; - if (PIN_PORT(pin) < PIN_STPORT_MAX) + if (PIN_PORT(pin) < PIN_APMPORT_MAX) { - gpio_port = PIN_STPORT(pin); - gpio_pin = PIN_STPIN(pin); + gpio_port = PIN_APMPORT(pin); + gpio_pin = PIN_APMPIN(pin); value = GPIO_ReadInputBit(gpio_port, gpio_pin); } return value; } -static void apm32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode) +static void _pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode) { GPIO_Config_T gpioConfig; - if (PIN_PORT(pin) >= PIN_STPORT_MAX) + if (PIN_PORT(pin) >= PIN_APMPORT_MAX) { return; } /* Configure gpioConfigure */ - gpioConfig.pin = PIN_STPIN(pin); + gpioConfig.pin = PIN_APMPIN(pin); gpioConfig.mode = GPIO_MODE_OUT_PP; gpioConfig.speed = GPIO_SPEED_50MHz; @@ -202,7 +202,7 @@ static void apm32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode) gpioConfig.mode = GPIO_MODE_OUT_OD; } - GPIO_Config(PIN_STPORT(pin), &gpioConfig); + GPIO_Config(PIN_APMPORT(pin), &gpioConfig); } rt_inline rt_int32_t bit2bitno(rt_uint32_t bit) @@ -228,18 +228,18 @@ rt_inline const struct pin_irq_map *get_pin_irq_map(uint32_t pinbit) return &pin_irq_map[mapindex]; }; -static rt_err_t apm32_pin_attach_irq(struct rt_device *device, rt_int32_t pin, - rt_uint32_t mode, void (*hdr)(void *args), void *args) +static rt_err_t _pin_attach_irq(struct rt_device *device, rt_int32_t pin, + rt_uint32_t mode, void (*hdr)(void *args), void *args) { rt_base_t level; rt_int32_t irqindex = -1; - if (PIN_PORT(pin) >= PIN_STPORT_MAX) + if (PIN_PORT(pin) >= PIN_APMPORT_MAX) { return -RT_ENOSYS; } - irqindex = bit2bitno(PIN_STPIN(pin)); + irqindex = bit2bitno(PIN_APMPIN(pin)); if (irqindex < 0 || irqindex >= ITEM_NUM(pin_irq_map)) { return RT_ENOSYS; @@ -247,9 +247,9 @@ static rt_err_t apm32_pin_attach_irq(struct rt_device *device, rt_int32_t pin, level = rt_hw_interrupt_disable(); if (pin_irq_hdr_tab[irqindex].pin == pin && - pin_irq_hdr_tab[irqindex].hdr == hdr && - pin_irq_hdr_tab[irqindex].mode == mode && - pin_irq_hdr_tab[irqindex].args == args) + pin_irq_hdr_tab[irqindex].hdr == hdr && + pin_irq_hdr_tab[irqindex].mode == mode && + pin_irq_hdr_tab[irqindex].args == args) { rt_hw_interrupt_enable(level); return RT_EOK; @@ -268,17 +268,17 @@ static rt_err_t apm32_pin_attach_irq(struct rt_device *device, rt_int32_t pin, return RT_EOK; } -static rt_err_t apm32_pin_dettach_irq(struct rt_device *device, rt_int32_t pin) +static rt_err_t _pin_dettach_irq(struct rt_device *device, rt_int32_t pin) { rt_base_t level; rt_int32_t irqindex = -1; - if (PIN_PORT(pin) >= PIN_STPORT_MAX) + if (PIN_PORT(pin) >= PIN_APMPORT_MAX) { return -RT_ENOSYS; } - irqindex = bit2bitno(PIN_STPIN(pin)); + irqindex = bit2bitno(PIN_APMPIN(pin)); if (irqindex < 0 || irqindex >= ITEM_NUM(pin_irq_map)) { return RT_ENOSYS; @@ -299,22 +299,22 @@ static rt_err_t apm32_pin_dettach_irq(struct rt_device *device, rt_int32_t pin) return RT_EOK; } -static rt_err_t apm32_pin_irq_enable(struct rt_device *device, rt_base_t pin, - rt_uint32_t enabled) +static rt_err_t _pin_irq_enable(struct rt_device *device, rt_base_t pin, + rt_uint32_t enabled) { const struct pin_irq_map *irqmap; rt_base_t level; rt_int32_t irqindex = -1; GPIO_Config_T gpioConfig; - if (PIN_PORT(pin) >= PIN_STPORT_MAX) + if (PIN_PORT(pin) >= PIN_APMPORT_MAX) { return -RT_ENOSYS; } if (enabled == PIN_IRQ_ENABLE) { - irqindex = bit2bitno(PIN_STPIN(pin)); + irqindex = bit2bitno(PIN_APMPIN(pin)); if (irqindex < 0 || irqindex >= ITEM_NUM(pin_irq_map)) { return RT_ENOSYS; @@ -331,7 +331,7 @@ static rt_err_t apm32_pin_irq_enable(struct rt_device *device, rt_base_t pin, irqmap = &pin_irq_map[irqindex]; /* Configure gpioConfigure */ - gpioConfig.pin = PIN_STPIN(pin); + gpioConfig.pin = PIN_APMPIN(pin); gpioConfig.speed = GPIO_SPEED_50MHz; switch (pin_irq_hdr_tab[irqindex].mode) { @@ -345,7 +345,7 @@ static rt_err_t apm32_pin_irq_enable(struct rt_device *device, rt_base_t pin, gpioConfig.mode = GPIO_MODE_IN_FLOATING; break; } - GPIO_Config(PIN_STPORT(pin), &gpioConfig); + GPIO_Config(PIN_APMPORT(pin), &gpioConfig); NVIC_EnableIRQRequest(irqmap->irqno, 5, 0); pin_irq_enable_mask |= irqmap->pinbit; @@ -354,14 +354,14 @@ static rt_err_t apm32_pin_irq_enable(struct rt_device *device, rt_base_t pin, } else if (enabled == PIN_IRQ_DISABLE) { - irqmap = get_pin_irq_map(PIN_STPIN(pin)); + irqmap = get_pin_irq_map(PIN_APMPIN(pin)); if (irqmap == RT_NULL) { return RT_ENOSYS; } level = rt_hw_interrupt_disable(); - + pin_irq_enable_mask &= ~irqmap->pinbit; if ((irqmap->pinbit >= GPIO_PIN_5) && (irqmap->pinbit <= GPIO_PIN_9)) @@ -393,13 +393,13 @@ static rt_err_t apm32_pin_irq_enable(struct rt_device *device, rt_base_t pin, } const static struct rt_pin_ops _apm32_pin_ops = { - apm32_pin_mode, - apm32_pin_write, - apm32_pin_read, - apm32_pin_attach_irq, - apm32_pin_dettach_irq, - apm32_pin_irq_enable, - apm32_pin_get, + _pin_mode, + _pin_write, + _pin_read, + _pin_attach_irq, + _pin_dettach_irq, + _pin_irq_enable, + _pin_get, }; rt_inline void pin_irq_hdr(int irqno) @@ -420,20 +420,20 @@ void GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin) void EINT0_IRQHandler(void) { rt_interrupt_enter(); - - if(EINT_ReadIntFlag(EINT_LINE_0)) + + if (EINT_ReadIntFlag(EINT_LINE_0)) { EINT_ClearIntFlag(EINT_LINE_0); GPIO_EXTI_IRQHandler(GPIO_PIN_0); } - + rt_interrupt_leave(); } void EINT1_IRQHandler(void) { rt_interrupt_enter(); - if(EINT_ReadIntFlag(EINT_LINE_1)) + if (EINT_ReadIntFlag(EINT_LINE_1)) { EINT_ClearIntFlag(EINT_LINE_1); GPIO_EXTI_IRQHandler(GPIO_PIN_1); @@ -444,7 +444,7 @@ void EINT1_IRQHandler(void) void EINT2_IRQHandler(void) { rt_interrupt_enter(); - if(EINT_ReadIntFlag(EINT_LINE_2)) + if (EINT_ReadIntFlag(EINT_LINE_2)) { EINT_ClearIntFlag(EINT_LINE_2); GPIO_EXTI_IRQHandler(GPIO_PIN_2); @@ -455,7 +455,7 @@ void EINT2_IRQHandler(void) void EINT3_IRQHandler(void) { rt_interrupt_enter(); - if(EINT_ReadIntFlag(EINT_LINE_3)) + if (EINT_ReadIntFlag(EINT_LINE_3)) { EINT_ClearIntFlag(EINT_LINE_3); GPIO_EXTI_IRQHandler(GPIO_PIN_3); @@ -466,7 +466,7 @@ void EINT3_IRQHandler(void) void EINT4_IRQHandler(void) { rt_interrupt_enter(); - if(EINT_ReadIntFlag(EINT_LINE_4)) + if (EINT_ReadIntFlag(EINT_LINE_4)) { EINT_ClearIntFlag(EINT_LINE_4); GPIO_EXTI_IRQHandler(GPIO_PIN_4); @@ -477,27 +477,27 @@ void EINT4_IRQHandler(void) void EINT9_5_IRQHandler(void) { rt_interrupt_enter(); - if(EINT_ReadIntFlag(EINT_LINE_5)) + if (EINT_ReadIntFlag(EINT_LINE_5)) { EINT_ClearIntFlag(EINT_LINE_5); GPIO_EXTI_IRQHandler(GPIO_PIN_5); } - if(EINT_ReadIntFlag(EINT_LINE_6)) + if (EINT_ReadIntFlag(EINT_LINE_6)) { EINT_ClearIntFlag(EINT_LINE_6); GPIO_EXTI_IRQHandler(GPIO_PIN_6); } - if(EINT_ReadIntFlag(EINT_LINE_7)) + if (EINT_ReadIntFlag(EINT_LINE_7)) { EINT_ClearIntFlag(EINT_LINE_7); GPIO_EXTI_IRQHandler(GPIO_PIN_7); } - if(EINT_ReadIntFlag(EINT_LINE_8)) + if (EINT_ReadIntFlag(EINT_LINE_8)) { EINT_ClearIntFlag(EINT_LINE_8); GPIO_EXTI_IRQHandler(GPIO_PIN_8); } - if(EINT_ReadIntFlag(EINT_LINE_9)) + if (EINT_ReadIntFlag(EINT_LINE_9)) { EINT_ClearIntFlag(EINT_LINE_9); GPIO_EXTI_IRQHandler(GPIO_PIN_9); @@ -508,32 +508,32 @@ void EINT9_5_IRQHandler(void) void EINT15_10_IRQHandler(void) { rt_interrupt_enter(); - if(EINT_ReadIntFlag(EINT_LINE_10)) + if (EINT_ReadIntFlag(EINT_LINE_10)) { EINT_ClearIntFlag(EINT_LINE_10); GPIO_EXTI_IRQHandler(GPIO_PIN_10); } - if(EINT_ReadIntFlag(EINT_LINE_11)) + if (EINT_ReadIntFlag(EINT_LINE_11)) { EINT_ClearIntFlag(EINT_LINE_11); GPIO_EXTI_IRQHandler(GPIO_PIN_11); } - if(EINT_ReadIntFlag(EINT_LINE_12)) + if (EINT_ReadIntFlag(EINT_LINE_12)) { EINT_ClearIntFlag(EINT_LINE_12); GPIO_EXTI_IRQHandler(GPIO_PIN_12); } - if(EINT_ReadIntFlag(EINT_LINE_13)) + if (EINT_ReadIntFlag(EINT_LINE_13)) { EINT_ClearIntFlag(EINT_LINE_13); GPIO_EXTI_IRQHandler(GPIO_PIN_13); } - if(EINT_ReadIntFlag(EINT_LINE_14)) + if (EINT_ReadIntFlag(EINT_LINE_14)) { EINT_ClearIntFlag(EINT_LINE_14); GPIO_EXTI_IRQHandler(GPIO_PIN_14); } - if(EINT_ReadIntFlag(EINT_LINE_15)) + if (EINT_ReadIntFlag(EINT_LINE_15)) { EINT_ClearIntFlag(EINT_LINE_15); GPIO_EXTI_IRQHandler(GPIO_PIN_15); diff --git a/bsp/apm32/libraries/Drivers/drv_usart.c b/bsp/apm32/libraries/Drivers/drv_usart.c index a2d4f55272..c3141be55c 100644 --- a/bsp/apm32/libraries/Drivers/drv_usart.c +++ b/bsp/apm32/libraries/Drivers/drv_usart.c @@ -14,8 +14,8 @@ #ifdef RT_USING_SERIAL #if !defined(BSP_USING_UART1) && !defined(BSP_USING_UART2) -#error "Please define at least one BSP_USING_UARTx" -/* this driver can be disabled at menuconfig -> RT-Thread Components -> Device Drivers */ + #error "Please define at least one BSP_USING_UARTx" + /* this driver can be disabled at menuconfig -> RT-Thread Components -> Device Drivers */ #endif /* stm32 config class */ @@ -40,18 +40,22 @@ enum static struct apm32_usart usart_config[] = { #ifdef BSP_USING_UART1 - { "uart1", + { + "uart1", USART1, - USART1_IRQn, }, + USART1_IRQn, + }, #endif #ifdef BSP_USING_UART2 - { "uart2", + { + "uart2", USART2, - USART2_IRQn, }, + USART2_IRQn, + }, #endif }; -static rt_err_t apm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg) +static rt_err_t _uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg) { USART_Config_T USART_ConfigStruct; RT_ASSERT(serial != RT_NULL); @@ -60,7 +64,7 @@ static rt_err_t apm32_configure(struct rt_serial_device *serial, struct serial_c struct apm32_usart *usart_instance = (struct apm32_usart *) serial->parent.user_data; apm32_usart_init(); - + USART_ConfigStruct.baudRate = cfg->baud_rate;; USART_ConfigStruct.hardwareFlow = USART_HARDWARE_FLOW_NONE; USART_ConfigStruct.mode = USART_MODE_TX_RX; @@ -113,14 +117,14 @@ static rt_err_t apm32_configure(struct rt_serial_device *serial, struct serial_c USART_Config(usart_instance->usartx, &USART_ConfigStruct); USART_Enable(usart_instance->usartx); - + return RT_EOK; } -static rt_err_t apm32_control(struct rt_serial_device *serial, int cmd, void *arg) +static rt_err_t _uart_control(struct rt_serial_device *serial, int cmd, void *arg) { struct apm32_usart *usart; - + RT_ASSERT(serial != RT_NULL); usart = (struct apm32_usart *) serial->parent.user_data; @@ -130,10 +134,10 @@ static rt_err_t apm32_control(struct rt_serial_device *serial, int cmd, void *ar { /* disable interrupt */ case RT_DEVICE_CTRL_CLR_INT: - + /* disable rx irq */ NVIC_DisableIRQRequest(usart->irq_type); - + /* disable interrupt */ USART_DisableInterrupt(usart->usartx, USART_INT_RXBNE); @@ -143,7 +147,7 @@ static rt_err_t apm32_control(struct rt_serial_device *serial, int cmd, void *ar case RT_DEVICE_CTRL_SET_INT: /* enable rx irq */ NVIC_EnableIRQRequest(usart->irq_type, 1, 0); - + /* enable interrupt */ USART_EnableInterrupt(usart->usartx, USART_INT_RXBNE); break; @@ -152,29 +156,29 @@ static rt_err_t apm32_control(struct rt_serial_device *serial, int cmd, void *ar return RT_EOK; } -static int apm32_putc(struct rt_serial_device *serial, char c) +static int _uart_putc(struct rt_serial_device *serial, char c) { struct apm32_usart *usart; RT_ASSERT(serial != RT_NULL); usart = (struct apm32_usart *) serial->parent.user_data; - + RT_ASSERT(usart != RT_NULL); - + USART_TxData(usart->usartx, (uint8_t) c); - + while (USART_ReadStatusFlag(usart->usartx, USART_FLAG_TXC) == RESET); - + return 1; } -static int apm32_getc(struct rt_serial_device *serial) +static int _uart_getc(struct rt_serial_device *serial) { int ch; struct apm32_usart *usart; RT_ASSERT(serial != RT_NULL); usart = (struct apm32_usart *) serial->parent.user_data; - + RT_ASSERT(usart != RT_NULL); ch = -1; @@ -197,7 +201,7 @@ static void usart_isr(struct rt_serial_device *serial) RT_ASSERT(serial != RT_NULL); RT_ASSERT(serial != RT_NULL); usart = (struct apm32_usart *) serial->parent.user_data; - + RT_ASSERT(usart != RT_NULL); /* UART in mode Receiver -------------------------------------------------*/ @@ -211,15 +215,18 @@ static void usart_isr(struct rt_serial_device *serial) else { - if (USART_ReadStatusFlag(usart->usartx, USART_FLAG_CTS) != RESET) { + if (USART_ReadStatusFlag(usart->usartx, USART_FLAG_CTS) != RESET) + { USART_ClearStatusFlag(usart->usartx, USART_FLAG_CTS); } - if (USART_ReadStatusFlag(usart->usartx, USART_FLAG_LBD) != RESET) { + if (USART_ReadStatusFlag(usart->usartx, USART_FLAG_LBD) != RESET) + { USART_ClearStatusFlag(usart->usartx, USART_FLAG_LBD); } - if (USART_ReadStatusFlag(usart->usartx, USART_FLAG_TXBE) != RESET) { + if (USART_ReadStatusFlag(usart->usartx, USART_FLAG_TXBE) != RESET) + { USART_ClearStatusFlag(usart->usartx, USART_FLAG_TXBE); } } @@ -258,10 +265,10 @@ void USART2_IRQHandler(void) static const struct rt_uart_ops apm32_usart_ops = { - .configure = apm32_configure, - .control = apm32_control, - .putc = apm32_putc, - .getc = apm32_getc, + .configure = _uart_configure, + .control = _uart_control, + .putc = _uart_putc, + .getc = _uart_getc, .dma_transmit = RT_NULL }; @@ -274,15 +281,16 @@ int rt_hw_usart_init(void) struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; rt_err_t result = 0; - for (index = 0; index < obj_num; index++) { + for (index = 0; index < obj_num; index++) + { usart_config[index].serial.ops = &apm32_usart_ops; usart_config[index].serial.config = config; /* register USART device */ result = rt_hw_serial_register(&usart_config[index].serial, - usart_config[index].name, - RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX - | RT_DEVICE_FLAG_INT_TX, &usart_config[index]); + usart_config[index].name, + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX + | RT_DEVICE_FLAG_INT_TX, &usart_config[index]); RT_ASSERT(result == RT_EOK); }