Skip to content

Commit

Permalink
soc: added SOC_TOUCH_SENSE_SUPPORTED macro
Browse files Browse the repository at this point in the history
  • Loading branch information
suda-morris committed Jul 22, 2022
1 parent 5dbae0c commit 741b031
Show file tree
Hide file tree
Showing 28 changed files with 61 additions and 99 deletions.
14 changes: 4 additions & 10 deletions components/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,22 @@ if(CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2)
list(APPEND srcs "spi_slave_hd.c")
endif()

if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
list(APPEND srcs "touch_sensor_common.c" "${target}/touch_sensor.c")
endif()

if(${target} STREQUAL "esp32")
list(APPEND srcs "dac_common.c"
"sdio_slave.c"
"touch_sensor_common.c"
"esp32/touch_sensor.c"
"deprecated/adc_i2s_deprecated.c"
"esp32/dac.c")
endif()

if(${target} STREQUAL "esp32s2")
list(APPEND srcs "dac_common.c"
"touch_sensor_common.c"
"esp32s2/touch_sensor.c"
"esp32s2/dac.c")
endif()

if(${target} STREQUAL "esp32s3")
list(APPEND srcs "touch_sensor_common.c"
"esp32s3/touch_sensor.c")
endif()


if(BOOTLOADER_BUILD)
# Bootloader shall NOT depend on the drivers
idf_component_register()
Expand Down
4 changes: 4 additions & 0 deletions components/driver/include/driver/touch_pad.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@

#pragma once

#include "soc/soc_caps.h"

#if SOC_TOUCH_SENSOR_SUPPORTED
#include "driver/touch_sensor.h"
#endif
8 changes: 3 additions & 5 deletions components/esp_hw_support/include/esp_sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ esp_err_t esp_sleep_enable_ulp_wakeup(void);
*/
esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us);

#if SOC_TOUCH_SENSOR_NUM > 0

#if SOC_TOUCH_SENSOR_SUPPORTED
/**
* @brief Enable wakeup by touch sensor
*
Expand All @@ -157,8 +156,7 @@ esp_err_t esp_sleep_enable_touchpad_wakeup(void);
* @return touch pad which caused wakeup
*/
touch_pad_t esp_sleep_get_touchpad_wakeup_status(void);

#endif // SOC_TOUCH_SENSOR_NUM > 0
#endif // SOC_TOUCH_SENSOR_SUPPORTED

/**
* @brief Returns true if a GPIO number is valid for use as wakeup source.
Expand Down Expand Up @@ -360,7 +358,7 @@ uint64_t esp_sleep_get_gpio_wakeup_status(void);
* - ESP_ERR_INVALID_ARG if either of the arguments is out of range
*/
esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain,
esp_sleep_pd_option_t option);
esp_sleep_pd_option_t option);

