Просмотр исходного кода

fix nrf52 freeRTOS interrupt priority

hathach 7 лет назад
Родитель
Сommit
87d89cf5cb
2 измененных файлов с 10 добавлено и 7 удалено
  1. 7 4
      hw/mcu/nordic/FreeRTOSConfig.h
  2. 3 3
      src/device/usbd.c

+ 7 - 4
hw/mcu/nordic/FreeRTOSConfig.h

@@ -112,7 +112,10 @@
   do {\
   do {\
     if ( !(_exp) ) { \
     if ( !(_exp) ) { \
       volatile uint32_t* ARM_CM_DHCSR =  ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
       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)
   } while(0)
 #else
 #else
@@ -136,7 +139,7 @@
 
 
 /* The lowest interrupt priority that can be used in a call to a "set priority"
 /* The lowest interrupt priority that can be used in a call to a "set priority"
 function. */
 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
 /* 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
 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
 /* 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. */
 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 !!!!
 /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
 See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 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 */
 #endif /* __FREERTOS_CONFIG__H */

+ 3 - 3
src/device/usbd.c

@@ -553,7 +553,7 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
           .rhport          = rhport,
           .rhport          = rhport,
           .event_id        = DCD_EVENT_SOF,
           .event_id        = DCD_EVENT_SOF,
       };
       };
-      osal_queue_send(_usbd_q, &task_event, true);
+      osal_queue_send(_usbd_q, &task_event, in_isr);
       #endif
       #endif
     }
     }
     break;
     break;
@@ -582,11 +582,11 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
         if (event->xfer_complete.len)
         if (event->xfer_complete.len)
         {
         {
           (void) event->xfer_complete.result; // TODO handle control error/stalled
           (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
       }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,);
       TU_ASSERT(event->xfer_complete.result == DCD_XFER_SUCCESS,);
     break;
     break;