Skip to content
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

drivers/stmpe811: add spi mode #17088

Merged
merged 2 commits into from Dec 3, 2021
Merged

Conversation

fjmolinas
Copy link
Contributor

Contribution description

This PR adds the spi version for the stmpe811. It also changes to use error codes following driver guidelines.

Testing procedure

Tested on Adafruit tft touch screen feather wing with the IRQ pin soldered in. https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing, but this is not really needed for lvgl since the position is periodically queried.

DRIVER=stmpe811_spi make -C tests/pkg_lvgl_touch flash term

main(): This is RIOT! (Version: 2021.10-devel-619-gff404-pr_stmpe811_spi)
Button clicked!
Button clicked!
Button clicked!
Button clicked!

Test as well the i2c version.

@github-actions github-actions bot added Area: boards Area: Board ports Area: drivers Area: Device drivers Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework labels Oct 30, 2021
* @return 0 on success
* @return -ENODEV when no valid device
* @return -EIO when software reset failed
* @return -EPROTO on any I2C error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change I2C to bus since now it can be either i2c or spi

* @return STMPE811_OK on success
* @return -STMPE811_ERR_I2C on any I2C error
* @return 0 on success
* @return -EPROTO on any I2C error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change I2C to bus since now it can be either i2c or spi

* @return STMPE811_OK on success
* @return -STMPE811_ERR_I2C on any I2C error
* @return 0 on success
* @return -EPROTO on any I2C error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change I2C to bus since now it can be either i2c or spi

@fjmolinas
Copy link
Contributor Author

May I squash? Does the i2c version still work for you @aabadie?

@fjmolinas
Copy link
Contributor Author

Ping @aabadie!

@aabadie
Copy link
Contributor

aabadie commented Nov 8, 2021

Does the i2c version still work for you @aabadie?

I won't be able to test before next week unfortunately.

@fjmolinas
Copy link
Contributor Author

Just a remainder for you to test this one @aabadie :)

@fjmolinas fjmolinas added this to the Release 2022.01 milestone Nov 18, 2021
@fjmolinas
Copy link
Contributor Author

Just a remainder for you to test this one @aabadie :)

For some reason I have two devices that start with a different SPI_MODE, so I added a check to test them both on init. @aabadie any chance you can test?

@aabadie
Copy link
Contributor

aabadie commented Dec 2, 2021

any chance you can test?

will do tomorrow. There's a typo reported by codespell.

@aabadie
Copy link
Contributor

aabadie commented Dec 3, 2021

The I2C version is still working:

$ BUILD_IN_DOCKER=1 make -C tests/driver_stmpe811/ flash term --no-print-directory
Launching build container using image "riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/Europe/Paris:/etc/localtime:ro' -v '/work/riot/RIOT:/data/riotbuild/riotbase:delegated' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'        -w '/data/riotbuild/riotbase/tests/driver_stmpe811/' 'riot/riotbuild:latest' make     
Building application "tests_driver_stmpe811" for "stm32f429i-disc1" with MCU "stm32".

[INFO] cloning stm32cmsis
Cloning into '/data/riotbuild/riotbase/cpu/stm32/include/vendor/cmsis/f4'...
remote: Enumerating objects: 319, done.
remote: Counting objects: 100% (319/319), done.
remote: Compressing objects: 100% (67/67), done.
remote: Total 319 (delta 264), reused 302 (delta 247), pack-reused 0
Receiving objects: 100% (319/319), 810.54 KiB | 5.26 MiB/s, done.
Resolving deltas: 100% (264/264), done.
HEAD is now at 4cf5053 Release v2.6.4
[INFO] updating stm32cmsis /data/riotbuild/riotbase/cpu/stm32/include/vendor/cmsis/f4/.pkg-state.git-downloaded
echo 4cf505380bf123941fd485b1ae01c0747dca3792   > /data/riotbuild/riotbase/cpu/stm32/include/vendor/cmsis/f4/.pkg-state.git-downloaded
[INFO] patch stm32cmsis
"make" -C /data/riotbuild/riotbase/boards/stm32f429i-disc1
"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/cpu/stm32
"make" -C /data/riotbuild/riotbase/cpu/cortexm_common
"make" -C /data/riotbuild/riotbase/cpu/cortexm_common/periph
"make" -C /data/riotbuild/riotbase/cpu/stm32/periph
"make" -C /data/riotbuild/riotbase/cpu/stm32/stmclk
"make" -C /data/riotbuild/riotbase/cpu/stm32/vectors
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/drivers/stmpe811
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/div
"make" -C /data/riotbuild/riotbase/sys/malloc_thread_safe
"make" -C /data/riotbuild/riotbase/sys/newlib_syscalls_default
"make" -C /data/riotbuild/riotbase/sys/pm_layered
"make" -C /data/riotbuild/riotbase/sys/stdio_uart
"make" -C /data/riotbuild/riotbase/sys/xtimer
   text	   data	    bss	    dec	    hex	filename
  13236	    112	   2460	  15808	   3dc0	/data/riotbuild/riotbase/tests/driver_stmpe811/bin/stm32f429i-disc1/tests_driver_stmpe811.elf
