From db4b416ea824e66414530b84928671f701ac5b84 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 4 Apr 2023 11:04:17 +0200 Subject: [PATCH] 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. --- ports/mimxrt/pendsv.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/ports/mimxrt/pendsv.c b/ports/mimxrt/pendsv.c index 7638b160d8..11f2ef5e1c 100644 --- a/ports/mimxrt/pendsv.c +++ b/ports/mimxrt/pendsv.c @@ -27,23 +27,16 @@ #include #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