Commit db4b416e authored by iabdalkader's avatar iabdalkader Committed by Damien George

mimxrt/pendsv: Clean up PendSV code.

The dispatch active flag is only set once and never reset, so it will
always call the dispatch handler (once enabled), and it's not really
needed because it doesn't make things more efficient.

Also remove unused included headers.
parent eb6e5143
...@@ -27,23 +27,16 @@ ...@@ -27,23 +27,16 @@
#include <stdlib.h> #include <stdlib.h>
#include "py/runtime.h" #include "py/runtime.h"
#include "shared/runtime/interrupt_char.h"
#include "pendsv.h" #include "pendsv.h"
#include "lib/nxp_driver/sdk/CMSIS/Include/core_cm7.h"
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) #define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003)
#define IRQ_PRI_PENDSV NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 15, 0) #define IRQ_PRI_PENDSV NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 15, 0)
#if defined(PENDSV_DISPATCH_NUM_SLOTS) #if defined(PENDSV_DISPATCH_NUM_SLOTS)
uint32_t pendsv_dispatch_active;
pendsv_dispatch_t pendsv_dispatch_table[PENDSV_DISPATCH_NUM_SLOTS]; pendsv_dispatch_t pendsv_dispatch_table[PENDSV_DISPATCH_NUM_SLOTS];
#endif #endif
void pendsv_init(void) { void pendsv_init(void) {
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
pendsv_dispatch_active = false;
#endif
// set PendSV interrupt at lowest priority // set PendSV interrupt at lowest priority
NVIC_SetPriority(PendSV_IRQn, IRQ_PRI_PENDSV); NVIC_SetPriority(PendSV_IRQn, IRQ_PRI_PENDSV);
} }
...@@ -51,11 +44,10 @@ void pendsv_init(void) { ...@@ -51,11 +44,10 @@ void pendsv_init(void) {
#if defined(PENDSV_DISPATCH_NUM_SLOTS) #if defined(PENDSV_DISPATCH_NUM_SLOTS)
void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f) { void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f) {
pendsv_dispatch_table[slot] = f; pendsv_dispatch_table[slot] = f;
pendsv_dispatch_active = true;
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
} }
void pendsv_dispatch_handler(void) { void PendSV_Handler(void) {
for (size_t i = 0; i < PENDSV_DISPATCH_NUM_SLOTS; ++i) { for (size_t i = 0; i < PENDSV_DISPATCH_NUM_SLOTS; ++i) {
if (pendsv_dispatch_table[i] != NULL) { if (pendsv_dispatch_table[i] != NULL) {
pendsv_dispatch_t f = pendsv_dispatch_table[i]; pendsv_dispatch_t f = pendsv_dispatch_table[i];
...@@ -64,10 +56,4 @@ void pendsv_dispatch_handler(void) { ...@@ -64,10 +56,4 @@ void pendsv_dispatch_handler(void) {
} }
} }
} }
void PendSV_Handler(void) {
if (pendsv_dispatch_active) {
pendsv_dispatch_handler();
}
}
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment