summaryrefslogtreecommitdiff
path: root/components/drivers/touch
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2020-12-28 04:13:25 -0600
committerGitHub <[email protected]>2020-12-28 04:13:25 -0600
commit3bca2cfb418f03c529fc8563b62c19d391caf90b (patch)
tree469dbaebaa3325f64e59b71b4063f135bb6fdfd8 /components/drivers/touch
parent84a5f96453ee2719695b719142af08b7a51b623d (diff)
parent936db0e396f286a7f493cdadb698cf9340a82448 (diff)
Merge pull request #7 from RT-Thread/master
pr
Diffstat (limited to 'components/drivers/touch')
-rw-r--r--components/drivers/touch/SConscript2
-rw-r--r--components/drivers/touch/touch.c26
-rw-r--r--components/drivers/touch/touch.h5
3 files changed, 24 insertions, 9 deletions
diff --git a/components/drivers/touch/SConscript b/components/drivers/touch/SConscript
index f370b2aba6..6c2a126c9c 100644
--- a/components/drivers/touch/SConscript
+++ b/components/drivers/touch/SConscript
@@ -6,6 +6,6 @@ cwd = GetCurrentDir()
src = ['touch.c']
CPPPATH = [cwd, cwd + '/../include']
-group = DefineGroup('Touch', src, depend = ['RT_USING_TOUCH', 'RT_USING_DEVICE'], CPPPATH = CPPPATH)
+group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_TOUCH', 'RT_USING_DEVICE'], CPPPATH = CPPPATH)
Return('group')
diff --git a/components/drivers/touch/touch.c b/components/drivers/touch/touch.c
index 80ba6378bb..e9595e9f8f 100644
--- a/components/drivers/touch/touch.c
+++ b/components/drivers/touch/touch.c
@@ -16,12 +16,9 @@
#include <rtdbg.h>
/* ISR for touch interrupt */
-static void irq_callback(void *args)
+void rt_hw_touch_isr(rt_touch_t touch)
{
- rt_touch_t touch;
-
- touch = (rt_touch_t)args;
-
+ RT_ASSERT(touch);
if (touch->parent.rx_indicate == RT_NULL)
{
return;
@@ -35,9 +32,17 @@ static void irq_callback(void *args)
touch->parent.rx_indicate(&touch->parent, 1);
}
+#ifdef RT_TOUCH_PIN_IRQ
+static void touch_irq_callback(void *param)
+{
+ rt_hw_touch_isr((rt_touch_t)param);
+}
+#endif
+
/* touch interrupt initialization function */
static rt_err_t rt_touch_irq_init(rt_touch_t touch)
{
+#ifdef RT_TOUCH_PIN_IRQ
if (touch->config.irq_pin.pin == RT_PIN_NONE)
{
return -RT_EINVAL;
@@ -47,18 +52,19 @@ static rt_err_t rt_touch_irq_init(rt_touch_t touch)
if (touch->config.irq_pin.mode == PIN_MODE_INPUT_PULLDOWN)
{
- rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_RISING, irq_callback, (void *)touch);
+ rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_RISING, touch_irq_callback, (void *)touch);
}
else if (touch->config.irq_pin.mode == PIN_MODE_INPUT_PULLUP)
{
- rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_FALLING, irq_callback, (void *)touch);
+ rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_FALLING, touch_irq_callback, (void *)touch);
}
else if (touch->config.irq_pin.mode == PIN_MODE_INPUT)
{
- rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_RISING_FALLING, irq_callback, (void *)touch);
+ rt_pin_attach_irq(touch->config.irq_pin.pin, PIN_IRQ_MODE_RISING_FALLING, touch_irq_callback, (void *)touch);
}
rt_pin_irq_enable(touch->config.irq_pin.pin, PIN_IRQ_ENABLE);
+#endif
return RT_EOK;
}
@@ -66,19 +72,23 @@ static rt_err_t rt_touch_irq_init(rt_touch_t touch)
/* touch interrupt enable */
static void rt_touch_irq_enable(rt_touch_t touch)
{
+#ifdef RT_TOUCH_PIN_IRQ
if (touch->config.irq_pin.pin != RT_PIN_NONE)
{
rt_pin_irq_enable(touch->config.irq_pin.pin, RT_TRUE);
}
+#endif
}
/* touch interrupt disable */
static void rt_touch_irq_disable(rt_touch_t touch)
{
+#ifdef RT_TOUCH_PIN_IRQ
if (touch->config.irq_pin.pin != RT_PIN_NONE)
{
rt_pin_irq_enable(touch->config.irq_pin.pin, RT_FALSE);
}
+#endif
}
static rt_err_t rt_touch_open(rt_device_t dev, rt_uint16_t oflag)
diff --git a/components/drivers/touch/touch.h b/components/drivers/touch/touch.h
index c33fe17520..be12c24206 100644
--- a/components/drivers/touch/touch.h
+++ b/components/drivers/touch/touch.h
@@ -66,7 +66,9 @@ struct rt_touch_info
struct rt_touch_config
{
+#ifdef RT_TOUCH_PIN_IRQ
struct rt_device_pin_mode irq_pin; /* Interrupt pin, The purpose of this pin is to notification read data */
+#endif
char *dev_name; /* The name of the communication device */
void *user_data;
};
@@ -103,6 +105,9 @@ int rt_hw_touch_register(rt_touch_t touch,
rt_uint32_t flag,
void *data);
+/* if you doesn't use pin device. you must call this function in your touch irq callback */
+void rt_hw_touch_isr(rt_touch_t touch);
+
#ifdef __cplusplus
}
#endif