mirror of https://github.com/ARMmbed/mbed-os.git
STM32: serial: clear Overrun flag if it is set when checking if readable
Note that this could have side effects on the application as it would not be aware that data has been missed. This may be later solved by adding an error management parameter to the Serial API in mbed. The advantage is that the serial link can work again.pull/4502/head
parent
072a227bc9
commit
c5c33f1d0f
|
@ -472,7 +472,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -289,7 +289,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -438,7 +438,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -373,7 +373,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -435,7 +435,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -426,7 +426,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -355,7 +355,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -345,7 +345,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -391,7 +391,12 @@ int serial_readable(serial_t *obj)
|
|||
{
|
||||
struct serial_s *obj_s = SERIAL_S(obj);
|
||||
UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];
|
||||
|
||||
/* To avoid a target blocking case, let's check for
|
||||
* possible OVERRUN error and discard it
|
||||
*/
|
||||
if(__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE)) {
|
||||
__HAL_UART_CLEAR_OREFLAG(huart);
|
||||
}
|
||||
// Check if data is received
|
||||
return (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) ? 1 : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue