user_irqs should be claimed globally not per core, since vector tabes are shared (#1183)
This commit is contained in:
parent
8b8778c59b
commit
a66ba7a942
@ -18,6 +18,11 @@
|
||||
#define PICO_DISABLE_SHARED_IRQ_HANDLERS 0
|
||||
#endif
|
||||
|
||||
// PICO_CONFIG: PICO_VTABLE_PER_CORE, user is using separate vector tables per core, type=bool, default=0, group=hardware_irq
|
||||
#ifndef PICO_VTABLE_PER_CORE
|
||||
#define PICO_VTABLE_PER_CORE 0
|
||||
#endif
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
#include "pico.h"
|
||||
|
@ -15,7 +15,17 @@
|
||||
|
||||
extern void __unhandled_user_irq(void);
|
||||
|
||||
#if PICO_VTABLE_PER_CORE
|
||||
static uint8_t user_irq_claimed[NUM_CORES];
|
||||
static inline uint8_t *user_irq_claimed_ptr(void) {
|
||||
return &user_irq_claimed[get_core_num()];
|
||||
}
|
||||
#else
|
||||
static uint8_t user_irq_claimed;
|
||||
static inline uint8_t *user_irq_claimed_ptr(void) {
|
||||
return &user_irq_claimed;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline irq_handler_t *get_vtable(void) {
|
||||
return (irq_handler_t *) scb_hw->vtor;
|
||||
@ -435,20 +445,20 @@ static uint get_user_irq_claim_index(uint irq_num) {
|
||||
}
|
||||
|
||||
void user_irq_claim(uint irq_num) {
|
||||
hw_claim_or_assert(&user_irq_claimed[get_core_num()], get_user_irq_claim_index(irq_num), "User IRQ is already claimed");
|
||||
hw_claim_or_assert(user_irq_claimed_ptr(), get_user_irq_claim_index(irq_num), "User IRQ is already claimed");
|
||||
}
|
||||
|
||||
void user_irq_unclaim(uint irq_num) {
|
||||
hw_claim_clear(&user_irq_claimed[get_core_num()], get_user_irq_claim_index(irq_num));
|
||||
hw_claim_clear(user_irq_claimed_ptr(), get_user_irq_claim_index(irq_num));
|
||||
}
|
||||
|
||||
int user_irq_claim_unused(bool required) {
|
||||
int bit = hw_claim_unused_from_range(&user_irq_claimed[get_core_num()], required, 0, NUM_USER_IRQS - 1, "No user IRQs are available");
|
||||
int bit = hw_claim_unused_from_range(user_irq_claimed_ptr(), required, 0, NUM_USER_IRQS - 1, "No user IRQs are available");
|
||||
if (bit >= 0) bit = (int)NUM_IRQS - bit - 1;
|
||||
return bit;
|
||||
}
|
||||
|
||||
bool user_irq_is_claimed(uint irq_num) {
|
||||
return hw_is_claimed(&user_irq_claimed[get_core_num()], get_user_irq_claim_index(irq_num));
|
||||
return hw_is_claimed(user_irq_claimed_ptr(), get_user_irq_claim_index(irq_num));
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,10 @@ void multicore_launch_core1_with_stack(void (*entry)(void), uint32_t *stack_bott
|
||||
stack_ptr[0] = (uintptr_t) entry;
|
||||
stack_ptr[1] = (uintptr_t) stack_bottom;
|
||||
stack_ptr[2] = (uintptr_t) core1_wrapper;
|
||||
#if PICO_VTABLE_PER_CORE
|
||||
#warning PICO_VTABLE_PER_CORE==1 is not currently supported in pico_multicore
|
||||
panic_unsupported();
|
||||
#endif
|
||||
multicore_launch_core1_raw(core1_trampoline, stack_ptr, scb_hw->vtor);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user