mirror of https://github.com/ARMmbed/mbed-os.git
[NUCLEO_F072RB] Improvement of Serial hal
parent
63cf897d5a
commit
b507427292
|
@ -90,6 +90,10 @@ static void init_uart(serial_t *obj) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -223,7 +227,7 @@ static void uart_irq(UARTName name, int id) {
|
|||
}
|
||||
if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_RXNE) != RESET) {
|
||||
irq_handler(serial_irq_ids[id], RxIrq);
|
||||
__HAL_UART_CLEAR_IT(&UartHandle, UART_FLAG_RXNE);
|
||||
volatile uint32_t tmpval = UartHandle.Instance->RDR; // Clear RXNE bit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,9 +297,9 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) {
|
|||
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;
|
||||
}
|
||||
|
@ -339,8 +343,8 @@ int serial_writable(serial_t *obj) {
|
|||
|
||||
void serial_clear(serial_t *obj) {
|
||||
UartHandle.Instance = (USART_TypeDef *)(obj->uart);
|
||||
__HAL_UART_CLEAR_IT(&UartHandle, UART_FLAG_TXE);
|
||||
__HAL_UART_CLEAR_IT(&UartHandle, UART_FLAG_RXNE);
|
||||
__HAL_UART_CLEAR_IT(&UartHandle, UART_FLAG_TC);
|
||||
__HAL_UART_SEND_REQ(&UartHandle, UART_RXDATA_FLUSH_REQUEST);
|
||||
}
|
||||
|
||||
void serial_pinout_tx(PinName tx) {
|
||||
|
|
Loading…
Reference in New Issue