uint8_t tx_started;
};
-#if HAS_SERIAL_1
-struct ao_stm_usart ao_stm_usart1;
-#endif
-#if HAS_SERIAL_2
-struct ao_stm_usart ao_stm_usart2;
-#endif
-#if HAS_SERIAL_3
-struct ao_stm_usart ao_stm_usart3;
-#endif
-
void
ao_debug_out(char c)
{
stm_usart1.dr = c;
}
-#if 0
-void
-outbyte(char c)
-{
- putchar(c);
-}
-#endif
-
static void
ao_usart_tx_start(struct ao_stm_usart *usart)
{
}
}
-#if HAS_SERIAL_1
-void stm_usart1_isr(void) { ao_usart_isr(&ao_stm_usart1, USE_SERIAL_STDIN); }
-#endif
-#if HAS_SERIAL_2
-void stm_usart2_isr(void) { ao_usart_isr(&ao_stm_usart2, 0); }
-#endif
-#if HAS_SERIAL_3
-void stm_usart3_isr(void) { ao_usart_isr(&ao_stm_usart3, 0); }
-#endif
-
char
ao_usart_getchar(struct ao_stm_usart *usart)
{
ao_usart_set_speed(usart, AO_SERIAL_SPEED_9600);
}
+#if HAS_SERIAL_1
+struct ao_stm_usart ao_stm_usart1;
+void stm_usart1_isr(void) { ao_usart_isr(&ao_stm_usart1, USE_SERIAL_STDIN); }
+#endif
+#if HAS_SERIAL_2
+struct ao_stm_usart ao_stm_usart2;
+void stm_usart2_isr(void) { ao_usart_isr(&ao_stm_usart2, 0); }
+#endif
+#if HAS_SERIAL_3
+struct ao_stm_usart ao_stm_usart3;
+void stm_usart3_isr(void) { ao_usart_isr(&ao_stm_usart3, 0); }
+#endif
+
void
ao_serial_init(void)
{
/*
* TX RX
* PA9 PA10
- * PB6 PB7
+ * PB6 PB7 *
*/
- stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOAEN);
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOBEN);
- stm_moder_set(&stm_gpioa, 9, STM_MODER_ALTERNATE);
- stm_moder_set(&stm_gpioa, 10, STM_MODER_ALTERNATE);
- stm_afr_set(&stm_gpioa, 9, STM_AFR_AF7);
- stm_afr_set(&stm_gpioa, 10, STM_AFR_AF7);
+ stm_moder_set(&stm_gpiob, 6, STM_MODER_ALTERNATE);
+ stm_moder_set(&stm_gpiob, 7, STM_MODER_ALTERNATE);
+ stm_afr_set(&stm_gpiob, 6, STM_AFR_AF7);
+ stm_afr_set(&stm_gpiob, 7, STM_AFR_AF7);
/* Enable USART */
stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_USART1EN);
-
ao_stm_usart1.reg = &stm_usart1;
+ ao_usart_init(&ao_stm_usart1);
+
stm_nvic_set_enable(STM_ISR_USART1_POS);
stm_nvic_set_priority(STM_ISR_USART1_POS, 4);
#if USE_SERIAL_STDIN
/* Enable USART */
stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USART2EN);
+ ao_usart_init(&stm_usart1);
ao_stm_usart2.reg = &stm_usart2;
/* Enable USART */
stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USART3EN);
+ ao_usart_init(&stm_usart1);
ao_stm_usart3.reg = &stm_usart3;