Skip to content

Commit afda4c1

Browse files
committed
Merge branch 'feature/support_p4_ulp_touch_driver' into 'master'
feat(ulp_touch): support ulp touch driver on p4 Closes IDF-12546 See merge request espressif/esp-idf!37362
2 parents 71e4d9e + c9cc7bb commit afda4c1

File tree

28 files changed

+725
-24
lines changed

28 files changed

+725
-24
lines changed

components/esp_driver_touch_sens/common/touch_sens_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "esp_check.h"
3333
#include "touch_sens_private.h"
3434

35-
#define TOUCH_CHANNEL_CHECK(num) ESP_RETURN_ON_FALSE(num >= TOUCH_MIN_CHAN_ID && num <= TOUCH_MAX_CHAN_ID, \
35+
#define TOUCH_CHANNEL_CHECK(num) ESP_RETURN_ON_FALSE((int)(num) >= (int)TOUCH_MIN_CHAN_ID && num <= TOUCH_MAX_CHAN_ID, \
3636
ESP_ERR_INVALID_ARG, TAG, "The channel number is out of supported range");
3737

3838
static const char *TAG = "touch";

components/esp_driver_touch_sens/hw_ver1/include/driver/touch_version_types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
extern "C" {
2020
#endif
2121

22-
#define TOUCH_MIN_CHAN_ID 0 /*!< The minimum available channel id of the touch pad */
23-
#define TOUCH_MAX_CHAN_ID 9 /*!< The maximum available channel id of the touch pad */
24-
2522
/**
2623
* @brief Helper macro to the default configurations of the touch sensor controller
2724
*

components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
extern "C" {
2020
#endif
2121

22-
#define TOUCH_MIN_CHAN_ID 1 /*!< The minimum available channel id of the touch pad */
23-
#define TOUCH_MAX_CHAN_ID 14 /*!< The maximum available channel id of the touch pad */
24-
2522
#define TOUCH_SHIELD_CHAN_ID 14 /*!< The touch channel that can be used as the shield channel */
2623

2724
/**

components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
extern "C" {
2020
#endif
2121

22-
#define TOUCH_MIN_CHAN_ID 0 /*!< The minimum available channel id of the touch pad */
23-
#define TOUCH_MAX_CHAN_ID 13 /*!< The maximum available channel id of the touch pad */
24-
2522
/**
2623
* @brief Helper macro to the default configurations of the touch sensor controller
2724
*

components/esp_driver_touch_sens/include/driver/touch_sens_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ extern "C" {
2222
#define TOUCH_PROXIMITY_CHAN_NUM SOC_TOUCH_PROXIMITY_CHANNEL_NUM /*!< The supported proximity channel number in proximity sensing mode */
2323
#endif
2424

25+
#define TOUCH_MIN_CHAN_ID SOC_TOUCH_MIN_CHAN_ID /*!< The minimum available channel id of the touch pad */
26+
#define TOUCH_MAX_CHAN_ID SOC_TOUCH_MAX_CHAN_ID /*!< The maximum available channel id of the touch pad */
27+
2528
/**
2629
* @brief The chip sleep level that allows the touch sensor to wake-up
2730
*

components/hal/esp32p4/include/hal/touch_sensor_ll.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,18 @@ static inline void touch_ll_sample_cfg_set_engaged_num(uint8_t sample_cfg_num)
584584
LP_ANA_PERI.touch_scan_ctrl2.freq_scan_cnt_limit = sample_cfg_num ? sample_cfg_num : 1;
585585
}
586586

587+
/**
588+
* Get the engaged sample configuration number
589+
*
590+
* @return The engaged sample configuration number, range 0~3.
591+
*/
592+
static inline uint32_t touch_ll_sample_cfg_get_engaged_num(void)
593+
{
594+
uint32_t sample_cfg_num = LP_ANA_PERI.touch_scan_ctrl2.freq_scan_cnt_limit;
595+
return sample_cfg_num ? sample_cfg_num : 1;
596+
}
597+
598+
587599
/**
588600
* Set capacitance and resistance of the RC filter of the sampling frequency.
589601
*

components/hal/esp32s2/include/hal/touch_sensor_ll.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,29 @@ static inline void touch_ll_sleep_read_data(uint32_t *raw_data)
16821682
*raw_data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
16831683
}
16841684

1685+
/**
1686+
* Get the data of the touch channel according to the types
1687+
*
1688+
* @param sample_cfg_id The sample configuration index
1689+
* @param type data type
1690+
* 0/1: TOUCH_LL_READ_RAW, the raw data of the touch channel
1691+
* 2: TOUCH_LL_READ_BENCHMARK, benchmark value of touch channel,
1692+
* the benchmark value is the maximum during the first measurement period
1693+
* 3: TOUCH_LL_READ_SMOOTH, the smoothed data that obtained by filtering the raw data.
1694+
* @param smooth_data pointer to smoothed data
1695+
*/
1696+
__attribute__((always_inline))
1697+
static inline void touch_ll_sleep_read_chan_data(uint8_t type, uint32_t *data)
1698+
{
1699+
SENS.sar_touch_conf.touch_data_sel = type;
1700+
if (type == TOUCH_LL_READ_RAW) {
1701+
uint32_t touch_num = RTCCNTL.touch_slp_thres.touch_slp_pad;
1702+
*data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
1703+
} else {
1704+
*data = SENS.sar_touch_slp_status.touch_slp_data;
1705+
}
1706+
}
1707+
16851708
/**
16861709
* Select touch sensor dbias to save power in sleep mode.
16871710
*

components/hal/esp32s3/include/hal/touch_sensor_ll.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,29 @@ static inline void touch_ll_sleep_read_data(uint32_t *raw_data)
17181718
*raw_data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
17191719
}
17201720

1721+
/**
1722+
* Get the data of the touch channel according to the types
1723+
*
1724+
* @param sample_cfg_id The sample configuration index
1725+
* @param type data type
1726+
* 0/1: TOUCH_LL_READ_RAW, the raw data of the touch channel
1727+
* 2: TOUCH_LL_READ_BENCHMARK, benchmark value of touch channel,
1728+
* the benchmark value is the maximum during the first measurement period
1729+
* 3: TOUCH_LL_READ_SMOOTH, the smoothed data that obtained by filtering the raw data.
1730+
* @param smooth_data pointer to smoothed data
1731+
*/
1732+
__attribute__((always_inline))
1733+
static inline void touch_ll_sleep_read_chan_data(uint8_t type, uint32_t *data)
1734+
{
1735+
SENS.sar_touch_conf.touch_data_sel = type;
1736+
if (type == TOUCH_LL_READ_RAW) {
1737+
uint32_t touch_num = RTCCNTL.touch_slp_thres.touch_slp_pad;
1738+
*data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
1739+
} else {
1740+
*data = SENS.sar_touch_slp_status.touch_slp_data;
1741+
}
1742+
}
1743+
17211744

17221745
/**
17231746
* Select touch sensor dbias to save power in sleep mode.

components/soc/esp32/include/soc/Kconfig.soc_caps.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,14 @@ config SOC_TOUCH_SENSOR_NUM
735735
int
736736
default 10
737737

738+
config SOC_TOUCH_MIN_CHAN_ID
739+
int
740+
default 0
741+
742+
config SOC_TOUCH_MAX_CHAN_ID
743+
int
744+
default 9
745+
738746
config SOC_TOUCH_SUPPORT_SLEEP_WAKEUP
739747
bool
740748
default y

components/soc/esp32/include/soc/soc_caps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@
336336
/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
337337
#define SOC_TOUCH_SENSOR_VERSION (1U) /*!<Hardware version of touch sensor */
338338
#define SOC_TOUCH_SENSOR_NUM (10)
339+
#define SOC_TOUCH_MIN_CHAN_ID (0U) /*!< Touch minimum channel number */
340+
#define SOC_TOUCH_MAX_CHAN_ID (9) /*!< Touch maximum channel number */
339341
#define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1)
340342
#define SOC_TOUCH_SAMPLE_CFG_NUM (1U) /*!< The sample configuration number in total, each sampler can be used to sample on one frequency */
341343

0 commit comments

Comments
 (0)