mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 09:00:23 +08:00
stm32/uart: Simplify deinit of UART, no need to call HAL.
The HAL just clears UE and then clears all the UART control registers.
This commit is contained in:
parent
bc3f0dddac
commit
e0c2432503
@ -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) {
|
void uart_deinit(pyb_uart_obj_t *self) {
|
||||||
self->is_enabled = false;
|
self->is_enabled = false;
|
||||||
|
|
||||||
UART_HandleTypeDef huart;
|
// Disable UART
|
||||||
huart.Instance = self->uartx;
|
self->uartx->CR1 &= ~USART_CR1_UE;
|
||||||
HAL_UART_DeInit(&huart);
|
|
||||||
|
|
||||||
|
// Reset and turn off the UART peripheral
|
||||||
if (self->uart_id == 1) {
|
if (self->uart_id == 1) {
|
||||||
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
||||||
__HAL_RCC_USART1_FORCE_RESET();
|
__HAL_RCC_USART1_FORCE_RESET();
|
||||||
|
Loading…
Reference in New Issue
Block a user