@@ -510,8 +510,16 @@ esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope,
510
510
portENTER_CRITICAL (& rtc_spinlock );
511
511
//set tie opt value, high or low level seem no difference for counter
512
512
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
+ }
513
521
//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 ;
515
523
portEXIT_CRITICAL (& rtc_spinlock );
516
524
return ESP_OK ;
517
525
}
@@ -521,7 +529,14 @@ esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope
521
529
RTC_MODULE_CHECK ((touch_num < TOUCH_PAD_MAX ), "touch IO error" , ESP_ERR_INVALID_ARG );
522
530
portENTER_CRITICAL (& rtc_spinlock );
523
531
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 ;
525
540
}
526
541
if (opt ) {
527
542
* opt = RTCIO .touch_pad [touch_num ].tie_opt ;
0 commit comments