X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fstm%2Fao_serial_stm.c;h=38f16e5eb96d8042d17dc02b8e475fdbf4cd67e3;hp=ead2570f4d983eee2e24c0bf1c0988c81e30bd38;hb=ab6ea9043b592c25948a70b6204d613756a9a250;hpb=8ba5344514f8ed51f6fd69ca09f6c7035c4fd0da diff --git a/src/stm/ao_serial_stm.c b/src/stm/ao_serial_stm.c index ead2570f..38f16e5e 100644 --- a/src/stm/ao_serial_stm.c +++ b/src/stm/ao_serial_stm.c @@ -51,19 +51,20 @@ ao_serial_tx1_start(void) void stm_usart1_isr(void) { uint32_t sr; - cli(); + sr = stm_usart1.sr; stm_usart1.sr = 0; - sei(); + if (sr & (1 << STM_USART_SR_RXNE)) { + char c = stm_usart1.dr; if (!ao_fifo_full(ao_usart1_rx_fifo)) - ao_fifo_insert(ao_usart1_rx_fifo, stm_usart1.dr); + ao_fifo_insert(ao_usart1_rx_fifo, c); ao_wakeup(&ao_usart1_rx_fifo); #if USE_SERIAL_STDIN ao_wakeup(&ao_stdin_ready); #endif } - if (sr & (1 << STM_USART_SR_TXE)) { + if (sr & (1 << STM_USART_SR_TC)) { ao_serial_tx1_started = 0; ao_serial_tx1_start(); ao_wakeup(&ao_usart1_tx_fifo); @@ -174,8 +175,8 @@ ao_serial_init(void) (0 << STM_USART_CR1_PCE) | (0 << STM_USART_CR1_PS) | (0 << STM_USART_CR1_PEIE) | - (1 << STM_USART_CR1_TXEIE) | - (0 << STM_USART_CR1_TCIE) | + (0 << STM_USART_CR1_TXEIE) | + (1 << STM_USART_CR1_TCIE) | (1 << STM_USART_CR1_RXNEIE) | (0 << STM_USART_CR1_IDLEIE) | (1 << STM_USART_CR1_TE) | @@ -210,12 +211,10 @@ ao_serial_init(void) ao_serial_set_speed(AO_SERIAL_SPEED_9600); printf ("serial initialized\n"); -#if 0 #if USE_SERIAL_STDIN ao_add_stdio(ao_serial_pollchar, ao_serial_putchar, NULL); -#endif #endif stm_nvic_set_enable(STM_ISR_USART1_POS);