summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2023-04-04 11:04:17 +0200
committerDamien George <damien@micropython.org>2023-04-05 10:16:22 +1000
commitdb4b416ea824e66414530b84928671f701ac5b84 (patch)
treefc1366a62703a59056b47e9c3241cd5850236d25
parenteb6e5143c422e13f9b07790a88473e4813024e92 (diff)
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.
-rw-r--r--ports/mimxrt/pendsv.c16
1 files changed, 1 insertions, 15 deletions
diff --git a/ports/mimxrt/pendsv.c b/ports/mimxrt/pendsv.c
index 7638b160d..11f2ef5e1 100644
--- a/ports/mimxrt/pendsv.c
+++ b/ports/mimxrt/pendsv.c
@@ -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