diff options
| author | Bernard Xiong <[email protected]> | 2014-09-14 19:42:32 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2014-09-14 19:42:32 +0800 |
| commit | e41fe36a088d0b4944799f2f8627d13c835544bd (patch) | |
| tree | 6106ddf20b460941cfbdecf31e1401476ab2aabb /bsp | |
| parent | 521f24f1093ab3eeeb914648b71ad21d7e0e782d (diff) | |
| parent | 762f18d743580b4b8f3a7954d481dcbe1d2ecf30 (diff) | |
Merge pull request #341 from armink/master
[YModem] YModem optimization;
[BSP] Add more error handling in STM32F1 bsp.
Diffstat (limited to 'bsp')
| -rw-r--r-- | bsp/stm32f10x/drivers/usart.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/bsp/stm32f10x/drivers/usart.c b/bsp/stm32f10x/drivers/usart.c index bbaf4ec032..4c6f24af30 100644 --- a/bsp/stm32f10x/drivers/usart.c +++ b/bsp/stm32f10x/drivers/usart.c @@ -21,19 +21,19 @@ #include <rtdevice.h> /* USART1 */ -#define UART1_GPIO_TX GPIO_Pin_9 -#define UART1_GPIO_RX GPIO_Pin_10 -#define UART1_GPIO GPIOA +#define UART1_GPIO_TX GPIO_Pin_9 +#define UART1_GPIO_RX GPIO_Pin_10 +#define UART1_GPIO GPIOA /* USART2 */ -#define UART2_GPIO_TX GPIO_Pin_2 -#define UART2_GPIO_RX GPIO_Pin_3 -#define UART2_GPIO GPIOA +#define UART2_GPIO_TX GPIO_Pin_2 +#define UART2_GPIO_RX GPIO_Pin_3 +#define UART2_GPIO GPIOA /* USART3_REMAP[1:0] = 00 */ -#define UART3_GPIO_TX GPIO_Pin_10 -#define UART3_GPIO_RX GPIO_Pin_11 -#define UART3_GPIO GPIOB +#define UART3_GPIO_TX GPIO_Pin_10 +#define UART3_GPIO_RX GPIO_Pin_11 +#define UART3_GPIO GPIOB /* STM32 uart driver */ struct stm32_uart @@ -163,7 +163,10 @@ void USART1_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } - + if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) + { + stm32_getc(&serial1); + } /* leave interrupt */ rt_interrupt_leave(); } @@ -197,6 +200,10 @@ void USART2_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } + if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) + { + stm32_getc(&serial2); + } /* leave interrupt */ rt_interrupt_leave(); @@ -204,7 +211,7 @@ void USART2_IRQHandler(void) #endif /* RT_USING_UART2 */ #if defined(RT_USING_UART3) -/* UART1 device driver structure */ +/* UART3 device driver structure */ struct stm32_uart uart3 = { USART3, @@ -231,6 +238,10 @@ void USART3_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } + if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) + { + stm32_getc(&serial3); + } /* leave interrupt */ rt_interrupt_leave(); @@ -282,7 +293,7 @@ static void GPIO_Configuration(void) /* Configure USART Rx/tx PIN */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = UART2_GPIO_RX; - GPIO_Init(UART1_GPIO, &GPIO_InitStructure); + GPIO_Init(UART2_GPIO, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = UART2_GPIO_TX; |
