altosui: Add config and pyro tabs to graph widget
[fw/altos] / src / stm32l0 / ao_serial_stm.c
index a75804e9bd395209633e0aff0c9348d87131a3f0..650f2f1f636c335f80e8c27068948b42c65a1cfc 100644 (file)
@@ -66,7 +66,7 @@ _ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
                        }
 #endif
                } else {
-                       usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+                       usart->reg->cr1 &= ~(1UL << STM_USART_CR1_RXNEIE);
                }
        }
 }
@@ -77,11 +77,11 @@ ao_usart_isr(struct ao_stm_usart *usart, int is_stdin)
        _ao_usart_rx(usart, is_stdin);
 
        if (!_ao_usart_tx_start(usart))
-               usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TXEIE);
 
        if (usart->reg->isr & (1 << STM_USART_ISR_TC)) {
                usart->tx_running = 0;
-               usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+               usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TCIE);
                if (usart->draining) {
                        usart->draining = 0;
                        ao_wakeup(&usart->tx_fifo);
@@ -158,7 +158,7 @@ ao_usart_drain(struct ao_stm_usart *usart)
 }
 #endif
 
-static const uint32_t ao_usart_speeds[] = {
+const uint32_t ao_usart_speeds[] = {
        [AO_SERIAL_SPEED_4800] = 4800,
        [AO_SERIAL_SPEED_9600] = 9600,
        [AO_SERIAL_SPEED_19200] = 19200,
@@ -380,10 +380,24 @@ ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart,
 void
 ao_serial_shutdown(void)
 {
+# if SERIAL_2_PA2_PA3
+       stm_moder_set(&stm_gpioa, 2, STM_MODER_INPUT);
+       stm_moder_set(&stm_gpioa, 3, STM_MODER_INPUT);
+# elif SERIAL_2_PA9_PA10
+       stm_moder_set(&stm_gpioa, 9, STM_MODER_INPUT);
+       stm_moder_set(&stm_gpioa, 10, STM_MODER_INPUT);
+# elif SERIAL_2_PA14_PA15
+       stm_moder_set(&stm_gpioa, 14, STM_MODER_INPUT);
+       stm_moder_set(&stm_gpioa, 15, STM_MODER_INPUT);
+# elif SERIAL_2_PB6_PB7
+       stm_moder_set(&stm_gpiob, 6, STM_MODER_INPUT);
+       stm_moder_set(&stm_gpiob, 7, STM_MODER_INPUT);
+#endif
 #if HAS_SERIAL_1
        stm_rcc.apb2enr &= ~(1 << STM_RCC_APB2ENR_USART1EN);
 #endif
 #if HAS_SERIAL_2
+       stm_nvic_set_disable(STM_ISR_USART2_POS);
        stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USART2EN);
 #endif
 }