Skip to content

Commit db4b416

Browse files
iabdalkaderdpgeorge
authored andcommitted
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.
1 parent eb6e514 commit db4b416

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

ports/mimxrt/pendsv.c

+1-15
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,27 @@
2727
#include <stdlib.h>
2828

2929
#include "py/runtime.h"
30-
#include "shared/runtime/interrupt_char.h"
3130
#include "pendsv.h"
32-
#include "lib/nxp_driver/sdk/CMSIS/Include/core_cm7.h"
3331

3432
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003)
3533
#define IRQ_PRI_PENDSV NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 15, 0)
3634

3735
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
38-
uint32_t pendsv_dispatch_active;
3936
pendsv_dispatch_t pendsv_dispatch_table[PENDSV_DISPATCH_NUM_SLOTS];
4037
#endif
4138

4239
void pendsv_init(void) {
43-
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
44-
pendsv_dispatch_active = false;
45-
#endif
46-
4740
// set PendSV interrupt at lowest priority
4841
NVIC_SetPriority(PendSV_IRQn, IRQ_PRI_PENDSV);
4942
}
5043

5144
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
5245
void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f) {
5346
pendsv_dispatch_table[slot] = f;
54-
pendsv_dispatch_active = true;
5547
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
5648
}
5749

58-
void pendsv_dispatch_handler(void) {
50+
void PendSV_Handler(void) {
5951
for (size_t i = 0; i < PENDSV_DISPATCH_NUM_SLOTS; ++i) {
6052
if (pendsv_dispatch_table[i] != NULL) {
6153
pendsv_dispatch_t f = pendsv_dispatch_table[i];
@@ -64,10 +56,4 @@ void pendsv_dispatch_handler(void) {
6456
}
6557
}
6658
}
67-
68-
void PendSV_Handler(void) {
69-
if (pendsv_dispatch_active) {
70-
pendsv_dispatch_handler();
71-
}
72-
}
7359
#endif

0 commit comments

Comments
 (0)