Merge pull request #4194 from tyustli/lixiang

[components][drivers] separate touch framework and pin framework
This commit is contained in:
Bernard Xiong 2020-12-27 23:49:51 +08:00 committed by GitHub
commit e3e8633786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 8 deletions

View File

@ -291,6 +291,11 @@ endif
config RT_USING_TOUCH
bool "Using Touch device drivers"
default n
if RT_USING_TOUCH
config RT_TOUCH_PIN_IRQ
bool "touch irq use pin irq"
default n
endif
menuconfig RT_USING_HWCRYPTO
bool "Using Hardware Crypto drivers"

View File

@ -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)

View File

@ -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