Skip to content

Commit 477ed8c

Browse files
committed
Merge branch 'bugfix/touchpad_dac_mismatch_on_tp8_tp9' into 'master'
bugfix(touch): add workaround for touch pad DAC hardware source mismatch on tp8 and tp9. See merge request !1288
2 parents dbebece + 449f9e1 commit 477ed8c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

components/driver/include/driver/touch_pad.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ typedef enum {
3131
TOUCH_PAD_NUM5, /*!< Touch pad channel 5 is GPIO12*/
3232
TOUCH_PAD_NUM6, /*!< Touch pad channel 6 is GPIO14*/
3333
TOUCH_PAD_NUM7, /*!< Touch pad channel 7 is GPIO27*/
34-
TOUCH_PAD_NUM8, /*!< Touch pad channel 8 is GPIO32*/
35-
TOUCH_PAD_NUM9, /*!< Touch pad channel 9 is GPIO33*/
34+
TOUCH_PAD_NUM8, /*!< Touch pad channel 8 is GPIO33*/
35+
TOUCH_PAD_NUM9, /*!< Touch pad channel 9 is GPIO32*/
3636
TOUCH_PAD_MAX,
3737
} touch_pad_t;
3838

components/driver/rtc_module.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,16 @@ esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope,
510510
portENTER_CRITICAL(&rtc_spinlock);
511511
//set tie opt value, high or low level seem no difference for counter
512512
RTCIO.touch_pad[touch_num].tie_opt = opt;
513+
514+
//workaround for touch pad DAC mismatch on tp8 and tp9
515+
touch_pad_t touch_pad_wrap = touch_num;
516+
if (touch_num == TOUCH_PAD_NUM9) {
517+
touch_pad_wrap = TOUCH_PAD_NUM8;
518+
} else if (touch_num == TOUCH_PAD_NUM8) {
519+
touch_pad_wrap = TOUCH_PAD_NUM9;
520+
}
513521
//touch sensor set slope for charging and discharging.
514-
RTCIO.touch_pad[touch_num].dac = slope;
522+
RTCIO.touch_pad[touch_pad_wrap].dac = slope;
515523
portEXIT_CRITICAL(&rtc_spinlock);
516524
return ESP_OK;
517525
}
@@ -521,7 +529,14 @@ esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope
521529
RTC_MODULE_CHECK((touch_num < TOUCH_PAD_MAX), "touch IO error", ESP_ERR_INVALID_ARG);
522530
portENTER_CRITICAL(&rtc_spinlock);
523531
if (slope) {
524-
*slope = RTCIO.touch_pad[touch_num].dac;
532+
//workaround for touch pad DAC mismatch on tp8 and tp9
533+
touch_pad_t touch_pad_wrap = touch_num;
534+
if (touch_num == TOUCH_PAD_NUM9) {
535+
touch_pad_wrap = TOUCH_PAD_NUM8;
536+
} else if (touch_num == TOUCH_PAD_NUM8) {
537+
touch_pad_wrap = TOUCH_PAD_NUM9;
538+
}
539+
*slope = RTCIO.touch_pad[touch_pad_wrap].dac;
525540
}
526541
if (opt) {
527542
*opt = RTCIO.touch_pad[touch_num].tie_opt;

0 commit comments

Comments
 (0)