summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-10-24 16:48:27 +0700
committerhathach <[email protected]>2018-10-24 16:48:27 +0700
commit87d89cf5cbc42bc905654cca92c8a1809183a23d (patch)
tree8aeb8f50f4d4d4666e900f5e40ff494f92892866
parentc65e5b406fcf384011f9d8c6b2345b6cc77ea813 (diff)
fix nrf52 freeRTOS interrupt priority
-rw-r--r--hw/mcu/nordic/FreeRTOSConfig.h11
-rw-r--r--src/device/usbd.c6
2 files changed, 10 insertions, 7 deletions
diff --git a/hw/mcu/nordic/FreeRTOSConfig.h b/hw/mcu/nordic/FreeRTOSConfig.h
index be2768ba7..96de8f8c5 100644
--- a/hw/mcu/nordic/FreeRTOSConfig.h
+++ b/hw/mcu/nordic/FreeRTOSConfig.h
@@ -112,7 +112,10 @@
do {\
if ( !(_exp) ) { \
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
- if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */\
+ if ( (*ARM_CM_DHCSR) & 1UL ) { /* Only halt mcu if debugger is attached */ \
+ taskDISABLE_INTERRUPTS(); \
+ __asm("BKPT #0\n"); \
+ }\
}\
} while(0)
#else
@@ -136,7 +139,7 @@
/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
-#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x0f
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
@@ -155,10 +158,10 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
/* Interrupt priorities used by the kernel port layer itself. These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
-#define configKERNEL_INTERRUPT_PRIORITY configLIBRARY_LOWEST_INTERRUPT_PRIORITY
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
-#define configMAX_SYSCALL_INTERRUPT_PRIORITY configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#endif /* __FREERTOS_CONFIG__H */
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 1e96983b1..815948458 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -553,7 +553,7 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
.rhport = rhport,
.event_id = DCD_EVENT_SOF,
};
- osal_queue_send(_usbd_q, &task_event, true);
+ osal_queue_send(_usbd_q, &task_event, in_isr);
#endif
}
break;
@@ -582,11 +582,11 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
if (event->xfer_complete.len)
{
(void) event->xfer_complete.result; // TODO handle control error/stalled
- osal_semaphore_post( _usbd_ctrl_sem, true);
+ osal_semaphore_post( _usbd_ctrl_sem, in_isr);
}
}else
{
- osal_queue_send(_usbd_q, event, true);
+ osal_queue_send(_usbd_q, event, in_isr);
}
TU_ASSERT(event->xfer_complete.result == DCD_XFER_SUCCESS,);
break;