summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-12-10 10:58:08 +1100
committerDamien George <damien.p.george@gmail.com>2018-12-10 16:21:50 +1100
commite0c24325034244a89f608459cc6ace09c142fcf1 (patch)
tree0d7780fe7d8177dc56c8d7a3fcfbc2cf46f9df14
parentbc3f0dddac3ae680eead8c6447af20167a4368ff (diff)
stm32/uart: Simplify deinit of UART, no need to call HAL.
The HAL just clears UE and then clears all the UART control registers.
-rw-r--r--ports/stm32/uart.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ports/stm32/uart.c b/ports/stm32/uart.c
index 061738181..4882ebafb 100644
--- a/ports/stm32/uart.c
+++ b/ports/stm32/uart.c
@@ -332,10 +332,10 @@ void uart_set_rxbuf(pyb_uart_obj_t *self, size_t len, void *buf) {
void uart_deinit(pyb_uart_obj_t *self) {
self->is_enabled = false;
- UART_HandleTypeDef huart;
- huart.Instance = self->uartx;
- HAL_UART_DeInit(&huart);
+ // Disable UART
+ self->uartx->CR1 &= ~USART_CR1_UE;
+ // Reset and turn off the UART peripheral
if (self->uart_id == 1) {
HAL_NVIC_DisableIRQ(USART1_IRQn);
__HAL_RCC_USART1_FORCE_RESET();