Merge pull request #2039 from balanceTWK/master

[bsp/stm32 uart drivers] 修复串口驱动 | Fixed serial port drivers
This commit is contained in:
Bernard Xiong 2018-12-08 09:12:00 +08:00 committed by GitHub
commit 94e6c349a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 25 additions and 14 deletions

View File

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

View File

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

View File

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

View File

@ -101,8 +101,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));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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