/work/riot/RIOT/dist/tools/openocd/openocd.sh flash /work/riot/RIOT/tests/driver_stmpe811/bin/stm32f429i-disc1/tests_driver_stmpe811.elf
### Flashing Target ###
Open On-Chip Debugger 0.11.0 (2021-11-22-14:28)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 2000 kHz
Info : STLINK V2J25M14 (API v2) VID:PID 0483:374B
Info : Target voltage: 2.850698
Warn : target stm32f4x.cpu examination failed
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 300ms
Info : starting gdb server for stm32f4x.cpu on 0
Info : Listening on port 45397 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f4x.cpu       hla_target little stm32f4x.cpu       unknown

Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Error: mem2array: Read @ 0xe0042004, w=4, cnt=1, failed
Error executing event examine-end on target stm32f4x.cpu:
/usr/local/bin/../share/openocd/scripts/mem_helper.tcl:6: Error: 
in procedure 'ocd_process_reset' 
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 288
in procedure 'mmw' called at file "/usr/local/bin/../share/openocd/scripts/target/stm32f4x.cfg", line 85
in procedure 'mrw' called at file "/usr/local/bin/../share/openocd/scripts/mem_helper.tcl", line 36
at file "/usr/local/bin/../share/openocd/scripts/mem_helper.tcl", line 6
Info : Previous state query failed, trying to reconnect
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080008e4 msp: 0x20000200
Polling target stm32f4x.cpu failed, trying to reexamine
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : device id = 0x20016419
Info : flash size = 2048 kbytes
Info : Dual Bank 2048 kiB STM32F42x/43x/469/479 found
auto erase enabled
wrote 16384 bytes from file /work/riot/RIOT/tests/driver_stmpe811/bin/stm32f429i-disc1/tests_driver_stmpe811.elf in 0.691579s (23.135 KiB/s)

verified 13348 bytes in 0.138113s (94.380 KiB/s)

Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
shutdown command invoked
Done flashing
/work/riot/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200"  
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2021-12-03 10:37:24,902 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2021-12-03 10:37:38,606 # Pressed!
2021-12-03 10:37:38,612 # X: 95, Y:180
2021-12-03 10:37:38,725 # Released!
2021-12-03 10:37:39,206 # Pressed!
2021-12-03 10:37:39,212 # X: 84, Y:167
2021-12-03 10:37:39,338 # Released!
2021-12-03 10:37:39,614 # Pressed!
2021-12-03 10:37:39,632 # X: 73, Y:146
2021-12-03 10:37:39,638 # X: 74, Y:147
2021-12-03 10:37:39,794 # Released!
2021-12-03 10:37:40,046 # Pressed!
2021-12-03 10:37:40,046 # X: 75, Y:242
2021-12-03 10:37:40,178 # Released!
2021-12-03 10:37:40,370 # Pressed!
2021-12-03 10:37:40,376 # X: 42, Y:105
2021-12-03 10:37:40,382 # Released!
2021-12-03 10:37:40,382 # Pressed!
2021-12-03 10:37:40,388 # X: 45, Y:103
2021-12-03 10:37:40,508 # Released!
2021-12-03 10:37:40,682 # Pressed!
2021-12-03 10:37:40,683 # X: 43, Y:124
2021-12-03 10:37:40,687 # Released!
2021-12-03 10:37:40,694 # Pressed!
2021-12-03 10:37:40,700 # X: 47, Y:120
2021-12-03 10:37:40,790 # Released!
2021-12-03 10:37:40,940 # Pressed!
2021-12-03 10:37:40,946 # X: 69, Y:216
2021-12-03 10:37:40,951 # Released!
2021-12-03 10:37:40,952 # Pressed!
2021-12-03 10:37:40,958 # X: 73, Y:218
2021-12-03 10:37:41,036 # Released!
2021-12-03 10:37:41,216 # Pressed!
2021-12-03 10:37:41,222 # X: 42, Y:150
2021-12-03 10:37:41,223 # Released!
2021-12-03 10:37:41,228 # Pressed!
2021-12-03 10:37:41,228 # X: 49, Y:146
2021-12-03 10:37:41,294 # Released!
2021-12-03 10:37:42,272 # Exiting Pyterm

drivers/stmpe811/stmpe811.c Outdated Show resolved Hide resolved
@fjmolinas fjmolinas added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 3, 2021
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@aabadie
Copy link
Contributor

aabadie commented Dec 3, 2021

Hmm, Murdock spotted an issue, you can squash the fix right away.

@aabadie aabadie merged commit 8329112 into RIOT-OS:master Dec 3, 2021
@fjmolinas fjmolinas deleted the pr_stmpe811_spi branch December 6, 2021 08:07
@fjmolinas
Copy link
Contributor Author

Thanks @aabadie!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: drivers Area: Device drivers Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants