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/cst816s: add touch_dev interface + add Kconfig + migrate to ztimer #17459

Merged
merged 5 commits into from
Apr 19, 2022

Conversation

aabadie
Copy link
Contributor

@aabadie aabadie commented Jan 2, 2022

Contribution description

This PR extends the cst816s touch panel driver with the following:

  • adds a touch interface
  • adds the missing Kconfig file
  • migrate it to ztimer
  • pull-in cst816s driver automatically on the pinetime when touch_dev is used

Testing procedure

  • Green CI
  • tests/touch_dev should work on the pinetime (untested)

Issues/PRs references

None

@aabadie aabadie added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Jan 2, 2022
@github-actions github-actions bot added Area: boards Area: Board ports Area: drivers Area: Device drivers Area: Kconfig Area: Kconfig integration Area: sys Area: System labels Jan 2, 2022
@aabadie aabadie force-pushed the pr/drivers/cst816s_enh branch from 01162e1 to a1b0f52 Compare January 2, 2022 07:10
@aabadie aabadie added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 2, 2022
@aabadie aabadie force-pushed the pr/drivers/cst816s_enh branch from a1b0f52 to 5470193 Compare January 2, 2022 07:27
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Jan 2, 2022
@aabadie aabadie force-pushed the pr/drivers/cst816s_enh branch 2 times, most recently from 48cb3e2 to 0f780d6 Compare January 6, 2022 15:15
@aabadie aabadie added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 7, 2022
Copy link
Member

@bergzand bergzand left a comment

Choose a reason for hiding this comment

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

Minor nitpick, untested ack otherwise

drivers/cst816s/Kconfig Outdated Show resolved Hide resolved
@aabadie aabadie force-pushed the pr/drivers/cst816s_enh branch from 0f780d6 to 1dd5561 Compare January 10, 2022 10:59
@fjmolinas
Copy link
Contributor

Minor nitpick, untested ack otherwise

Missing the actual ACk @bergzand :)

@aabadie
Copy link
Contributor Author

aabadie commented Jan 17, 2022

Missing the actual ACk @bergzand :)

I tested it on my pinetime last week, and it doesn't work (failed assertion the nrf i2c driver because the i2c dev index is not < I2C_NUMOF). I couldn't find the actual cause and even after checking the code several times.

@fjmolinas
Copy link
Contributor

Missing the actual ACk @bergzand :)

I tested it on my pinetime last week, and it doesn't work (failed assertion the nrf i2c driver because the i2c dev index is not < I2C_NUMOF). I couldn't find the actual cause and even after checking the code several times.

Can you print the I2C_NUMOFF values that is being tried?

@aabadie
Copy link
Contributor Author

aabadie commented Jan 17, 2022

Can you print the I2C_NUMOFF values that is being tried?

Unfortunately, my pinetime programming wires didn't survive my (little) programming/debugging session.

@aabadie aabadie force-pushed the pr/drivers/cst816s_enh branch from 1dd5561 to 294cfd9 Compare March 25, 2022 14:44
@github-actions github-actions bot removed the Area: tests Area: tests and testing framework label Mar 25, 2022
@aabadie aabadie force-pushed the pr/drivers/cst816s_enh branch 2 times, most recently from 1652bf6 to 881b3c2 Compare March 28, 2022 15:53
@aabadie
Copy link
Contributor Author

aabadie commented Mar 28, 2022

@fjmolinas kindly brought me a couple (2!!!) of programming wires but I didn't succeed in having the touch panel to work. Note that it was not working on master and some old releases.
I'll back with the hardware at the end of the week so will try again. Normally that should work the same, just need to find my setup/workflow mistake. @bergzand any hint ?

@aabadie
Copy link
Contributor Author

aabadie commented Apr 14, 2022

Good news! I was able to test this one and it works like a charm!

tests/driver_cst816s
$ make BOARD=pinetime -C tests/driver_cst816s flash term
make: Entering directory '/work/riot/RIOT/tests/driver_cst816s'
Building application "tests_driver_cst816s" for "pinetime" with MCU "nrf52".

