1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 10:32:44 +01:00

drivers/stmpe811: init INT pin only if callback is defined

If the INT pin is initialized if the callback function parameter `cb` is `NULL`, the driver crashes the first time an interrupt is triggered. Therefore, the INT pin must be initialized only if also the callback function parameter `cb` is not `NULL`.

Even if the interrupt pin is not initialized here because the callback function parameter `cb` is NULL, the device interrupts are configured here so that they will work when the interrupt pin is initialized later, as is the case when the Touch Device API is used, for example. Since the interrupt state is cleared on each read, this is not a problem even if the interrupt pin is not used at all.
This commit is contained in:
Gunar Schorcht 2023-08-12 18:09:21 +02:00
parent 91441db357
commit b921bf460b

View File

@ -282,7 +282,9 @@ 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");
if (cb) {
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);