-
Notifications
You must be signed in to change notification settings - Fork 2.1k
drivers/stmpe811: fix initialization if callback function parameter is NULL #19881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@maribu Thank you for reviewing so promptly. While modifying Therefore, I pushed commit 3e35dba with a small additional change. I could squash it with commit 16abf02 if you prefer. |
as you prefer. The ACK remains valid in either case |
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.
To be able to test the STMPE811 device driver in polling mode, variable `STMPE811_POLLING_MODE` is introduced. It is set to 0 by default and can be overriden by 1 to use the polling mode. The polling period can be controlled by the `STMPE811_POLLING_PERIOD` variable.
3e35dba
to
42c73bf
Compare
I decided to squash them because it makes the change more clear if is in one commit instead of two commits. |
bors merge |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
GitHub status checks took too long to complete, so bors is giving up. You can adjust bors configuration to have it wait longer if you like. |
bors merge |
👎 Rejected by PR status |
bors merge |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Thanks for reviewing and mergin. |
19882: tests/drivers/touch_dev: allow to test a touch device in polling mode r=aabadie a=gschorcht ### Contribution description To be able to test the touch device in polling mode, variable `TOUCH_DEV_POLLING` is introduced. It is set to 0 by default and can be overriden by 1 to use the polling mode. The polling period can be controlled by the `TOUCH_DEV_POLLING_PERIOD` variable. To use it for `ft5x06` and `stmpe811` drivers, the polling mode has to be fixed for these touch device drivers (PR #19880 respective PR #19881). ### Testing procedure Use any board with touch device driver that uses the generic touch device API, for example (PR #19881 is required) ``` TOUCH_DEV_POLLING_MODE=1 TOUCH_DEV_POLLING_PERIOD=100 \ BOARD=stm32f429i-disc1 make -C tests/drivers/touch_dev flash term ``` or (PR #19880 is required) ``` TOUCH_DEV_POLLING_MODE=1 TOUCH_DEV_POLLING_PERIOD=100 \ BOARD=stm32f746g-disco make -C tests/drivers/touch_dev flash term ``` ### Issues/PRs references Depends partially on PR #19880 Depends partially on PR #19881 Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Contribution description
This PR fixes the
stmpe811
driver initialization if the callback function parametercb
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
isNULL
, the driver crashes the first time an interrupt is triggered. Therefore, the INT pin must be initialized only if also the callback function parametercb
is notNULL
.To be able to test the polling mode, this PR also includes a change of the
tests/drivers/stmpe811
application which introduces the environment variablesSTMPE811_POLLING_MODE
STMPE811_POLLING_PERIOD
and in the makefile.Testing procedure
Use a
stm32f429i-disc1
board and test it in polling mode:It should work as expected.
Checkout master branch and cerry-pick commit 691a5e6. The test application
tests/drivers/stmpe811
will crash once a touch event occur:Issues/PRs references