1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

drivers/stmpe811: improve interrupt callback management

This commit is contained in:
Alexandre Abadie 2022-01-07 18:30:34 +01:00
parent 3676b63583
commit 86192de81b
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 5 additions and 16 deletions

View File

@ -118,17 +118,6 @@ static int _read_burst(const stmpe811_t *dev, uint8_t reg, void *buf, size_t len
}
#endif /* bus mode selection */
static void _gpio_irq(void *arg)
{
const stmpe811_t *dev = (const stmpe811_t *)arg;
assert(dev);
if (dev->cb) {
dev->cb(dev->cb_arg);
}
}
static int _soft_reset(const stmpe811_t *dev)
{
if (_write_reg(dev, STMPE811_SYS_CTRL1, STMPE811_SYS_CTRL1_SOFT_RESET ) < 0) {
@ -191,8 +180,6 @@ int stmpe811_init(stmpe811_t *dev, const stmpe811_params_t *params, stmpe811_eve
void *arg)
{
dev->params = *params;
dev->cb = cb;
dev->cb_arg = arg;
dev->prev_x = 0;
dev->prev_y = 0;
@ -295,7 +282,7 @@ int stmpe811_init(stmpe811_t *dev, const stmpe811_params_t *params, stmpe811_eve
if (gpio_is_valid(dev->params.int_pin)) {
DEBUG("[stmpe811] init: configuring touchscreen interrupt\n");
gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_FALLING, _gpio_irq, dev);
gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_FALLING, cb, arg);
/* Enable touchscreen interrupt */
ret += _write_reg(dev, STMPE811_INT_EN, STMPE811_INT_EN_TOUCH_DET);

View File

@ -23,6 +23,7 @@
#include <assert.h>
#include "kernel_defines.h"
#include "periph/gpio.h"
#include "stmpe811.h"
#include "stmpe811_touch_dev.h"
@ -77,8 +78,9 @@ void _stmpe811_set_event_callback(const touch_dev_t *touch_dev, touch_event_cb_t
stmpe811_t *dev = (stmpe811_t *)touch_dev;
assert(dev);
dev->cb = (stmpe811_event_cb_t)cb;
dev->cb_arg = arg;
if (gpio_is_valid(dev->params.int_pin)) {
gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_FALLING, cb, arg);
}
}
const touch_dev_driver_t stmpe811_touch_dev_driver = {