aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c
diff options
context:
space:
mode:
authorUladzimir Pylinski <barthess@yandex.ru>2016-07-19 18:56:03 +0000
committerUladzimir Pylinski <barthess@yandex.ru>2016-07-19 18:56:03 +0000
commit0edf3f363b0e8222477f1bf956a421ab6e7d2cd5 (patch)
tree9f53cb6ac75e50776abe22373a41d820ca4255f2 /os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c
parent57dc4418deee2b123301d36eec3a020acee3814b (diff)
downloadChibiOS-0edf3f363b0e8222477f1bf956a421ab6e7d2cd5.tar.gz
ChibiOS-0edf3f363b0e8222477f1bf956a421ab6e7d2cd5.tar.bz2
ChibiOS-0edf3f363b0e8222477f1bf956a421ab6e7d2cd5.zip
[STM32. USARTv2] Added receiver timeout handling.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9713 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c')
-rw-r--r--os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c b/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c
index ceb14fe67..0012ef259 100644
--- a/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c
+++ b/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c
@@ -220,6 +220,7 @@ static void usart_stop(UARTDriver *uartp) {
*/
static void usart_start(UARTDriver *uartp) {
uint32_t cr1;
+ const uint32_t tmo = uartp->config->timeout;
USART_TypeDef *u = uartp->usart;
/* Defensive programming, starting from a clean state.*/
@@ -242,6 +243,13 @@ static void usart_start(UARTDriver *uartp) {
cr1 = USART_CR1_UE | USART_CR1_PEIE | USART_CR1_TE | USART_CR1_RE;
u->CR1 = uartp->config->cr1 | cr1;
+ /* Set receive timeout and check it appliance */
+ if (tmo > 0) {
+ osalDbgAssert(tmo <= USART_RTOR_RTO, "Timeout overflow");
+ u->RTOR = tmo;
+ osalDbgAssert(tmo == u->RTOR, "Timeout feature unsupported in this UART");
+ }
+
/* Starting the receiver idle loop.*/
uart_enter_rx_idle_loop(uartp);
}
@@ -325,6 +333,10 @@ static void serve_usart_irq(UARTDriver *uartp) {
/* End of transmission, a callback is generated.*/
_uart_tx2_isr_code(uartp);
}
+
+ if ((isr & USART_ISR_IDLE) || (isr & USART_ISR_RTOF)) {
+ _uart_timeout_isr_code(uartp);
+ }
}
/*===========================================================================*/