"make" -C /work/riot/RIOT/boards/common/init
"make" -C /work/riot/RIOT/boards/pinetime
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/core/lib
"make" -C /work/riot/RIOT/cpu/nrf52
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/nrf52/periph
"make" -C /work/riot/RIOT/cpu/nrf52/vectors
"make" -C /work/riot/RIOT/cpu/nrf5x_common
"make" -C /work/riot/RIOT/cpu/nrf5x_common/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/cst816s
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/div
"make" -C /work/riot/RIOT/sys/frac
"make" -C /work/riot/RIOT/sys/malloc_thread_safe
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/stdio_rtt
"make" -C /work/riot/RIOT/sys/ztimer
   text	   data	    bss	    dec	    hex	filename
  12048	    232	   3060	  15340	   3bec	/work/riot/RIOT/tests/driver_cst816s/bin/pinetime/tests_driver_cst816s.elf
/work/riot/RIOT/dist/tools/jlink/jlink.sh flash /work/riot/RIOT/tests/driver_cst816s/bin/pinetime/tests_driver_cst816s.bin
### Flashing Target ###
### Flashing at base address 0x0 with offset 0 ###
SEGGER J-Link Commander V6.94b (Compiled Jan 26 2021 18:05:49)
DLL version V6.94b, compiled Jan 26 2021 18:05:34

J-Link Commander will now exit on Error

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link V9 compiled Dec 13 2019 11:14:50
Hardware version: V9.30
S/N: 269307832
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=3.254V
Target connection not established yet but required for command.
Device "NRF52" selected.


Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x2BA01477
DPv0 detected
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x02880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
Halting CPU for downloading file.
Downloading file [/work/riot/RIOT/tests/driver_cst816s/bin/pinetime/tests_driver_cst816s.bin]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (12288 bytes)
J-Link: Flash download: Total: 0.260s (Prepare: 0.026s, Compare: 0.003s, Erase: 0.008s, Program & Verify: 0.216s, Restore: 0.004s)
J-Link: Flash download: Program & Verify speed: 55 KB/s
O.K.

Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.



Script processing completed.

/work/riot/RIOT/dist/tools/jlink/jlink.sh term-rtt 
### Starting RTT terminal ###
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2022-04-14 11:25:58,457 # Host name for TCP connection is missing, defaulting to "localhost"
2022-04-14 11:25:58,458 # Connect to localhost:19021
Welcome to pyterm!
Type '/exit' to exit.
2022-04-14 11:25:59,464 # SEGGER J-Link V6.94b - Real time terminal output
2022-04-14 11:25:59,465 # SEGGER J-Link EDU V9.3, SN=269307832
2022-04-14 11:25:59,465 # Process: JLinkExe
2022-04-14 11:25:59,466 # main(): This is RIOT! (Version: 2022.04-devel-990-g881b3c-pr/drivers/cst816s_enh)
2022-04-14 11:25:59,466 # CST816S test application
2022-04-14 11:25:59,466 # 
2022-04-14 11:26:52,383 # Reading data:
2022-04-14 11:26:52,384 # Touch at 103, 133 with gesture type "single click"
2022-04-14 11:26:52,649 # Reading data:
2022-04-14 11:26:52,650 # Touch at 111, 138 with gesture type "single click"
2022-04-14 11:26:53,026 # Reading data:
2022-04-14 11:26:53,027 # Touch at 096, 143 with gesture type "single click"
2022-04-14 11:26:53,239 # Reading data:
2022-04-14 11:26:53,239 # Touch at 092, 141 with gesture type "single click"
2022-04-14 11:26:53,481 # Reading data:
2022-04-14 11:26:53,482 # Touch at 087, 133 with gesture type "single click"
2022-04-14 11:26:53,920 # Reading data:
2022-04-14 11:26:53,931 # Touch at 083, 121 with gesture type "single click"
2022-04-14 11:26:54,148 # Reading data:
2022-04-14 11:26:54,149 # Touch at 090, 124 with gesture type "single click"
2022-04-14 11:26:56,631 # Exiting Pyterm
tests/touch_dev
$ make BOARD=pinetime -C tests/touch_dev flash term
make: Entering directory '/work/riot/RIOT/tests/touch_dev'
Building application "tests_touch_dev" for "pinetime" with MCU "nrf52".

