-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RP.PIO.Touch_Sense: Add capacitive charge mode
Anticipating the support of rp2350, this new mode is a workaround for the rp2350 e9 eratum (pin pull-down lock).
- Loading branch information
1 parent
3ff0c10
commit 3321566
Showing
6 changed files
with
124 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-------------------------------------------------------- | ||
-- This file is autogenerated by pioasm; do not edit! -- | ||
-------------------------------------------------------- | ||
|
||
pragma Style_Checks (Off); | ||
|
||
package RP.PIO.Touch_Sense_Charge_PIO | ||
with Preelaborate | ||
is | ||
|
||
------------------------ | ||
-- Touch_Sense_Charge -- | ||
------------------------ | ||
|
||
Touch_Sense_Charge_Wrap_Target : constant := 0; | ||
Touch_Sense_Charge_Wrap : constant := 12; | ||
|
||
Touch_Sense_Charge_Program_Instructions : RP.PIO.Program := ( | ||
-- .wrap_target | ||
16#80a0#, -- 0: pull block | ||
16#e081#, -- 1: set pindirs, 1 | ||
16#e000#, -- 2: set pins, 0 | ||
16#e03e#, -- 3: set x, 30 | ||
16#1f44#, -- 4: jmp x--, 4 [31] | ||
16#a027#, -- 5: mov x, osr | ||
16#e080#, -- 6: set pindirs, 0 | ||
16#0049#, -- 7: jmp x--, 9 | ||
16#000b#, -- 8: jmp 11 | ||
16#00cb#, -- 9: jmp pin, 11 | ||
16#0007#, -- 10: jmp 7 | ||
16#a0c1#, -- 11: mov isr, x | ||
16#8020#); -- 12: push block | ||
-- .wrap | ||
|
||
end RP.PIO.Touch_Sense_Charge_PIO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
; SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries | ||
; SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt | ||
; | ||
; SPDX-License-Identifier: MIT | ||
|
||
|
||
; See rp-pio-touch_sense.ads for more high level explanation of the touch | ||
; sensing process. | ||
|
||
.program touch_sense_charge | ||
|
||
.wrap_target | ||
pull block ; trigger a reading, get maxcount value from fifo, OSR contains maxcount | ||
set pindirs, 1 ; set GPIO as output | ||
set pins, 0 ; drive pin LOW to discharge capacitance | ||
; set x,24 ; wait time for pin discharge | ||
set x,30 ; wait time for pin discharge | ||
discharge: ; wait (24+1)*31 = 1085 cycles = 8.6us | ||
jmp x--, discharge [31] | ||
mov x, osr ; load maxcount value (10_000 usually) | ||
set pindirs, 0 ; set GPIO as input | ||
timing: | ||
jmp x--, test ; decrement x until timeout | ||
jmp done ; we've timed out, so leave | ||
test: | ||
jmp pin, done ; exit when pin is becomes high | ||
jmp timing ; loop otherwise | ||
done: | ||
mov isr, x ; load ISR with count value in x | ||
push ; push ISR into RX fifo | ||
.wrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters