touch interrupt initialization function */
| 41 | |
| 42 | /* touch interrupt initialization function */ |
| 43 | static rt_err_t rt_touch_irq_init(rt_touch_t touch) |
| 44 | { |
| 45 | #ifdef RT_TOUCH_PIN_IRQ |
| 46 | if (touch->config.irq_pin.pin == PIN_IRQ_PIN_NONE) |
| 47 | { |
| 48 | return -RT_EINVAL; |
| 49 | } |
| 50 | |
| 51 | rt_pin_mode(touch->config.irq_pin.pin, touch->config.irq_pin.mode); |
| 52 | |
| 53 | if (touch->config.irq_pin.mode == PIN_MODE_INPUT_PULLDOWN) |
| 54 | { |
| 55 | rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_RISING, touch_irq_callback, (void *)touch); |
| 56 | } |
| 57 | else if (touch->config.irq_pin.mode == PIN_MODE_INPUT_PULLUP) |
| 58 | { |
| 59 | rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_FALLING, touch_irq_callback, (void *)touch); |
| 60 | } |
| 61 | else if (touch->config.irq_pin.mode == PIN_MODE_INPUT) |
| 62 | { |
| 63 | rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_RISING_FALLING, touch_irq_callback, (void *)touch); |
| 64 | } |
| 65 | |
| 66 | rt_pin_irq_enable(touch->config.irq_pin.pin, PIN_IRQ_ENABLE); |
| 67 | #endif |
| 68 | |
| 69 | return RT_EOK; |
| 70 | } |
| 71 | |
| 72 | /* touch interrupt enable */ |
| 73 | static void rt_touch_irq_enable(rt_touch_t touch) |
no test coverage detected