Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ports/espressif/common-hal/alarm/touch/TouchAlarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,19 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT,
.group = TOUCH_CHAN_TRIG_GROUP_BOTH,
};
#else
#elif SOC_TOUCH_SENSOR_VERSION == 2
touch_channel_config_t chan_cfg = {
.active_thresh = {(uint32_t)(benchmark / 10)},
.charge_speed = TOUCH_CHARGE_SPEED_7,
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT,
};
#elif SOC_TOUCH_SENSOR_VERSION == 3
// Values are similar to an ESP-IDF example: 1000, 2500, 5000.
touch_channel_config_t chan_cfg = {
.active_thresh = {(uint32_t)(benchmark / 10), (uint32_t)(benchmark / 4), (uint32_t)(benchmark / 2)},
};
#else
#error bad SOC_TOUCH_SENSOR_VERSION
#endif
touch_sensor_reconfig_channel(chan, &chan_cfg);
}
Expand Down
59 changes: 37 additions & 22 deletions ports/espressif/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ CIRCUITPY_LIBC_STRING0 = 0
# These modules are implemented in ports/<port>/common-hal:
CIRCUITPY__EVE ?= 1
CIRCUITPY_ALARM ?= 1
CIRCUITPY_ALARM_TOUCH ?= 0
CIRCUITPY_ALARM_TOUCH ?= 1
CIRCUITPY_ANALOGBUFIO ?= 1
CIRCUITPY_AUDIOBUSIO ?= 1
CIRCUITPY_AUDIOBUSIO_PDMIN ?= 0
CIRCUITPY_AUDIOBUSIO_PDMIN ?= 1
CIRCUITPY_AUDIOI2SIN ?= 1
CIRCUITPY_AUDIOIO ?= 1
CIRCUITPY_BLEIO_HCI = 0
Expand All @@ -80,7 +80,7 @@ CIRCUITPY_ESPULP ?= 1
CIRCUITPY_FRAMEBUFFERIO ?= 1
CIRCUITPY_FREQUENCYIO ?= 1
CIRCUITPY_HASHLIB ?= 1
CIRCUITPY_I2CTARGET ?= 0
CIRCUITPY_I2CTARGET = 0
CIRCUITPY_MAX3421E ?= 1
CIRCUITPY_MEMORYMAP ?= 1
CIRCUITPY_RCLCPY ?= 0
Expand All @@ -92,6 +92,7 @@ CIRCUITPY_ROTARYIO ?= 1
CIRCUITPY_SDIOIO ?= 1
CIRCUITPY_SETTABLE_PROCESSOR_FREQUENCY ?= 1
CIRCUITPY_SYNTHIO_MAX_CHANNELS ?= 12
CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1
CIRCUITPY_WATCHDOG ?= 1
CIRCUITPY_WIFI ?= 1
Expand All @@ -101,7 +102,6 @@ CIRCUITPY_SOCKETPOOL_IPV6 ?= 1
#### esp32 ############################################################
ifeq ($(IDF_TARGET),esp32)
# Modules
CIRCUITPY_ALARM_TOUCH = 1
CIRCUITPY_RGBMATRIX = 0

# Has no USB
Expand All @@ -117,6 +117,10 @@ CIRCUITPY_ESPCAMERA = 0
CIRCUITPY_ESPULP = 0
CIRCUITPY_MEMORYMAP = 0

# No capacitive touch peripheral
CIRCUITPY_ALARM_TOUCH = 0
CIRCUITPY_TOUCHIO_USE_NATIVE = 0

# No I80 support from the IDF
CIRCUITPY_PARALLELDISPLAYBUS = 0

Expand Down Expand Up @@ -146,8 +150,6 @@ CIRCUITPY_RGBMATRIX = 0
# No SDMMC
CIRCUITPY_SDIOIO = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
# Features
CIRCUITPY_USB_DEVICE = 0
CIRCUITPY_ESP_USB_SERIAL_JTAG = 0
Expand All @@ -162,9 +164,16 @@ CIRCUITPY_MEMORYMAP = 0
# No I80 support from the IDF
CIRCUITPY_PARALLELDISPLAYBUS = 0

# No capacitive touch peripheral
CIRCUITPY_ALARM_TOUCH = 0
CIRCUITPY_TOUCHIO_USE_NATIVE = 0

