Skip to content

Commit

Permalink
Move into platform.h, and prevent use of irqs without entries
Browse files Browse the repository at this point in the history
  • Loading branch information
will-v-pi committed Jan 21, 2025
1 parent de16925 commit 2fe1e0a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/rp2040/pico_platform/include/pico/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@
#define PICO_RP2040_B2_SUPPORTED 1
#endif

// PICO_CONFIG: PICO_VECTOR_TABLE_NUM_IRQS, Number of IRQ vectors to include in the vector table, type=int, default=NUM_IRQS, advanced=true, group=pico_platform
#ifndef PICO_VECTOR_TABLE_NUM_IRQS
#define PICO_VECTOR_TABLE_NUM_IRQS NUM_IRQS
#endif

#ifndef PICO_RAM_VECTOR_TABLE_SIZE
#define PICO_RAM_VECTOR_TABLE_SIZE (VTABLE_FIRST_IRQ + NUM_IRQS)
#define PICO_RAM_VECTOR_TABLE_SIZE (VTABLE_FIRST_IRQ + PICO_VECTOR_TABLE_NUM_IRQS)
#endif

// PICO_CONFIG: PICO_CLKDIV_ROUND_NEAREST, True if floating point clock divisors should be rounded to the nearest possible clock divisor by default rather than rounding down, type=bool, default=1, group=pico_platform
Expand Down
8 changes: 6 additions & 2 deletions src/rp2350/pico_platform/include/pico/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@
#define PICO_NO_RAM_VECTOR_TABLE 0
#endif

// PICO_CONFIG: PICO_VECTOR_TABLE_NUM_IRQS, Number of IRQ vectors to include in the vector table, type=int, default=NUM_IRQS, advanced=true, group=pico_platform
#ifndef PICO_VECTOR_TABLE_NUM_IRQS
#define PICO_VECTOR_TABLE_NUM_IRQS NUM_IRQS
#endif

#ifndef PICO_RAM_VECTOR_TABLE_SIZE
#define PICO_RAM_VECTOR_TABLE_SIZE (VTABLE_FIRST_IRQ + NUM_IRQS)
#define PICO_RAM_VECTOR_TABLE_SIZE (VTABLE_FIRST_IRQ + PICO_VECTOR_TABLE_NUM_IRQS)
#endif

// PICO_CONFIG: PICO_USE_STACK_GUARDS, Enable/disable stack guards, type=bool, default=0, advanced=true, group=pico_platform
Expand Down Expand Up @@ -284,4 +289,3 @@ __force_inline static int32_t __mul_instruction(int32_t a, int32_t b) {
#endif // __ASSEMBLER__

#endif

2 changes: 1 addition & 1 deletion src/rp2_common/hardware_irq/include/hardware/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ extern "C" {
typedef void (*irq_handler_t)(void);

static inline void check_irq_param(__unused uint num) {
invalid_params_if(HARDWARE_IRQ, num >= NUM_IRQS);
invalid_params_if(HARDWARE_IRQ, num >= PICO_VECTOR_TABLE_NUM_IRQS);
}

/*! \brief Set specified interrupt's priority
Expand Down
5 changes: 0 additions & 5 deletions src/rp2_common/pico_crt0/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ __vectors:
// we don't include any IRQ vectors; we will initialize them during runtime_init in the RAM vector table
#else

// PICO_CONFIG: PICO_VECTOR_TABLE_NUM_IRQS, Number of IRQ vectors to include in the vector table, type=int, default=NUM_IRQS, group=pico_crt0
#ifndef PICO_VECTOR_TABLE_NUM_IRQS
#define PICO_VECTOR_TABLE_NUM_IRQS NUM_IRQS
#endif

.macro if_irq_word num func
.if \num < PICO_VECTOR_TABLE_NUM_IRQS
.word \func
Expand Down

0 comments on commit 2fe1e0a

Please sign in to comment.