1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/touch_dev: extend API to set event callback function

This commit is contained in:
Alexandre Abadie 2020-07-20 16:37:51 +02:00
parent 84c83b8025
commit 528d884b5d
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 31 additions and 0 deletions

View File

@ -41,6 +41,13 @@ typedef struct {
uint16_t y; /**< Y coordinate */
} touch_t;
/**
* @brief Signature of touch event callback triggered from interrupt
*
* @param[in] arg optional context for the callback
*/
typedef void (*touch_event_cb_t)(void *arg);
/**
* @brief Generic type for a touch driver
*/
@ -75,6 +82,15 @@ typedef struct {
* @return number of touch positions, 0 means no touch
*/
uint8_t (*touches)(const touch_dev_t *dev, touch_t *touches, size_t len);
/**
* @brief Set and configure the touch event callback
*
* @param[in] dev Pointer to the touch device
* @param[in] cb The callback function
* @param[in] arg Context argument
*/
void (*set_event_callback)(const touch_dev_t *dev, touch_event_cb_t cb, void *arg);
} touch_dev_driver_t;
/**
@ -150,6 +166,15 @@ uint16_t touch_dev_width(const touch_dev_t *dev);
*/
uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len);
/**
* @brief Set and configure the touch event callback
*
* @param[in] dev Pointer to the touch device
* @param[in] cb The callback function
* @param[in] arg Context argument
*/
void touch_dev_set_touch_event_callback(const touch_dev_t *dev, touch_event_cb_t cb, void *arg);
#ifdef __cplusplus
}
#endif

View File

@ -82,3 +82,9 @@ uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len)
return dev->driver->touches(dev, touches, len);
}
void touch_dev_set_touch_event_callback(const touch_dev_t *dev, touch_event_cb_t cb, void *arg)
{
assert(dev);
dev->driver->set_event_callback(dev, cb, arg);
}