summaryrefslogtreecommitdiff
path: root/src/stm/ao_usb_stm.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-20 02:59:40 -0800
committerKeith Packard <keithp@keithp.com>2017-02-20 12:32:50 -0800
commit839eadbc8e5694842eb498c6e47cfbf08ba8fbf4 (patch)
tree68d81c5df977993c91c823951dc826403fa75a8d /src/stm/ao_usb_stm.c
parent088ddbb177efc8be2fc467524dc1668553080d3b (diff)
altos/stm: Allow use basepri instead of primask for masking interrupts
This allows for high priority interrupts (priority 0) to run, even when other interrupts are blocked. Code executing in such interrupt handlers must not attempt to control task execution as that will race with the scheduler. Select this by defining AO_NONMASK_INTERRUPT in ao_pins.h. non-maskable interrupt priority is AO_STM_NVIC_NONMASK_PRIORITY 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.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/stm/ao_usb_stm.c b/src/stm/ao_usb_stm.c
index 2abaf10f..33e0617c 100644
--- a/src/stm/ao_usb_stm.c
+++ b/src/stm/ao_usb_stm.c
@@ -1109,7 +1109,7 @@ struct ao_usb_dbg {
int line;
char *msg;
uint32_t value;
- uint32_t primask;
+ uint32_t prival;
#if TX_DBG
uint16_t in_count;
uint32_t in_epr;
@@ -1125,19 +1125,23 @@ struct ao_usb_dbg {
#endif
};
-#define NUM_USB_DBG 128
+#define NUM_USB_DBG 16
-static struct ao_usb_dbg dbg[128];
+static struct ao_usb_dbg dbg[NUM_USB_DBG];
static int dbg_i;
static void _dbg(int line, char *msg, uint32_t value)
{
- uint32_t primask;
+ uint32_t prival;
dbg[dbg_i].line = line;
dbg[dbg_i].msg = msg;
dbg[dbg_i].value = value;
- asm("mrs %0,primask" : "=&r" (primask));
- dbg[dbg_i].primask = primask;
+#if AO_NONMASK_INTERRUPT
+ asm("mrs %0,basepri" : "=&r" (prival));
+#else
+ asm("mrs %0,primask" : "=&r" (prival));
+#endif
+ dbg[dbg_i].prival = prival;
#if TX_DBG
dbg[dbg_i].in_count = in_count;
dbg[dbg_i].in_epr = stm_usb.epr[AO_USB_IN_EPR];