summaryrefslogtreecommitdiff
path: root/src/stm/ao_serial_stm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm/ao_serial_stm.c')
-rw-r--r--src/stm/ao_serial_stm.c15
1 files changed, 7 insertions, 8 deletions
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,13 +211,11 @@ 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);
stm_nvic_set_priority(STM_ISR_USART1_POS, 4);