projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/stm32f4: Use full printf/scanf (including floats)
[fw/altos]
/
src
/
avr
/
ao_serial_avr.c
diff --git
a/src/avr/ao_serial_avr.c
b/src/avr/ao_serial_avr.c
index dcee246ce3eb66191e393708aeee88858dc7ef34..cfdd7dfe2883431c74610ed6e4b98fcb3cf7a164 100644
(file)
--- a/
src/avr/ao_serial_avr.c
+++ b/
src/avr/ao_serial_avr.c
@@
-3,7
+3,8
@@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-17,8
+18,8
@@
#include "ao.h"
#include "ao.h"
-
__xdata
struct ao_fifo ao_serial1_rx_fifo;
-
__xdata
struct ao_fifo ao_serial1_tx_fifo;
+struct ao_fifo ao_serial1_rx_fifo;
+struct ao_fifo ao_serial1_tx_fifo;
void
ao_debug_out(char c)
void
ao_debug_out(char c)
@@
-39,7
+40,7
@@
ISR(USART1_RX_vect)
#endif
}
#endif
}
-static
__xdata
uint8_t ao_serial_tx1_started;
+static uint8_t ao_serial_tx1_started;
static void
ao_serial1_tx_start(void)
static void
ao_serial1_tx_start(void)
@@
-59,52
+60,51
@@
ISR(USART1_UDRE_vect)
ao_wakeup(&ao_serial1_tx_fifo);
}
ao_wakeup(&ao_serial1_tx_fifo);
}
-char
-ao_serial1_getchar(void) __critical
-{
- char c;
- cli();
- while (ao_fifo_empty(ao_serial1_rx_fifo))
- ao_sleep(&ao_serial1_rx_fifo);
- ao_fifo_remove(ao_serial1_rx_fifo, c);
- sei();
- return c;
-}
-
#if USE_SERIAL_1_STDIN
#if USE_SERIAL_1_STDIN
-char
-ao_serial1_pollchar(void) __critical
+int
+_ao_serial1_pollchar(void)
{
char c;
{
char c;
- cli();
if (ao_fifo_empty(ao_serial1_rx_fifo)) {
sei();
return AO_READ_AGAIN;
}
ao_fifo_remove(ao_serial1_rx_fifo,c);
if (ao_fifo_empty(ao_serial1_rx_fifo)) {
sei();
return AO_READ_AGAIN;
}
ao_fifo_remove(ao_serial1_rx_fifo,c);
- sei();
return c;
}
#endif
return c;
}
#endif
+char
+ao_serial1_getchar(void)
+{
+ char c;
+
+ ao_arch_block_interrupts();
+ while (ao_fifo_empty(ao_serial1_rx_fifo))
+ ao_sleep(&ao_serial1_rx_fifo);
+ ao_fifo_remove(ao_serial1_rx_fifo, c);
+ ao_arch_release_interrupts();
+ return c;
+}
+
void
void
-ao_serial1_putchar(char c)
__critical
+ao_serial1_putchar(char c)
{
{
-
cli
();
+
ao_arch_block_interrupts
();
while (ao_fifo_full(ao_serial1_tx_fifo))
ao_sleep(&ao_serial1_tx_fifo);
ao_fifo_insert(ao_serial1_tx_fifo, c);
ao_serial_tx1_start();
while (ao_fifo_full(ao_serial1_tx_fifo))
ao_sleep(&ao_serial1_tx_fifo);
ao_fifo_insert(ao_serial1_tx_fifo, c);
ao_serial_tx1_start();
-
sei
();
+
ao_arch_release_interrupts
();
}
void
}
void
-ao_serial1_drain(void)
__critical
+ao_serial1_drain(void)
{
{
-
cli
();
+
ao_arch_block_interrupts
();
while (!ao_fifo_empty(ao_serial1_tx_fifo))
ao_sleep(&ao_serial1_tx_fifo);
while (!ao_fifo_empty(ao_serial1_tx_fifo))
ao_sleep(&ao_serial1_tx_fifo);
-
sei
();
+
ao_arch_release_interrupts
();
}
static const struct {
}
static const struct {
@@
-155,7
+155,7
@@
ao_serial_init(void)
(1 << RXCIE1) | /* Enable receive interrupts */
(1 << UDRIE1)); /* Enable transmit empty interrupts */
#if USE_SERIAL_1_STDIN
(1 << RXCIE1) | /* Enable receive interrupts */
(1 << UDRIE1)); /* Enable transmit empty interrupts */
#if USE_SERIAL_1_STDIN
- ao_add_stdio(ao_serial1_pollchar,
+ ao_add_stdio(
_
ao_serial1_pollchar,
ao_serial1_putchar,
NULL);
#endif
ao_serial1_putchar,
NULL);
#endif