summaryrefslogtreecommitdiff
path: root/src/stm/ao_usb_stm.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-03-24 15:00:20 -0700
committerKeith Packard <keithp@keithp.com>2013-03-24 15:00:20 -0700
commitf3dc025a764ca6a2c44fb514ccaf22e6210f769d (patch)
tree05c0be2a58f2bfc84d2916d90baaea0f1609d890 /src/stm/ao_usb_stm.c
parent0365df9ed5a638bfdefb29eec830e51301c13936 (diff)
altos: Do not release interrupts from any pollchar function
getchar relies on interrupts being blocked across the pollchar calls and into the sleep call or it may go to sleep with data pending. This prefixes all pollchar functions with _ to indicate that they are to be called with interrupts blocked and eliminates all interrupt manipulation calls from within the pollchar functions. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stm/ao_usb_stm.c')
-rw-r--r--src/stm/ao_usb_stm.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/stm/ao_usb_stm.c b/src/stm/ao_usb_stm.c
index 9379e5cd..dfa58c42 100644
--- a/src/stm/ao_usb_stm.c
+++ b/src/stm/ao_usb_stm.c
@@ -229,10 +229,9 @@ ao_usb_set_stat_tx(int ep, uint32_t stat_tx)
}
static void
-ao_usb_set_stat_rx(int ep, uint32_t stat_rx) {
+_ao_usb_set_stat_rx(int ep, uint32_t stat_rx) {
uint32_t epr_write, epr_old;
- ao_arch_block_interrupts();
epr_write = epr_old = stm_usb.epr[ep];
epr_write &= STM_USB_EPR_PRESERVE_MASK;
epr_write |= STM_USB_EPR_INVARIANT;
@@ -240,6 +239,12 @@ ao_usb_set_stat_rx(int ep, uint32_t stat_rx) {
STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX,
stat_rx << STM_USB_EPR_STAT_RX);
stm_usb.epr[ep] = epr_write;
+}
+
+static void
+ao_usb_set_stat_rx(int ep, uint32_t stat_rx) {
+ ao_arch_block_interrupts();
+ _ao_usb_set_stat_rx(ep, stat_rx);
ao_arch_release_interrupts();
}
@@ -870,10 +875,10 @@ _ao_usb_out_recv(void)
ao_usb_rx_pos = 0;
/* ACK the packet */
- ao_usb_set_stat_rx(AO_USB_OUT_EPR, STM_USB_EPR_STAT_RX_VALID);
+ _ao_usb_set_stat_rx(AO_USB_OUT_EPR, STM_USB_EPR_STAT_RX_VALID);
}
-static int
+int
_ao_usb_pollchar(void)
{
uint8_t c;
@@ -896,16 +901,6 @@ _ao_usb_pollchar(void)
return c;
}
-int
-ao_usb_pollchar(void)
-{
- int c;
- ao_arch_block_interrupts();
- c = _ao_usb_pollchar();
- ao_arch_release_interrupts();
- return c;
-}
-
char
ao_usb_getchar(void)
{