/**
* @brief Enter deep sleep with the configured wakeup options
Expand Down
6 changes: 3 additions & 3 deletions components/esp_hw_support/sleep_modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "hal/wdt_hal.h"
#include "hal/rtc_hal.h"
#include "hal/uart_hal.h"
#if SOC_TOUCH_SENSOR_NUM > 0
#if SOC_TOUCH_SENSOR_SUPPORTED
#include "hal/touch_sensor_hal.h"
#include "driver/touch_sensor.h"
#include "driver/touch_sensor_common.h"
Expand Down Expand Up @@ -899,7 +899,7 @@ static void touch_wakeup_prepare(void)
}
#endif

#if SOC_TOUCH_SENSOR_NUM > 0
#if SOC_TOUCH_SENSOR_SUPPORTED

esp_err_t esp_sleep_enable_touchpad_wakeup(void)
{
Expand All @@ -926,7 +926,7 @@ touch_pad_t esp_sleep_get_touchpad_wakeup_status(void)
return (ret == ESP_OK) ? pad_num : TOUCH_PAD_MAX;
}

#endif // SOC_TOUCH_SENSOR_NUM > 0
#endif // SOC_TOUCH_SENSOR_SUPPORTED

bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num)
{
Expand Down
4 changes: 4 additions & 0 deletions components/soc/esp32/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ config SOC_SECURE_BOOT_SUPPORTED
bool
default y

config SOC_TOUCH_SENSOR_SUPPORTED
bool
default y

config SOC_DPORT_WORKAROUND_DIS_INTERRUPT_LVL
int
default 5
Expand Down
1 change: 1 addition & 0 deletions components/soc/esp32/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#define SOC_SHA_SUPPORTED 1
#define SOC_FLASH_ENC_SUPPORTED 1
#define SOC_SECURE_BOOT_SUPPORTED 1
#define SOC_TOUCH_SENSOR_SUPPORTED 1

#if SOC_CAPS_ECO_VER < 2
#define SOC_DPORT_WORKAROUND 1
Expand Down
20 changes: 6 additions & 14 deletions components/soc/esp32/touch_sensor_periph.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "soc/touch_sensor_periph.h"

/* Store IO number corresponding to the Touch Sensor channel number. */
const int touch_sensor_channel_io_map[SOC_TOUCH_SENSOR_NUM] = {
const int touch_sensor_channel_io_map[] = {
TOUCH_PAD_NUM0_GPIO_NUM,
TOUCH_PAD_NUM1_GPIO_NUM,
TOUCH_PAD_NUM2_GPIO_NUM,
Expand Down
4 changes: 0 additions & 4 deletions components/soc/esp32c2/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,6 @@ config SOC_TIMER_GROUP_TOTAL_TIMERS
int
default 1

config SOC_TOUCH_SENSOR_NUM
int
default 0

config SOC_SECURE_BOOT_V2_ECC
bool
default y
Expand Down
3 changes: 0 additions & 3 deletions components/soc/esp32c2/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@
#define SOC_TIMER_GROUP_SUPPORT_PLL_F40M (1)
#define SOC_TIMER_GROUP_TOTAL_TIMERS (1U)

/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
#define SOC_TOUCH_SENSOR_NUM (0U) /*! No touch sensors on ESP32-C2 */

/*-------------------------- Secure Boot CAPS----------------------------*/
#define SOC_SECURE_BOOT_V2_ECC 1
#define SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS (1U)
Expand Down
4 changes: 0 additions & 4 deletions components/soc/esp32c3/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,6 @@ config SOC_TIMER_GROUP_TOTAL_TIMERS
int
default 2

config SOC_TOUCH_SENSOR_NUM
bool
default n

config SOC_TWAI_BRP_MIN
int
default 2
Expand Down
3 changes: 0 additions & 3 deletions components/soc/esp32c3/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@
#define SOC_TIMER_GROUP_SUPPORT_APB (1)
#define SOC_TIMER_GROUP_TOTAL_TIMERS (2)

/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
#define SOC_TOUCH_SENSOR_NUM (0) /*! No touch sensors on ESP32-C3 */

/*-------------------------- TWAI CAPS ---------------------------------------*/
#define SOC_TWAI_BRP_MIN 2
#define SOC_TWAI_BRP_MAX 16384
Expand Down
4 changes: 0 additions & 4 deletions components/soc/esp32h2/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,6 @@ config SOC_TIMER_GROUP_TOTAL_TIMERS
int
default 2

config SOC_TOUCH_SENSOR_NUM
bool
default n

config SOC_TWAI_BRP_MIN
int
default 2
Expand Down
3 changes: 0 additions & 3 deletions components/soc/esp32h2/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@
#define SOC_TIMER_GROUP_SUPPORT_AHB (1)
#define SOC_TIMER_GROUP_TOTAL_TIMERS (2)

/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
#define SOC_TOUCH_SENSOR_NUM (0) /*! No touch sensors on ESP32-H2 */

/*-------------------------- TWAI CAPS ---------------------------------------*/
#define SOC_TWAI_BRP_MIN 2
#define SOC_TWAI_BRP_MAX 16384
Expand Down
4 changes: 4 additions & 0 deletions components/soc/esp32s2/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ config SOC_MEMPROT_SUPPORTED
bool
default y

config SOC_TOUCH_SENSOR_SUPPORTED
bool
default y

config SOC_ADC_RTC_CTRL_SUPPORTED
bool
default y
Expand Down
1 change: 1 addition & 0 deletions components/soc/esp32s2/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#define SOC_FLASH_ENC_SUPPORTED 1
#define SOC_SECURE_BOOT_SUPPORTED 1
#define SOC_MEMPROT_SUPPORTED 1
#define SOC_TOUCH_SENSOR_SUPPORTED 1


/*-------------------------- ADC CAPS ----------------------------------------*/
Expand Down
20 changes: 6 additions & 14 deletions components/soc/esp32s2/touch_sensor_periph.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "soc/touch_sensor_periph.h"

/* Store IO number corresponding to the Touch Sensor channel number. */
/* Note: T0 is an internal channel that does not have a corresponding external GPIO. */
const int touch_sensor_channel_io_map[SOC_TOUCH_SENSOR_NUM] = {
const int touch_sensor_channel_io_map[] = {
-1,
TOUCH_PAD_NUM1_GPIO_NUM,
TOUCH_PAD_NUM2_GPIO_NUM,
Expand Down
4 changes: 4 additions & 0 deletions components/soc/esp32s3/include/soc/Kconfig.soc_caps.in
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ config SOC_MEMPROT_SUPPORTED
bool
default y

config SOC_TOUCH_SENSOR_SUPPORTED
bool
default y

config SOC_APPCPU_HAS_CLOCK_GATING_BUG
bool
default y
Expand Down
2 changes: 1 addition & 1 deletion components/soc/esp32s3/include/soc/soc_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define SOC_FLASH_ENC_SUPPORTED 1
#define SOC_SECURE_BOOT_SUPPORTED 1
#define SOC_MEMPROT_SUPPORTED 1

#define SOC_TOUCH_SENSOR_SUPPORTED 1

/*-------------------------- SOC CAPS ----------------------------------------*/
#define SOC_APPCPU_HAS_CLOCK_GATING_BUG (1)
Expand Down
2 changes: 1 addition & 1 deletion components/soc/esp32s3/touch_sensor_periph.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Store IO number corresponding to the Touch Sensor channel number. */
/* Note: T0 is an internal channel that does not have a corresponding external GPIO. */
const int touch_sensor_channel_io_map[SOC_TOUCH_SENSOR_NUM] = {
const int touch_sensor_channel_io_map[] = {
-1,
TOUCH_PAD_NUM1_GPIO_NUM,
TOUCH_PAD_NUM2_GPIO_NUM,
Expand Down
20 changes: 6 additions & 14 deletions components/soc/include/soc/touch_sensor_periph.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

Expand All @@ -28,7 +20,7 @@
extern "C" {
#endif

extern const int touch_sensor_channel_io_map[SOC_TOUCH_SENSOR_NUM];
extern const int touch_sensor_channel_io_map[];

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion docs/conf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
'SOC_PCNT_SUPPORTED':PCNT_DOCS,
'SOC_RMT_SUPPORTED':RMT_DOCS,
'SOC_DAC_SUPPORTED':DAC_DOCS,
'SOC_TOUCH_SENSOR_NUM':TOUCH_SENSOR_DOCS,
'SOC_TOUCH_SENSOR_SUPPORTED':TOUCH_SENSOR_DOCS,
'SOC_ULP_SUPPORTED':ULP_DOCS,
'SOC_RISCV_COPROC_SUPPORTED':RISCV_COPROC_DOCS,
'SOC_DIG_SIGN_SUPPORTED':['api-reference/peripherals/ds.rst'],
Expand Down
2 changes: 1 addition & 1 deletion docs/en/api-reference/peripherals/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Peripherals API
:esp32: secure_element
:esp32s2: spi_slave_hd
:SOC_TEMP_SENSOR_SUPPORTED: temp_sensor
:SOC_TOUCH_SENSOR_NUM: touch_pad
:SOC_TOUCH_SENSOR_SUPPORTED: touch_pad
:esp32s2: touch_element
:SOC_TWAI_SUPPORTED: twai
uart
Expand Down
4 changes: 2 additions & 2 deletions docs/en/api-reference/system/sleep_modes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ So, in theory, it's ok if you only wake up the system after the flash is complet
Therefore, it's recommended not to power down flash when using ESP-IDF. For power-sensitive applications, it's recommended to use Kconfig option :ref:`CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND` to reduce the power consumption of the flash during light sleep, instead of powering down the flash.

.. only:: SOC_SPIRAM_SUPPORTED

It is worth mentioning that PSRAM has a similar Kconfig option :ref:`CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND`.

However, for those who have fully understood the risk and are still willing to power down the flash to further reduce the power consumption, please check the following mechanisms:
Expand Down Expand Up @@ -243,7 +243,7 @@ Checking Sleep Wakeup Cause

:cpp:func:`esp_sleep_get_wakeup_cause` function can be used to check which wakeup source has triggered wakeup from sleep mode.

.. only:: SOC_TOUCH_SENSOR_NUM
.. only:: SOC_TOUCH_SENSOR_SUPPORTED

For touchpad, it is possible to identify which touch pin has caused wakeup using :cpp:func:`esp_sleep_get_touchpad_wakeup_status` functions.

Expand Down
2 changes: 1 addition & 1 deletion docs/zh_CN/api-reference/peripherals/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
:esp32: secure_element
:esp32s2: spi_slave_hd
:SOC_TEMP_SENSOR_SUPPORTED: temp_sensor
:SOC_TOUCH_SENSOR_NUM: touch_pad
:SOC_TOUCH_SENSOR_SUPPORTED: touch_pad
:esp32s2: touch_element
:SOC_TWAI_SUPPORTED: twai
uart
Expand Down
Loading

0 comments on commit 741b031

Please sign in to comment.