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.
This commit is contained in:
iabdalkader 2023-04-04 11:04:17 +02:00 committed by Damien George
parent eb6e5143c4
commit db4b416ea8

View File

@ -27,23 +27,16 @@
#include <stdlib.h>
#include "py/runtime.h"
#include "shared/runtime/interrupt_char.h"
#include "pendsv.h"
#include "lib/nxp_driver/sdk/CMSIS/Include/core_cm7.h"
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003)
#define IRQ_PRI_PENDSV NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 15, 0)
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
uint32_t pendsv_dispatch_active;
pendsv_dispatch_t pendsv_dispatch_table[PENDSV_DISPATCH_NUM_SLOTS];
#endif
void pendsv_init(void) {
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
pendsv_dispatch_active = false;
#endif
// set PendSV interrupt at lowest priority
NVIC_SetPriority(PendSV_IRQn, IRQ_PRI_PENDSV);
}
@ -51,11 +44,10 @@ void pendsv_init(void) {
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f) {
pendsv_dispatch_table[slot] = f;
pendsv_dispatch_active = true;
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) {
if (pendsv_dispatch_table[i] != NULL) {
pendsv_dispatch_t f = pendsv_dispatch_table[i];
@ -64,10 +56,4 @@ void pendsv_dispatch_handler(void) {
}
}
}
void PendSV_Handler(void) {
if (pendsv_dispatch_active) {
pendsv_dispatch_handler();
}
}
#endif