# No DAC
CIRCUITPY_AUDIOIO = 0

# No I2S peripheral PDM-to-PCM hardware support
CIRCUITPY_AUDIOBUSIO_PDMIN = 0

# No PCNT peripheral
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_COUNTIO = 0
Expand All @@ -173,8 +182,6 @@ CIRCUITPY_ROTARYIO = 0
# No SDMMC
CIRCUITPY_SDIOIO = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
# Features
CIRCUITPY_USB_DEVICE = 0
CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 1
Expand All @@ -187,9 +194,16 @@ CIRCUITPY_ESPULP = 0
CIRCUITPY_MEMORYMAP = 0
CIRCUITPY_RGBMATRIX = 0

# No capacitive touch peripheral
CIRCUITPY_ALARM_TOUCH = 0
CIRCUITPY_TOUCHIO_USE_NATIVE = 0

# No DAC
CIRCUITPY_AUDIOIO = 0

# No I2S peripheral PDM-to-PCM hardware support
CIRCUITPY_AUDIOBUSIO_PDMIN = 0

# No space for this
CIRCUITPY_AUDIOBUSIO = 0

Expand All @@ -199,8 +213,6 @@ CIRCUITPY_PARALLELDISPLAYBUS = 0
# No SDMMC
CIRCUITPY_SDIOIO = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
# Features
CIRCUITPY_USB_DEVICE = 0
CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 1
Expand All @@ -213,6 +225,10 @@ CIRCUITPY_ESPULP = 0
CIRCUITPY_MEMORYMAP = 0
CIRCUITPY_RGBMATRIX = 0

# No capacitive touch peripheral
CIRCUITPY_ALARM_TOUCH = 0
CIRCUITPY_TOUCHIO_USE_NATIVE = 0

# No DAC
CIRCUITPY_AUDIOIO = 0

Expand All @@ -225,8 +241,6 @@ CIRCUITPY_PARALLELDISPLAYBUS = 0
# No SDMMC
CIRCUITPY_SDIOIO = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
# Features
CIRCUITPY_USB_DEVICE = 0
CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 1
Expand All @@ -252,18 +266,22 @@ CIRCUITPY_ESPULP = 0
CIRCUITPY_MEMORYMAP = 0
CIRCUITPY_RGBMATRIX = 0

# No capacitive touch peripheral
CIRCUITPY_ALARM_TOUCH = 0
CIRCUITPY_TOUCHIO_USE_NATIVE = 0

# No DAC
CIRCUITPY_AUDIOIO = 0

# No I2S peripheral PDM-to-PCM hardware support
CIRCUITPY_AUDIOBUSIO_PDMIN = 0

# No I80 support from the IDF
CIRCUITPY_PARALLELDISPLAYBUS = 0

# No SDMMC
CIRCUITPY_SDIOIO = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0

# Features
CIRCUITPY_USB_DEVICE = 0
CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 1
Expand All @@ -283,9 +301,6 @@ CIRCUITPY_BLEIO_NATIVE = 0
CIRCUITPY_WIFI = 0
CIRCUITPY_SSL = 0

CIRCUITPY_TOUCHIO = 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0

# Second stage bootloader doesn't work when the factory partition is empty due to
# UF2 missing.
UF2_BOOTLOADER = 0
Expand Down Expand Up @@ -316,9 +331,11 @@ CIRCUITPY_MIPIDSI = 1
#### esp32s2 ##########################################################
else ifeq ($(IDF_TARGET),esp32s2)
# Modules
CIRCUITPY_ALARM_TOUCH = $(CIRCUITPY_ALARM)
CIRCUITPY_AUDIOIO ?= 1

# No I2S peripheral PDM-to-PCM hardware support
CIRCUITPY_AUDIOBUSIO_PDMIN = 0

# No BLE in hw
CIRCUITPY_BLEIO_NATIVE = 0

Expand All @@ -331,8 +348,6 @@ CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 0
else ifeq ($(IDF_TARGET),esp32s3)

# Modules
CIRCUITPY_ALARM_TOUCH = $(CIRCUITPY_ALARM)
CIRCUITPY_AUDIOBUSIO_PDMIN = 1
CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 0

# No DAC
Expand All @@ -342,7 +357,7 @@ endif
#### end chip-specific choices ########################################

