rp2/machine_pin: Add mp_hal_pin_interrupt C interface.

So C can can easily configure a pin interrupt and callback.

Signed-off-by: Andrew Leech <andrew@alelec.net>
This commit is contained in:
Andrew Leech
2022-04-30 12:45:43 +10:00
committed by Damien George
parent 9bd6169b72
commit 05f927b624
2 changed files with 52 additions and 30 deletions

View File

@@ -126,4 +126,14 @@ static inline void mp_hal_pin_high(mp_hal_pin_obj_t pin) {
gpio_set_mask(1 << pin);
}
enum mp_hal_pin_interrupt_trigger {
MP_HAL_PIN_TRIGGER_NONE,
MP_HAL_PIN_TRIGGER_LOW = GPIO_IRQ_LEVEL_LOW,
MP_HAL_PIN_TRIGGER_HIGH = GPIO_IRQ_LEVEL_HIGH,
MP_HAL_PIN_TRIGGER_FALL = GPIO_IRQ_EDGE_FALL,
MP_HAL_PIN_TRIGGER_RISE = GPIO_IRQ_EDGE_RISE,
};
void mp_hal_pin_interrupt(mp_hal_pin_obj_t pin, mp_obj_t handler, mp_uint_t trigger, bool hard);
#endif // MICROPY_INCLUDED_RP2_MPHALPORT_H