Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/rp2_common/hardware_gpio/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ static void _gpio_set_irq_enabled(uint gpio, uint32_t events, bool enabled, io_b
}

void gpio_set_irq_enabled(uint gpio, uint32_t events, bool enabled) {
// either this call disables the interrupt
// or callback should already be set (raw or using gpio_set_irq_callback)
// either this call disables the interrupt or callback should already be set.
// this protects against enabling the interrupt without callback set
assert(!enabled
|| (raw_irq_mask[get_core_num()] & (1ull<<gpio))
|| callbacks[get_core_num()]);
assert(!enabled || irq_has_handler(IO_IRQ_BANK0));

// Separate mask/force/status per-core, so check which core called, and
// set the relevant IRQ controls.
Expand Down
16 changes: 15 additions & 1 deletion src/rp2_common/hardware_irq/include/hardware/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,23 @@ void irq_add_shared_handler(uint num, irq_handler_t handler, uint8_t order_prior
*/
void irq_remove_handler(uint num, irq_handler_t handler);

/*! \brief Determine if the current handler for the given number is shared
/*! \brief Determine if there is an installed IRQ handler for the given interrupt number
* \ingroup hardware_irq
*
* See \ref irq_set_exclusive_handler() for discussion on the scope of handlers
* when using both cores.
*
* \param num Interrupt number \ref interrupt_nums
* \return true if the specified IRQ has a handler
*/
bool irq_has_handler(uint num);

/*! \brief Determine if the current IRQ andler for the given interrupt number is shared
* \ingroup hardware_irq
*
* See \ref irq_set_exclusive_handler() for discussion on the scope of handlers
* when using both cores.
*
* \param num Interrupt number \ref interrupt_nums
* \return true if the specified IRQ has a shared handler
*/
Expand Down
8 changes: 7 additions & 1 deletion src/rp2_common/hardware_irq/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,16 @@ static inline bool is_shared_irq_raw_handler(irq_handler_t raw_handler) {
return (uintptr_t)raw_handler - (uintptr_t)irq_handler_chain_slots < sizeof(irq_handler_chain_slots);
}

bool irq_has_handler(uint irq_num) {
check_irq_param(irq_num);
irq_handler_t handler = irq_get_vtable_handler(irq_num);
return handler && handler != __unhandled_user_irq;
}

bool irq_has_shared_handler(uint irq_num) {
check_irq_param(irq_num);
irq_handler_t handler = irq_get_vtable_handler(irq_num);
return handler && is_shared_irq_raw_handler(handler);
return is_shared_irq_raw_handler(handler);
}

#else // PICO_DISABLE_SHARED_IRQ_HANDLERS
Expand Down
Loading