mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c
- Revision:
- 293:2a9cf2ed1474
- Parent:
- 242:7074e42da0b2
diff -r e8c83abeb68f -r 2a9cf2ed1474 targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c --- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c Thu Aug 21 08:00:07 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/serial_api.c Thu Aug 21 10:45:06 2014 +0100 @@ -91,6 +91,10 @@ UartHandle.Init.Mode = UART_MODE_TX_RX; } + // Disable the reception overrun detection + UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT; + UartHandle.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE; + HAL_UART_Init(&UartHandle); } @@ -217,7 +221,7 @@ } if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_RXNE) != RESET) { irq_handler(serial_irq_ids[id], RxIrq); - __HAL_UART_SEND_REQ(&UartHandle, UART_RXDATA_FLUSH_REQUEST); + volatile uint32_t tmpval = UartHandle.Instance->RDR; // Clear RXNE bit } } } @@ -278,9 +282,9 @@ if (irq == RxIrq) { __HAL_UART_DISABLE_IT(&UartHandle, UART_IT_RXNE); // Check if TxIrq is disabled too - if ((UartHandle.Instance->CR1 & USART_CR1_TXEIE) == 0) all_disabled = 1; + if ((UartHandle.Instance->CR1 & USART_CR1_TCIE) == 0) all_disabled = 1; } else { // TxIrq - __HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TXE); + __HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TC); // Check if RxIrq is disabled too if ((UartHandle.Instance->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1; } @@ -297,13 +301,13 @@ int serial_getc(serial_t *obj) { USART_TypeDef *uart = (USART_TypeDef *)(obj->uart); while (!serial_readable(obj)); - return (int)(uart->RDR & 0xFF); + return (int)(uart->RDR & (uint32_t)0xFF); } void serial_putc(serial_t *obj, int c) { USART_TypeDef *uart = (USART_TypeDef *)(obj->uart); while (!serial_writable(obj)); - uart->TDR = (uint16_t)(c & 0xFF); + uart->TDR = (uint32_t)(c & (uint32_t)0xFF); } int serial_readable(serial_t *obj) {