# By default, enable dualbank, and it'll be disabled for small flash sizes
CIRCUITPY_DUALBANK = 1
CIRCUITPY_DUALBANK ?= 1

# No room for large modules on 2MB boards
# 2MB boards have a single firmware partition, and can't do dualbank.
Expand Down
25 changes: 22 additions & 3 deletions ports/espressif/peripherals/touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ void peripherals_touch_init(const int channel_id) {
touch_sensor_sample_config_t sample_cfg = TOUCH_SENSOR_V2_DEFAULT_SAMPLE_CONFIG(500, TOUCH_VOLT_LIM_L_0V5, TOUCH_VOLT_LIM_H_2V2);
#elif SOC_TOUCH_SENSOR_VERSION == 3
touch_sensor_sample_config_t sample_cfg = TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG2(3, 29, 8, 3);
#else
#error bad SOC_TOUCH_SENSOR_VERSION
#endif
touch_sensor_config_t sens_cfg = TOUCH_SENSOR_DEFAULT_BASIC_CONFIG(1, &sample_cfg);
touch_sensor_new_controller(&sens_cfg, &touch_controller);
Expand All @@ -86,12 +88,19 @@ void peripherals_touch_init(const int channel_id) {
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT,
.group = TOUCH_CHAN_TRIG_GROUP_BOTH,
};
#else
#elif SOC_TOUCH_SENSOR_VERSION == 2
touch_channel_config_t chan_cfg = {
.active_thresh = {2000},
.charge_speed = TOUCH_CHARGE_SPEED_7,
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT,
};
#elif SOC_TOUCH_SENSOR_VERSION == 3
// Values are similar to an ESP-IDF example: 1000, 2500, 5000.
touch_channel_config_t chan_cfg = {
.active_thresh = {1000, 2000, 5000},
};
#else
#error bad SOC_TOUCH_SENSOR_VERSION
#endif

touch_sensor_new_channel(touch_controller, channel_id, &chan_cfg, &touch_channels[idx]);
Expand All @@ -110,19 +119,29 @@ uint16_t peripherals_touch_read(int channel_id) {
}

uint32_t touch_value = 0;
touch_channel_read_data(touch_channels[idx], TOUCH_CHAN_DATA_TYPE_RAW, &touch_value);

#if SOC_TOUCH_SENSOR_VERSION == 1
// ESP32 touch reads a lower value when touched.
// Flip the values to be consistent with TouchIn assumptions.
touch_channel_read_data(touch_channels[idx], TOUCH_CHAN_DATA_TYPE_RAW, &touch_value);
if (touch_value > UINT16_MAX) {
return 0;
}
return UINT16_MAX - (uint16_t)touch_value;
#else
touch_channel_read_data(touch_channels[idx], TOUCH_CHAN_DATA_TYPE_RAW, &touch_value);
return UINT16_MAX - (uint16_t)touch_value;
#elif SOC_TOUCH_SENSOR_VERSION == 2
if (touch_value > UINT16_MAX) {
return UINT16_MAX;
}
return (uint16_t)touch_value;
#elif SOC_TOUCH_SENSOR_VERSION == 3
touch_channel_read_data(touch_channels[idx], TOUCH_CHAN_DATA_TYPE_SMOOTH, &touch_value);
if (touch_value > UINT16_MAX) {
return UINT16_MAX;
}
return (uint16_t)touch_value;
#else
#error bad SOC_TOUCH_SENSOR_VERSION
#endif
}
1 change: 1 addition & 0 deletions shared-bindings/alarm/touch/TouchAlarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
//| may be limited due to hardware restrictions, particularly for deep-sleep alarms.
//|
//| **Limitations:** Not available on SAMD, Nordic, or RP2040.
//| On Espressif, only available on ESP32, ESP32-S2, ESP32-S3, and ESP32-P4.
//| """
//| ...
//|
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/audiobusio/PDMIn.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//|
//| **Limitations:** On SAMD and RP2040, supports only 8 or 16 bit mono input, with 64x oversampling.
//| On nRF52840, supports only 16 bit mono input at 16 kHz; oversampling is fixed at 64x. Not provided
//| on nRF52833 for space reasons. Not available on Espressif.
//| on nRF52833 for space reasons. On Espressif, only available on ESP32, ESP32-S3, and ESP32-P4.
//|
//| For example, to record 8-bit unsigned samples to a buffer::
//|
Expand Down
Loading