mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
Merge branch 'bugfix/fix_touch_curr_scan_workaround_on_p4_v5.4' into 'release/v5.4'
fix(esp32p4): P4 touch channel 14 failure fix (v5.4) See merge request espressif/esp-idf!42923
This commit is contained in:
@@ -64,6 +64,10 @@ 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);
|
||||||
int ch_offset = touch_ll_get_current_meas_channel() - TOUCH_MIN_CHAN_ID;
|
int ch_offset = touch_ll_get_current_meas_channel() - TOUCH_MIN_CHAN_ID;
|
||||||
|
if (ch_offset < 0 || ch_offset >= (int)SOC_TOUCH_SENSOR_NUM) {
|
||||||
|
/* Not a valid channel */
|
||||||
|
return;
|
||||||
|
}
|
||||||
data.chan = g_touch->ch[ch_offset];
|
data.chan = g_touch->ch[ch_offset];
|
||||||
/* If the channel is not registered, return directly */
|
/* If the channel is not registered, return directly */
|
||||||
if (!data.chan) {
|
if (!data.chan) {
|
||||||
|
|||||||
@@ -196,3 +196,53 @@ TEST_CASE("touch_sens_active_inactive_test", "[touch]")
|
|||||||
TEST_ASSERT_EQUAL_INT32(touch_cnt, cb_data.active_count);
|
TEST_ASSERT_EQUAL_INT32(touch_cnt, cb_data.active_count);
|
||||||
TEST_ASSERT_EQUAL_INT32(touch_cnt, cb_data.inactive_count);
|
TEST_ASSERT_EQUAL_INT32(touch_cnt, cb_data.inactive_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SOC_TOUCH_SENSOR_VERSION > 1
|
||||||
|
TEST_CASE("touch_sens_current_meas_channel_test", "[touch]")
|
||||||
|
{
|
||||||
|
touch_sensor_handle_t touch = NULL;
|
||||||
|
touch_channel_handle_t touch_chan = NULL;
|
||||||
|
|
||||||
|
touch_sensor_config_t sens_cfg = TOUCH_SENSOR_DEFAULT_BASIC_CONFIG(TOUCH_SAMPLE_CFG_NUM, s_sample_cfg);
|
||||||
|
TEST_ESP_OK(touch_sensor_new_controller(&sens_cfg, &touch));
|
||||||
|
|
||||||
|
/* Configuring the filter */
|
||||||
|
touch_sensor_filter_config_t filter_cfg = TOUCH_SENSOR_DEFAULT_FILTER_CONFIG();
|
||||||
|
TEST_ESP_OK(touch_sensor_config_filter(touch, &filter_cfg));
|
||||||
|
|
||||||
|
int err_chan[TOUCH_MAX_CHAN_ID - TOUCH_MIN_CHAN_ID + 1] = {[0 ...(TOUCH_MAX_CHAN_ID - TOUCH_MIN_CHAN_ID)] = -1};
|
||||||
|
int scan_times = 100;
|
||||||
|
uint32_t curr_chan[scan_times];
|
||||||
|
/* Loop all channels */
|
||||||
|
for (int ch_id = TOUCH_MIN_CHAN_ID; ch_id <= TOUCH_MAX_CHAN_ID; ch_id++) {
|
||||||
|
/* New a channel */
|
||||||
|
TEST_ESP_OK(touch_sensor_new_channel(touch, ch_id, &s_chan_cfg, &touch_chan));
|
||||||
|
TEST_ESP_OK(touch_sensor_enable(touch));
|
||||||
|
/* Trigger one-shot scanning to update the current measuring channel */
|
||||||
|
touch_sensor_trigger_oneshot_scanning(touch, 2000);
|
||||||
|
|
||||||
|
/* Read the current measuring channel for several times */
|
||||||
|
for (int i = 0; i < scan_times; i++) {
|
||||||
|
curr_chan[i] = touch_ll_get_current_meas_channel();
|
||||||
|
/* Check if the current measuring channel is the same as the channel id */
|
||||||
|
if (curr_chan[i] != ch_id) {
|
||||||
|
err_chan[ch_id - TOUCH_MIN_CHAN_ID] = curr_chan[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Check if there is any error */
|
||||||
|
TEST_ESP_OK(touch_sensor_disable(touch));
|
||||||
|
TEST_ESP_OK(touch_sensor_del_channel(touch_chan));
|
||||||
|
}
|
||||||
|
TEST_ESP_OK(touch_sensor_del_controller(touch));
|
||||||
|
|
||||||
|
/* Check if there is any error in the current measuring channel from any channel */
|
||||||
|
bool has_error = false;
|
||||||
|
for (int i = 0; i < TOUCH_MAX_CHAN_ID - TOUCH_MIN_CHAN_ID + 1; i++) {
|
||||||
|
if (err_chan[i] >= 0) {
|
||||||
|
ESP_LOGE("TOUCH_TEST", "actual channel is %d, but current measuring channel reads %d", i + TOUCH_MIN_CHAN_ID, err_chan[i]);
|
||||||
|
has_error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TEST_ASSERT_FALSE(has_error);
|
||||||
|
}
|
||||||
|
#endif // SOC_TOUCH_SENSOR_VERSION > 1
|
||||||
|
|||||||
@@ -482,11 +482,7 @@ static inline void touch_ll_set_idle_channel_connect(touch_pad_conn_type_t type)
|
|||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
static inline uint32_t touch_ll_get_current_meas_channel(void)
|
static inline uint32_t touch_ll_get_current_meas_channel(void)
|
||||||
{
|
{
|
||||||
uint32_t curr_chan = LP_TOUCH.chn_status.scan_curr;
|
return LP_TOUCH.chn_status.scan_curr;
|
||||||
HAL_ASSERT(curr_chan < 14);
|
|
||||||
// Workaround: the curr channel read 0 when the actual channel is 14
|
|
||||||
curr_chan = curr_chan == 0 ? 14 : curr_chan;
|
|
||||||
return curr_chan;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user