1616#include <rtdbg.h>
1717
1818/* ISR for touch interrupt */
19- static void irq_callback ( void * args )
19+ void rt_hw_touch_isr ( rt_touch_t touch )
2020{
21- rt_touch_t touch ;
22-
23- touch = (rt_touch_t )args ;
24-
21+ RT_ASSERT (touch );
2522 if (touch -> parent .rx_indicate == RT_NULL )
2623 {
2724 return ;
@@ -35,9 +32,17 @@ static void irq_callback(void *args)
3532 touch -> parent .rx_indicate (& touch -> parent , 1 );
3633}
3734
35+ #ifdef RT_TOUCH_PIN_IRQ
36+ static void touch_irq_callback (void * param )
37+ {
38+ rt_hw_touch_isr ((rt_touch_t )param );
39+ }
40+ #endif
41+
3842/* touch interrupt initialization function */
3943static rt_err_t rt_touch_irq_init (rt_touch_t touch )
4044{
45+ #ifdef RT_TOUCH_PIN_IRQ
4146 if (touch -> config .irq_pin .pin == RT_PIN_NONE )
4247 {
4348 return - RT_EINVAL ;
@@ -47,38 +52,43 @@ static rt_err_t rt_touch_irq_init(rt_touch_t touch)
4752
4853 if (touch -> config .irq_pin .mode == PIN_MODE_INPUT_PULLDOWN )
4954 {
50- rt_pin_attach_irq (touch -> config .irq_pin .pin , PIN_IRQ_MODE_RISING , irq_callback , (void * )touch );
55+ rt_pin_attach_irq (touch -> config .irq_pin .pin , PIN_IRQ_MODE_RISING , touch_irq_callback , (void * )touch );
5156 }
5257 else if (touch -> config .irq_pin .mode == PIN_MODE_INPUT_PULLUP )
5358 {
54- rt_pin_attach_irq (touch -> config .irq_pin .pin , PIN_IRQ_MODE_FALLING , irq_callback , (void * )touch );
59+ rt_pin_attach_irq (touch -> config .irq_pin .pin , PIN_IRQ_MODE_FALLING , touch_irq_callback , (void * )touch );
5560 }
5661 else if (touch -> config .irq_pin .mode == PIN_MODE_INPUT )
5762 {
58- rt_pin_attach_irq (touch -> config .irq_pin .pin , PIN_IRQ_MODE_RISING_FALLING , irq_callback , (void * )touch );
63+ rt_pin_attach_irq (touch -> config .irq_pin .pin , PIN_IRQ_MODE_RISING_FALLING , touch_irq_callback , (void * )touch );
5964 }
6065
6166 rt_pin_irq_enable (touch -> config .irq_pin .pin , PIN_IRQ_ENABLE );
67+ #endif
6268
6369 return RT_EOK ;
6470}
6571
6672/* touch interrupt enable */
6773static void rt_touch_irq_enable (rt_touch_t touch )
6874{
75+ #ifdef RT_TOUCH_PIN_IRQ
6976 if (touch -> config .irq_pin .pin != RT_PIN_NONE )
7077 {
7178 rt_pin_irq_enable (touch -> config .irq_pin .pin , RT_TRUE );
7279 }
80+ #endif
7381}
7482
7583/* touch interrupt disable */
7684static void rt_touch_irq_disable (rt_touch_t touch )
7785{
86+ #ifdef RT_TOUCH_PIN_IRQ
7887 if (touch -> config .irq_pin .pin != RT_PIN_NONE )
7988 {
8089 rt_pin_irq_enable (touch -> config .irq_pin .pin , RT_FALSE );
8190 }
91+ #endif
8292}
8393
8494static rt_err_t rt_touch_open (rt_device_t dev , rt_uint16_t oflag )
0 commit comments