Attach an interrupt handler to a GPIO pin number. The pin number must be one specified with a GPIO() marker in hwdef.dat */
| 307 | must be one specified with a GPIO() marker in hwdef.dat |
| 308 | */ |
| 309 | bool GPIO::attach_interrupt(uint8_t pin, |
| 310 | irq_handler_fn_t fn, |
| 311 | INTERRUPT_TRIGGER_TYPE mode) |
| 312 | { |
| 313 | struct gpio_entry *g = gpio_by_pin_num(pin, false); |
| 314 | if (!g) { |
| 315 | return false; |
| 316 | } |
| 317 | g->isr_disabled_ticks = 0; |
| 318 | g->isr_quota = 0; |
| 319 | if (!_attach_interrupt(g->pal_line, |
| 320 | palcallback_t(fn?pal_interrupt_cb_functor:nullptr), |
| 321 | g, |
| 322 | mode)) { |
| 323 | return false; |
| 324 | } |
| 325 | g->fn = fn; |
| 326 | g->isr_mode = mode; |
| 327 | return true; |
| 328 | } |
| 329 | |
| 330 | /* |
| 331 | Attach an interrupt handler to ioline_t |
no test coverage detected