From e51a7a6b6f6f00f1ce0b2ca11ca0e679629522de Mon Sep 17 00:00:00 2001 From: fuzhibo Date: Tue, 22 Dec 2020 21:52:16 +0800 Subject: [PATCH] driver: update touch sensor apis --- .../driver/esp32s2/include/driver/touch_sensor.h | 2 ++ components/driver/esp32s2/touch_sensor.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/components/driver/esp32s2/include/driver/touch_sensor.h b/components/driver/esp32s2/include/driver/touch_sensor.h index 2a34950a47..e2e4a86bdf 100644 --- a/components/driver/esp32s2/include/driver/touch_sensor.h +++ b/components/driver/esp32s2/include/driver/touch_sensor.h @@ -187,6 +187,7 @@ uint32_t touch_pad_read_intr_status_mask(void); /** * @brief Enable touch sensor interrupt by bitmask. + * @note This API can be called in ISR handler. * @param int_mask Pad mask to enable interrupts * @return * - ESP_OK on success @@ -195,6 +196,7 @@ esp_err_t touch_pad_intr_enable(touch_pad_intr_mask_t int_mask); /** * @brief Disable touch sensor interrupt by bitmask. + * @note This API can be called in ISR handler. * @param int_mask Pad mask to disable interrupts * @return * - ESP_OK on success diff --git a/components/driver/esp32s2/touch_sensor.c b/components/driver/esp32s2/touch_sensor.c index 44faa510f6..92d727a566 100644 --- a/components/driver/esp32s2/touch_sensor.c +++ b/components/driver/esp32s2/touch_sensor.c @@ -197,19 +197,23 @@ touch_pad_t IRAM_ATTR touch_pad_get_current_meas_channel(void) esp_err_t touch_pad_intr_enable(touch_pad_intr_mask_t int_mask) { - TOUCH_INTR_MASK_CHECK(int_mask); - TOUCH_ENTER_CRITICAL(); + if (!(int_mask & TOUCH_PAD_INTR_MASK_ALL)) { + return ESP_ERR_INVALID_ARG; + } + TOUCH_ENTER_CRITICAL_SAFE(); touch_hal_intr_enable(int_mask); - TOUCH_EXIT_CRITICAL(); + TOUCH_EXIT_CRITICAL_SAFE(); return ESP_OK; } esp_err_t touch_pad_intr_disable(touch_pad_intr_mask_t int_mask) { - TOUCH_INTR_MASK_CHECK(int_mask); - TOUCH_ENTER_CRITICAL(); + if (!(int_mask & TOUCH_PAD_INTR_MASK_ALL)) { + return ESP_ERR_INVALID_ARG; + } + TOUCH_ENTER_CRITICAL_SAFE(); touch_hal_intr_disable(int_mask); - TOUCH_EXIT_CRITICAL(); + TOUCH_EXIT_CRITICAL_SAFE(); return ESP_OK; }