File syn_exti.h¶
FileList > drivers > syn_exti.h
Go to the source code of this file
GPIO interrupt dispatcher — register callbacks per pin. More...
#include "../common/syn_defs.h"#include "../port/syn_port_exti.h"#include <stdbool.h>#include <stdint.h>
Public Types¶
| Type | Name |
|---|---|
| typedef void(* | SYN_EXTI_Callback |
Public Functions¶
| Type | Name |
|---|---|
| size_t | syn_exti_count (void) Get the number of registered callbacks. |
| void | syn_exti_disable (SYN_GPIO_Pin pin) Disable interrupt for a pin. |
| void | syn_exti_enable (SYN_GPIO_Pin pin) Enable interrupt for a registered pin. |
| void | syn_exti_init (void) |
| void | syn_exti_irq_handler (SYN_GPIO_Pin pin) IRQ handler — call from platform ISR. |
| SYN_Status | syn_exti_register (SYN_GPIO_Pin pin, SYN_EXTI_Edge edge, SYN_EXTI_Callback cb, void * ctx) Register a callback for a pin interrupt. |
| void | syn_exti_unregister (SYN_GPIO_Pin pin) Unregister a pin callback. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_EXTI_MAX_PINS 16 |
Detailed Description¶
Thin layer over the EXTI port. Registers a callback for each pin; when the platform ISR fires, call syn_exti_irq_handler(pin) and the dispatcher invokes the registered callback.
Optionally integrates with the work queue for deferred processing (recommended for non-trivial handlers).
** **
void on_button_press(SYN_GPIO_Pin pin, void *ctx) {
// runs in ISR context — keep it fast!
*(bool *)ctx = true;
}
syn_exti_init();
syn_exti_register(PIN_BUTTON, SYN_EXTI_FALLING,
on_button_press, &button_flag);
syn_exti_enable(PIN_BUTTON);
** **
// STM32 example:
void EXTI0_IRQHandler(void) {
if (EXTI->PR & (1 << 0)) {
EXTI->PR = (1 << 0); // clear
syn_exti_irq_handler(0);
}
}
Public Types Documentation¶
typedef SYN_EXTI_Callback¶
EXTI callback — called from ISR context unless deferred.
Public Functions Documentation¶
function syn_exti_count¶
Get the number of registered callbacks.
Returns:
Registration count.
function syn_exti_disable¶
Disable interrupt for a pin.
Parameters:
pinGPIO pin.
function syn_exti_enable¶
Enable interrupt for a registered pin.
Parameters:
pinGPIO pin.
function syn_exti_init¶
Initialize the EXTI dispatcher.
function syn_exti_irq_handler¶
IRQ handler — call from platform ISR.
Looks up the registered callback for pin and invokes it. This is the glue between hardware ISR and the dispatcher.
Parameters:
pinGPIO pin that triggered the interrupt.
function syn_exti_register¶
Register a callback for a pin interrupt.
SYN_Status syn_exti_register (
SYN_GPIO_Pin pin,
SYN_EXTI_Edge edge,
SYN_EXTI_Callback cb,
void * ctx
)
Parameters:
pinGPIO pin.edgeTrigger edge.cbCallback (runs in ISR context).ctxUser context passed to callback.
Returns:
SYN_OK, or SYN_ERROR if table full.
function syn_exti_unregister¶
Unregister a pin callback.
Parameters:
pinGPIO pin.
Macro Definition Documentation¶
define SYN_EXTI_MAX_PINS¶
Max number of EXTI-enabled pins
The documentation for this class was generated from the following file src/syntropic/drivers/syn_exti.h