mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-08-18 20:48:41 +08:00
Merge pull request #2039 from balanceTWK/master
[bsp/stm32 uart drivers] 修复串口驱动 | Fixed serial port drivers
This commit is contained in:
@@ -97,8 +97,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
while (!(uart->uart_device->ISR & USART_FLAG_TXE));
|
||||
USART_ClearFlag(uart->uart_device,USART_FLAG_TC);
|
||||
uart->uart_device->TDR = c;
|
||||
while (!(uart->uart_device->ISR & USART_FLAG_TC));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
USART_ClearFlag(uart->uart_device,USART_FLAG_TC);
|
||||
uart->uart_device->DR = c;
|
||||
while (!(uart->uart_device->SR & USART_FLAG_TC));
|
||||
|
||||
|
||||
@@ -113,8 +113,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
struct stm32_uart *uart;
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
while (__HAL_UART_GET_FLAG(&uart->huart, UART_FLAG_TXE) == RESET);
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->huart), UART_FLAG_TC);
|
||||
uart->huart.Instance->DR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->huart), UART_FLAG_TC) == RESET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,6 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
|
||||
|
||||
/* Enable USART */
|
||||
USART_Cmd(uart->uart_device, ENABLE);
|
||||
|
||||
USART_ClearFlag(uart->uart_device,USART_FLAG_TC);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -159,6 +157,7 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
}
|
||||
else
|
||||
{
|
||||
USART_ClearFlag(uart->uart_device,USART_FLAG_TC);
|
||||
uart->uart_device->DR = c;
|
||||
while (!(uart->uart_device->SR & USART_FLAG_TC));
|
||||
}
|
||||
|
||||
@@ -166,8 +166,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
while (!(uart->uart_device->SR & USART_FLAG_TXE));
|
||||
USART_ClearFlag(uart->uart_device,USART_FLAG_TC);
|
||||
uart->uart_device->DR = c;
|
||||
while (!(uart->uart_device->SR & USART_FLAG_TC));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -155,8 +155,9 @@ static int drv_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct drv_uart *)serial->parent.user_data;
|
||||
|
||||
while((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->DR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,8 +185,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
while((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->DR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,8 +185,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
while((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->DR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,8 +185,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
while((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->DR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,8 +122,9 @@ static int drv_putc(struct rt_serial_device *serial, char c)
|
||||
struct drv_uart *uart;
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct drv_uart *)serial->parent.user_data;
|
||||
while ((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->DR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ static int drv_putc(struct rt_serial_device *serial, char c)
|
||||
struct drv_uart *uart;
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct drv_uart *)serial->parent.user_data;
|
||||
while ((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->TDR = c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -138,8 +138,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
while (!(uart->UartHandle.Instance->ISR & UART_FLAG_TXE));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->TDR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -185,8 +185,9 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||
|
||||
while((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->TDR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,8 +141,9 @@ static int drv_putc(struct rt_serial_device *serial, char c)
|
||||
|
||||
uart = (struct drv_uart *)serial->parent.user_data;
|
||||
|
||||
while ((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_TXE) == RESET));
|
||||
__HAL_UART_CLEAR_FLAG(&(uart->UartHandle), UART_FLAG_TC);
|
||||
uart->UartHandle.Instance->TDR = c;
|
||||
while (__HAL_UART_GET_FLAG(&(uart->UartHandle), UART_FLAG_TC) == RESET);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user