diff options
| author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-09-03 18:29:45 -0400 |
|---|---|---|
| committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-09-03 18:29:45 -0400 |
| commit | c5dfc108e6c0313f54fc0ebaa7b31e5f2b41e8e8 (patch) | |
| tree | dfbbf24f499ca6dee1ad40a4639a196d502805c4 /wirish/ext_interrupts.cpp | |
| parent | 9992325cefda4213e61b24cc4b52955ba3f538d2 (diff) | |
| parent | d9f8b4f8c462b4fb2e1324567803cfcb839cfc2f (diff) | |
Merge branch 'callback_interrupt_handlers'
Diffstat (limited to 'wirish/ext_interrupts.cpp')
| -rw-r--r-- | wirish/ext_interrupts.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/wirish/ext_interrupts.cpp b/wirish/ext_interrupts.cpp index a3e61fd..1195ea9 100644 --- a/wirish/ext_interrupts.cpp +++ b/wirish/ext_interrupts.cpp @@ -39,13 +39,6 @@ static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode); -/** - * @brief Attach an interrupt handler to a pin, triggering on the given mode. - * @param pin Pin to attach an interrupt handler onto. - * @param handler Function to call when the external interrupt is triggered. - * @param mode Trigger mode for the given interrupt. - * @see ExtIntTriggerMode - */ void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode) { if (pin >= BOARD_NR_GPIO_PINS || !handler) { return; @@ -59,10 +52,21 @@ void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode) { outMode); } -/** - * @brief Disable any external interrupt attached to a pin. - * @param pin Pin number to detach any interrupt from. - */ +void attachInterrupt(uint8 pin, voidArgumentFuncPtr handler, void *arg, + ExtIntTriggerMode mode) { + if (pin >= BOARD_NR_GPIO_PINS || !handler) { + return; + } + + exti_trigger_mode outMode = exti_out_mode(mode); + + exti_attach_callback((exti_num)(PIN_MAP[pin].gpio_bit), + gpio_exti_port(PIN_MAP[pin].gpio_device), + handler, + arg, + outMode); +} + void detachInterrupt(uint8 pin) { if (pin >= BOARD_NR_GPIO_PINS) { return; |
