mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
5cf32002f5
19880: drivers/ft5x06: fix initialization if callback function parameter is NULL r=aabadie a=gschorcht ### Contribution description This PR fixes the `ft5x06` driver initialization if the callback function parameter `cb` is `NULL. This might be the case for example if the application uses the touch device in polling mode. If the interrupt 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`. To be able to test the polling mode, this PR also includes a change of the `tests/drivers/ft5x06` application which introduces the environment variables `FT5X06_POLLING_MODE` `FT5X06_POLLING_PERIOD` and in the makefile. ### Testing procedure 1. Use any board with a FTXXXX touch device and test it in polling mode, for example: ``` FT5X06_POLLING_MODE=1 BOARD=stm32f746g-disco make -C tests/drivers/ft5x06 flash term ``` It should work as expected. ``` main(): This is RIOT! (Version: 2023.10-devel-119-g92a44a-drivers/ft5x06_fix_cb_null) FT5x06 test application +------------Initializing------------+ Initialization successful 1 touch detected Touch 1 - X: 236, Y:111 Touch 1 - X: 236, Y:111 ... Touch 1 - X: 236, Y:111 Released! ``` 2. Checkout master branch and cerry-pick commit 691a5e6308426ddc685e5a2c297238529211c258. The test application `tests/drivers/ft5x06` will crash once a touch event occur: ``` +------------Initializing------------+ Initialization successful 1 touch detected Context before hardfault: ``` ### Issues/PRs references Co-authored-by: Gunar Schorcht <gunar@schorcht.net> |
||
---|---|---|
.. | ||
include | ||
ft5x06_internal.c | ||
ft5x06_touch_dev.c | ||
ft5x06.c | ||
Kconfig | ||
Makefile | ||
Makefile.dep | ||
Makefile.include |