summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2021-01-18 11:52:03 -0500
committerDan Halbert <halbert@halwitz.org>2021-01-18 11:52:03 -0500
commitee48e4b4528b7cfea7f568d83eb31c0fde1867d8 (patch)
tree2ce03cba01a37e5fdfb9bdb1f2177af701222601 /ports
parent6a76b60027aa163756aace389a5c9203594759ce (diff)
ESP32-S2: Initialize touch in proper order
Diffstat (limited to 'ports')
-rw-r--r--ports/esp32s2/peripherals/touch.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ports/esp32s2/peripherals/touch.c b/ports/esp32s2/peripherals/touch.c
index 6cf33b2bd..cd895b10b 100644
--- a/ports/esp32s2/peripherals/touch.c
+++ b/ports/esp32s2/peripherals/touch.c
@@ -46,8 +46,13 @@ void peripherals_touch_init(const touch_pad_t touchpad) {
if (!touch_inited) {
touch_pad_init();
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
+ }
+ // touch_pad_config() must be done before touch_pad_fsm_start() the first time.
+ // Otherwise the calibration is wrong and we get maximum raw values if there is
+ // a trace of any significant length on the pin.
+ touch_pad_config(touchpad);
+ if (!touch_inited) {
touch_pad_fsm_start();
touch_inited = true;
}
- touch_pad_config(touchpad);
}