"make" -C /work/riot/RIOT/boards/common/init
"make" -C /work/riot/RIOT/boards/pinetime
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/core/lib
"make" -C /work/riot/RIOT/cpu/nrf52
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/nrf52/periph
"make" -C /work/riot/RIOT/cpu/nrf52/vectors
"make" -C /work/riot/RIOT/cpu/nrf5x_common
"make" -C /work/riot/RIOT/cpu/nrf5x_common/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/cst816s
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/drivers/touch_dev
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/auto_init/screen
"make" -C /work/riot/RIOT/sys/div
"make" -C /work/riot/RIOT/sys/frac
"make" -C /work/riot/RIOT/sys/malloc_thread_safe
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/stdio_rtt
"make" -C /work/riot/RIOT/sys/ztimer
   text	   data	    bss	    dec	    hex	filename
  12060	    180	   3092	  15332	   3be4	/work/riot/RIOT/tests/touch_dev/bin/pinetime/tests_touch_dev.elf
/work/riot/RIOT/dist/tools/jlink/jlink.sh flash /work/riot/RIOT/tests/touch_dev/bin/pinetime/tests_touch_dev.bin
### Flashing Target ###
### Flashing at base address 0x0 with offset 0 ###
SEGGER J-Link Commander V6.94b (Compiled Jan 26 2021 18:05:49)
DLL version V6.94b, compiled Jan 26 2021 18:05:34

J-Link Commander will now exit on Error

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link V9 compiled Dec 13 2019 11:14:50
Hardware version: V9.30
S/N: 269307832
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=3.256V
Target connection not established yet but required for command.
Device "NRF52" selected.


Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x2BA01477
DPv0 detected
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x02880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
Halting CPU for downloading file.
Downloading file [/work/riot/RIOT/tests/touch_dev/bin/pinetime/tests_touch_dev.bin]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (12288 bytes)
J-Link: Flash download: Total: 0.260s (Prepare: 0.028s, Compare: 0.003s, Erase: 0.007s, Program & Verify: 0.216s, Restore: 0.005s)
J-Link: Flash download: Program & Verify speed: 55 KB/s
O.K.

Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.



Script processing completed.

/work/riot/RIOT/dist/tools/jlink/jlink.sh term-rtt 
### Starting RTT terminal ###
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2022-04-14 11:29:22,709 # Host name for TCP connection is missing, defaulting to "localhost"
2022-04-14 11:29:22,709 # Connect to localhost:19021
Welcome to pyterm!
Type '/exit' to exit.
2022-04-14 11:29:23,715 # SEGGER J-Link V6.94b - Real time terminal output
2022-04-14 11:29:23,716 # SEGGER J-Link EDU V9.3, SN=269307832
2022-04-14 11:29:23,716 # Process: JLinkExe
2022-04-14 11:29:23,717 # main(): This is RIOT! (Version: 2022.04-devel-990-g881b3c-pr/drivers/cst816s_enh)
2022-04-14 11:29:24,999 # pressed!
2022-04-14 11:29:25,000 # X: 90, Y:124
2022-04-14 11:29:25,009 # X: 90, Y:124
2022-04-14 11:29:25,020 # X: 90, Y:124
2022-04-14 11:29:25,030 # X: 182, Y:224
2022-04-14 11:29:25,041 # released!
2022-04-14 11:29:25,417 # pressed!
2022-04-14 11:29:25,418 # X: 149, Y:210
2022-04-14 11:29:25,427 # X: 149, Y:210
2022-04-14 11:29:25,438 # X: 149, Y:210
2022-04-14 11:29:25,438 # X: 149, Y:210
2022-04-14 11:29:25,448 # X: 149, Y:210
2022-04-14 11:29:25,459 # X: 149, Y:210
2022-04-14 11:29:25,469 # X: 149, Y:210
2022-04-14 11:29:25,480 # X: 149, Y:210
2022-04-14 11:29:25,491 # X: 149, Y:210
2022-04-14 11:29:25,501 # X: 149, Y:210
2022-04-14 11:29:25,512 # X: 149, Y:210
2022-04-14 11:29:25,523 # X: 149, Y:210
2022-04-14 11:29:25,534 # X: 149, Y:210
2022-04-14 11:29:25,544 # X: 149, Y:210
2022-04-14 11:29:25,555 # X: 149, Y:210
2022-04-14 11:29:25,566 # X: 149, Y:210
2022-04-14 11:29:25,576 # X: 149, Y:210
2022-04-14 11:29:25,587 # X: 82, Y:222
2022-04-14 11:29:25,598 # released!
2022-04-14 11:29:25,793 # pressed!
2022-04-14 11:29:25,794 # X: 85, Y:210
2022-04-14 11:29:25,803 # X: 85, Y:210
2022-04-14 11:29:25,813 # X: 85, Y:210
2022-04-14 11:29:25,823 # X: 85, Y:210
2022-04-14 11:29:25,834 # X: 85, Y:210
2022-04-14 11:29:25,844 # X: 85, Y:210
2022-04-14 11:29:25,854 # X: 85, Y:210
2022-04-14 11:29:25,865 # X: 85, Y:210
2022-04-14 11:29:25,876 # X: 85, Y:210
2022-04-14 11:29:25,886 # X: 85, Y:210
2022-04-14 11:29:25,897 # X: 85, Y:210
2022-04-14 11:29:25,908 # X: 85, Y:210
2022-04-14 11:29:25,919 # X: 85, Y:210
2022-04-14 11:29:25,929 # X: 85, Y:210
2022-04-14 11:29:25,939 # X: 85, Y:210
2022-04-14 11:29:25,950 # X: 85, Y:210
2022-04-14 11:29:25,961 # X: 85, Y:210
2022-04-14 11:29:25,971 # X: 85, Y:210
2022-04-14 11:29:25,982 # X: 85, Y:210
2022-04-14 11:29:25,993 # X: 56, Y:205
2022-04-14 11:29:26,003 # released!
2022-04-14 11:29:26,135 # pressed!
2022-04-14 11:29:26,135 # X: 56, Y:205
2022-04-14 11:29:26,145 # X: 56, Y:205
2022-04-14 11:29:26,156 # X: 56, Y:205
2022-04-14 11:29:26,166 # X: 56, Y:205
2022-04-14 11:29:26,176 # X: 56, Y:205
2022-04-14 11:29:26,186 # X: 0, Y:0
2022-04-14 11:29:26,197 # X: 56, Y:205
2022-04-14 11:29:26,208 # X: 56, Y:205
2022-04-14 11:29:26,218 # X: 56, Y:205
2022-04-14 11:29:26,229 # X: 56, Y:205
2022-04-14 11:29:26,240 # X: 56, Y:205
2022-04-14 11:29:26,250 # X: 56, Y:205
2022-04-14 11:29:26,261 # X: 56, Y:205
2022-04-14 11:29:26,272 # X: 56, Y:205
2022-04-14 11:29:26,292 # X: 56, Y:205
2022-04-14 11:29:26,303 # X: 74, Y:197
2022-04-14 11:29:26,303 # released!

This is good to go I think :)

@aabadie aabadie force-pushed the pr/drivers/cst816s_enh branch from 881b3c2 to dbc59aa Compare April 14, 2022 09:31
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Code looks good!

@aabadie aabadie merged commit 718b1e3 into RIOT-OS:master Apr 19, 2022
@aabadie aabadie deleted the pr/drivers/cst816s_enh branch April 19, 2022 09:43
@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
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: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants