Skip to content

Commit e3e8633

Browse files
authored
Merge pull request #4194 from tyustli/lixiang
[components][drivers] separate touch framework and pin framework
2 parents eb4e4e0 + 48d7cf4 commit e3e8633

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

components/drivers/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@ endif
291291
config RT_USING_TOUCH
292292
bool "Using Touch device drivers"
293293
default n
294+
if RT_USING_TOUCH
295+
config RT_TOUCH_PIN_IRQ
296+
bool "touch irq use pin irq"
297+
default n
298+
endif
294299

295300
menuconfig RT_USING_HWCRYPTO
296301
bool "Using Hardware Crypto drivers"

components/drivers/touch/touch.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
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 */
3943
static 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 */
6773
static 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 */
7684
static 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

8494
static rt_err_t rt_touch_open(rt_device_t dev, rt_uint16_t oflag)

components/drivers/touch/touch.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ struct rt_touch_info
6666

6767
struct rt_touch_config
6868
{
69+
#ifdef RT_TOUCH_PIN_IRQ
6970
struct rt_device_pin_mode irq_pin; /* Interrupt pin, The purpose of this pin is to notification read data */
71+
#endif
7072
char *dev_name; /* The name of the communication device */
7173
void *user_data;
7274
};
@@ -103,6 +105,9 @@ int rt_hw_touch_register(rt_touch_t touch,
103105
rt_uint32_t flag,
104106
void *data);
105107

108+
/* if you doesn't use pin device. you must call this function in your touch irq callback */
109+
void rt_hw_touch_isr(rt_touch_t touch);
110+
106111
#ifdef __cplusplus
107112
}
108113
#endif

0 commit comments

Comments
 (0)