|
@@ -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;
|