X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm32l0%2Fao_lpuart_stm.c;h=08a0859b0ea1e18ad163b812c0b66ca23c90e7f9;hb=HEAD;hp=8fdc09f488a47d2375a954352d8df39c570cc896;hpb=33ea5b3658377cea325db285a3e457724f660384;p=fw%2Faltos diff --git a/src/stm32l0/ao_lpuart_stm.c b/src/stm32l0/ao_lpuart_stm.c index 8fdc09f4..08a0859b 100644 --- a/src/stm32l0/ao_lpuart_stm.c +++ b/src/stm32l0/ao_lpuart_stm.c @@ -85,7 +85,7 @@ _ao_lpuart_rx(struct ao_stm_lpuart *lpuart, int is_stdin) } #endif } else { - lpuart->reg->cr1 &= ~(1 << STM_LPUART_CR1_RXNEIE); + lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_RXNEIE); } } } @@ -96,11 +96,11 @@ ao_lpuart_isr(struct ao_stm_lpuart *lpuart, int is_stdin) _ao_lpuart_rx(lpuart, is_stdin); if (!_ao_lpuart_tx_start(lpuart)) - lpuart->reg->cr1 &= ~(1<< STM_LPUART_CR1_TXEIE); + lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_TXEIE); if (lpuart->reg->isr & (1 << STM_LPUART_ISR_TC)) { lpuart->tx_running = 0; - lpuart->reg->cr1 &= ~(1 << STM_LPUART_CR1_TCIE); + lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_TCIE); if (lpuart->draining) { lpuart->draining = 0; ao_wakeup(&lpuart->tx_fifo); @@ -182,7 +182,7 @@ ao_lpuart_set_speed(struct ao_stm_lpuart *lpuart, uint8_t speed) { if (speed > AO_SERIAL_SPEED_115200) return; - lpuart->reg->brr = AO_PCLK1 / ao_usart_speeds[speed]; + lpuart->reg->brr = 256 * AO_PCLK1 / ao_usart_speeds[speed]; } static void @@ -355,20 +355,21 @@ ao_lpuart1_enable(void) void ao_lpuart1_disable(void) { - /* Disable interrupts */ - stm_nvic_clear_enable(STM_ISR_LPUART1_AES_POS); - /* Stop LPUART */ ao_lpuart_disable(&ao_stm_lpuart1); + /* Disable interrupts */ + stm_nvic_clear_enable(STM_ISR_LPUART1_AES_POS); + /* Remap pins to GPIO use */ # if LPUART_1_PA0_PA1 - stm_afr_set(&stm_gpioa, 0, STM_AFR_NONE); - stm_afr_set(&stm_gpioa, 1, STM_AFR_NONE); + stm_moder_set(&stm_gpioa, 0, STM_MODER_INPUT); + stm_moder_set(&stm_gpioa, 1, STM_MODER_OUTPUT); # else # error "No LPUART_1 port configuration specified" # endif /* Disable LPUART */ - stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_LPUART1EN); + stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_LPUART1EN); } +