]> granicus.if.org Git - esp-idf/commitdiff
bugfix(touch): add workaround for touch pad DAC hardware source mismatch on tp8 and...
authorWangjialin <wangjialin@espressif.com>
Tue, 19 Sep 2017 11:40:49 +0000 (19:40 +0800)
committerWangjialin <wangjialin@espressif.com>
Tue, 19 Sep 2017 12:10:39 +0000 (20:10 +0800)
components/driver/include/driver/touch_pad.h
components/driver/rtc_module.c

index ce67a7dc72fe97a62f59571857f3d5ca026e7698..9d14fe4e7121d1dc839b22d11add80333902c82c 100644 (file)
@@ -31,8 +31,8 @@ typedef enum {
     TOUCH_PAD_NUM5,     /*!< Touch pad channel 5 is GPIO12*/
     TOUCH_PAD_NUM6,     /*!< Touch pad channel 6 is GPIO14*/
     TOUCH_PAD_NUM7,     /*!< Touch pad channel 7 is GPIO27*/
-    TOUCH_PAD_NUM8,     /*!< Touch pad channel 8 is GPIO32*/
-    TOUCH_PAD_NUM9,     /*!< Touch pad channel 9 is GPIO33*/
+    TOUCH_PAD_NUM8,     /*!< Touch pad channel 8 is GPIO33*/
+    TOUCH_PAD_NUM9,     /*!< Touch pad channel 9 is GPIO32*/
     TOUCH_PAD_MAX,
 } touch_pad_t;
 
index 0804721e4d95ba933b7ac91c1176d70d07c5c483..95370b1cb99733bf3a88ee76b2dad6e84037c32f 100644 (file)
@@ -510,8 +510,16 @@ esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope,
     portENTER_CRITICAL(&rtc_spinlock);
     //set tie opt value, high or low level seem no difference for counter
     RTCIO.touch_pad[touch_num].tie_opt = opt;
+
+    //workaround for touch pad DAC mismatch on tp8 and tp9
+    touch_pad_t touch_pad_wrap = touch_num;
+    if (touch_num == TOUCH_PAD_NUM9) {
+        touch_pad_wrap = TOUCH_PAD_NUM8;
+    } else if (touch_num == TOUCH_PAD_NUM8) {
+        touch_pad_wrap = TOUCH_PAD_NUM9;
+    }
     //touch sensor set slope for charging and discharging.
-    RTCIO.touch_pad[touch_num].dac = slope;
+    RTCIO.touch_pad[touch_pad_wrap].dac = slope;
     portEXIT_CRITICAL(&rtc_spinlock);
     return ESP_OK;
 }
@@ -521,7 +529,14 @@ esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope
     RTC_MODULE_CHECK((touch_num < TOUCH_PAD_MAX), "touch IO error", ESP_ERR_INVALID_ARG);
     portENTER_CRITICAL(&rtc_spinlock);
     if (slope) {
-        *slope = RTCIO.touch_pad[touch_num].dac;
+        //workaround for touch pad DAC mismatch on tp8 and tp9
+        touch_pad_t touch_pad_wrap = touch_num;
+        if (touch_num == TOUCH_PAD_NUM9) {
+            touch_pad_wrap = TOUCH_PAD_NUM8;
+        } else if (touch_num == TOUCH_PAD_NUM8) {
+            touch_pad_wrap = TOUCH_PAD_NUM9;
+        }
+        *slope = RTCIO.touch_pad[touch_pad_wrap].dac;
     }
     if (opt) {
         *opt = RTCIO.touch_pad[touch_num].tie_opt;