mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
fix(touch): fixed channel offset issue in touch v2
This commit is contained in:
@ -30,7 +30,7 @@ extern "C" {
|
|||||||
/* Helper macros */
|
/* Helper macros */
|
||||||
#define TOUCH_NULL_POINTER_CHECK(p) ESP_RETURN_ON_FALSE((p), ESP_ERR_INVALID_ARG, TAG, "input parameter '"#p"' is NULL")
|
#define TOUCH_NULL_POINTER_CHECK(p) ESP_RETURN_ON_FALSE((p), ESP_ERR_INVALID_ARG, TAG, "input parameter '"#p"' is NULL")
|
||||||
#define TOUCH_NULL_POINTER_CHECK_ISR(p) ESP_RETURN_ON_FALSE_ISR((p), ESP_ERR_INVALID_ARG, TAG, "input parameter '"#p"' is NULL")
|
#define TOUCH_NULL_POINTER_CHECK_ISR(p) ESP_RETURN_ON_FALSE_ISR((p), ESP_ERR_INVALID_ARG, TAG, "input parameter '"#p"' is NULL")
|
||||||
#define FOR_EACH_TOUCH_CHANNEL(i) for (int i = 0; i < SOC_TOUCH_SENSOR_NUM; i++)
|
#define FOR_EACH_TOUCH_CHANNEL(i) for (int i = 0; i < TOUCH_TOTAL_CHAN_NUM; i++)
|
||||||
#define TOUCH_IRAM_CHECK(cb) (!(cb) || esp_ptr_in_iram(cb))
|
#define TOUCH_IRAM_CHECK(cb) (!(cb) || esp_ptr_in_iram(cb))
|
||||||
|
|
||||||
/* IRAM safe caps */
|
/* IRAM safe caps */
|
||||||
|
@ -64,9 +64,12 @@ void IRAM_ATTR touch_priv_default_intr_handler(void *arg)
|
|||||||
touch_base_event_data_t data;
|
touch_base_event_data_t data;
|
||||||
touch_ll_get_active_channel_mask(&data.status_mask);
|
touch_ll_get_active_channel_mask(&data.status_mask);
|
||||||
uint32_t curr_chan = touch_ll_get_current_meas_channel();
|
uint32_t curr_chan = touch_ll_get_current_meas_channel();
|
||||||
|
if (curr_chan == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* It actually won't be out of range in the real environment, but limit the range to pass the coverity check */
|
/* It actually won't be out of range in the real environment, but limit the range to pass the coverity check */
|
||||||
curr_chan = curr_chan >= SOC_TOUCH_SENSOR_NUM ? SOC_TOUCH_SENSOR_NUM - 1 : curr_chan;
|
uint32_t curr_chan_offset = (curr_chan >= SOC_TOUCH_SENSOR_NUM ? SOC_TOUCH_SENSOR_NUM - 1 : curr_chan) - TOUCH_MIN_CHAN_ID;
|
||||||
data.chan = g_touch->ch[curr_chan];
|
data.chan = g_touch->ch[curr_chan_offset];
|
||||||
/* If the channel is not registered, return directly */
|
/* If the channel is not registered, return directly */
|
||||||
if (!data.chan) {
|
if (!data.chan) {
|
||||||
return;
|
return;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TOUCH_TOTAL_CHAN_NUM SOC_TOUCH_SENSOR_NUM /*!< The total channel number of the touch sensor */
|
|
||||||
#define TOUCH_SAMPLE_CFG_NUM SOC_TOUCH_SAMPLE_CFG_NUM /*!< The supported max sample configuration number */
|
#define TOUCH_SAMPLE_CFG_NUM SOC_TOUCH_SAMPLE_CFG_NUM /*!< The supported max sample configuration number */
|
||||||
#if SOC_TOUCH_SUPPORT_PROX_SENSING
|
#if SOC_TOUCH_SUPPORT_PROX_SENSING
|
||||||
#define TOUCH_PROXIMITY_CHAN_NUM SOC_TOUCH_PROXIMITY_CHANNEL_NUM /*!< The supported proximity channel number in proximity sensing mode */
|
#define TOUCH_PROXIMITY_CHAN_NUM SOC_TOUCH_PROXIMITY_CHANNEL_NUM /*!< The supported proximity channel number in proximity sensing mode */
|
||||||
@ -24,6 +23,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define TOUCH_MIN_CHAN_ID SOC_TOUCH_MIN_CHAN_ID /*!< The minimum available channel id of the touch pad */
|
#define TOUCH_MIN_CHAN_ID SOC_TOUCH_MIN_CHAN_ID /*!< The minimum available channel id of the touch pad */
|
||||||
#define TOUCH_MAX_CHAN_ID SOC_TOUCH_MAX_CHAN_ID /*!< The maximum available channel id of the touch pad */
|
#define TOUCH_MAX_CHAN_ID SOC_TOUCH_MAX_CHAN_ID /*!< The maximum available channel id of the touch pad */
|
||||||
|
#define TOUCH_TOTAL_CHAN_NUM (TOUCH_MAX_CHAN_ID - TOUCH_MIN_CHAN_ID + 1) /*!< The total channel number of the touch sensor */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The chip sleep level that allows the touch sensor to wake-up
|
* @brief The chip sleep level that allows the touch sensor to wake-up
|
||||||
|
Reference in New Issue
Block a user