Skip to content

Commit 6e5d8d0

Browse files
projectgusdpgeorge
authored andcommitted
esp32: Drop support for ESP-IDF below V5.2.0.
Specifically, remove all conditional compilation for these earlier versions and change the idf_component.yml specifiers to require >=5.2.0. Signed-off-by: Angus Gratton <[email protected]>
1 parent 82e382a commit 6e5d8d0

File tree

16 files changed

+13
-123
lines changed

16 files changed

+13
-123
lines changed

ports/esp32/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ manage the ESP32 microcontroller, as well as a way to manage the required
2828
build environment and toolchains needed to build the firmware.
2929

3030
The ESP-IDF changes quickly and MicroPython only supports certain versions.
31-
Currently MicroPython supports v5.0.4, v5.0.5, v5.1.2, v5.2.0, v5.2.2, v5.3.
31+
Currently MicroPython supports v5.2, v5.2.2, and v5.3.
3232

3333
To install the ESP-IDF the full instructions can be found at the
3434
[Espressif Getting Started guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#installation-step-by-step).

ports/esp32/machine_dac.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,13 @@
3434
#if MICROPY_PY_MACHINE_DAC
3535

3636
#include "driver/gpio.h"
37-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
3837
#include "driver/dac_oneshot.h"
39-
#else
40-
#include "driver/dac.h"
41-
#define DAC_CHAN_0 DAC_CHANNEL_1
42-
#define DAC_CHAN_1 DAC_CHANNEL_2
43-
#endif
4438

4539
typedef struct _mdac_obj_t {
4640
mp_obj_base_t base;
4741
gpio_num_t gpio_id;
4842
dac_channel_t dac_id;
49-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
5043
dac_oneshot_handle_t dac_oneshot_handle;
51-
#endif
5244
} mdac_obj_t;
5345

5446
static mdac_obj_t mdac_obj[] = {
@@ -77,21 +69,10 @@ static mp_obj_t mdac_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
7769
mp_raise_ValueError(MP_ERROR_TEXT("invalid Pin for DAC"));
7870
}
7971

80-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
8172
dac_oneshot_config_t dac_oneshot_config = {.chan_id = self->dac_id};
8273
check_esp_err(dac_oneshot_new_channel(&dac_oneshot_config, (dac_oneshot_handle_t *)&self->dac_oneshot_handle));
8374
check_esp_err(dac_oneshot_output_voltage(self->dac_oneshot_handle, 0));
8475
return MP_OBJ_FROM_PTR(self);
85-
#else
86-
esp_err_t err = dac_output_enable(self->dac_id);
87-
if (err == ESP_OK) {
88-
err = dac_output_voltage(self->dac_id, 0);
89-
}
90-
if (err == ESP_OK) {
91-
return MP_OBJ_FROM_PTR(self);
92-
}
93-
mp_raise_ValueError(MP_ERROR_TEXT("parameter error"));
94-
#endif
9576
}
9677

9778
static void mdac_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@@ -106,16 +87,8 @@ static mp_obj_t mdac_write(mp_obj_t self_in, mp_obj_t value_in) {
10687
mp_raise_ValueError(MP_ERROR_TEXT("value out of range"));
10788
}
10889

109-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
11090
check_esp_err(dac_oneshot_output_voltage(self->dac_oneshot_handle, value));
11191
return mp_const_none;
112-
#else
113-
esp_err_t err = dac_output_voltage(self->dac_id, value);
114-
if (err == ESP_OK) {
115-
return mp_const_none;
116-
}
117-
mp_raise_ValueError(MP_ERROR_TEXT("parameter error"));
118-
#endif
11992
}
12093
MP_DEFINE_CONST_FUN_OBJ_2(mdac_write_obj, mdac_write);
12194

ports/esp32/machine_pwm.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -211,39 +211,6 @@ static void configure_channel(machine_pwm_obj_t *self) {
211211
}
212212
}
213213

214-
// Temporary workaround for ledc_find_suitable_duty_resolution function only being added in IDF V5.2
215-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
216-
static uint32_t ledc_find_suitable_duty_resolution(uint32_t src_clk_freq, uint32_t timer_freq) {
217-
// This implementation is based on the one used in Micropython v1.23
218-
219-
// Find the highest bit resolution for the requested frequency
220-
unsigned int freq = src_clk_freq;
221-
222-
int divider = (freq + timer_freq / 2) / timer_freq; // rounded
223-
if (divider == 0) {
224-
divider = 1;
225-
}
226-
float f = (float)freq / divider; // actual frequency
227-
if (f <= 1.0) {
228-
f = 1.0;
229-
}
230-
freq = (unsigned int)roundf((float)freq / f);
231-
232-
unsigned int res = 0;
233-
for (; freq > 1; freq >>= 1) {
234-
++res;
235-
}
236-
if (res == 0) {
237-
res = 1;
238-
} else if (res > HIGHEST_PWM_RES) {
239-
// Limit resolution to HIGHEST_PWM_RES to match units of our duty
240-
res = HIGHEST_PWM_RES;
241-
}
242-
243-
return res;
244-
}
245-
#endif
246-
247214
static void set_freq(machine_pwm_obj_t *self, unsigned int freq, ledc_timer_config_t *timer) {
248215
esp_err_t err;
249216
if (freq != timer->freq_hz) {
@@ -265,20 +232,10 @@ static void set_freq(machine_pwm_obj_t *self, unsigned int freq, ledc_timer_conf
265232
}
266233
#endif
267234
uint32_t src_clk_freq = 0;
268-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
269235
err = esp_clk_tree_src_get_freq_hz(timer->clk_cfg, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &src_clk_freq);
270236
if (err != ESP_OK) {
271237
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("unable to query source clock frequency %d"), (int)timer->clk_cfg);
272238
}
273-
#else
274-
// Simplified fallback logic for IDF V5.0.x, for targets with APB only.
275-
src_clk_freq = APB_CLK_FREQ; // 80 MHz
276-
#if SOC_LEDC_SUPPORT_REF_TICK
277-
if (timer->clk_cfg == LEDC_USE_REF_TICK) {
278-
src_clk_freq = REF_CLK_FREQ; // 1 MHz
279-
}
280-
#endif // SOC_LEDC_SUPPORT_REF_TICK
281-
#endif // ESP_IDF_VERSION
282239

283240
timer->duty_resolution = ledc_find_suitable_duty_resolution(src_clk_freq, timer->freq_hz);
284241

ports/esp32/machine_uart.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,7 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args,
399399
}
400400
self->flowcontrol = args[ARG_flow].u_int;
401401
}
402-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
403402
uint8_t uart_fifo_len = UART_HW_FIFO_LEN(self->uart_num);
404-
#else
405-
uint8_t uart_fifo_len = UART_FIFO_LEN;
406-
#endif
407403
check_esp_err(uart_set_hw_flow_ctrl(self->uart_num, self->flowcontrol, uart_fifo_len - uart_fifo_len / 4));
408404
}
409405

ports/esp32/main_esp32/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
dependencies:
33
espressif/mdns: "~1.1.0"
44
idf:
5-
version: ">=5.0.4"
5+
version: ">=5.2.0"

ports/esp32/main_esp32c3/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
dependencies:
33
espressif/mdns: "~1.1.0"
44
idf:
5-
version: ">=5.0.4"
5+
version: ">=5.2.0"

ports/esp32/main_esp32c6/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
dependencies:
33
espressif/mdns: "~1.1.0"
44
idf:
5-
version: ">=5.1.0"
5+
version: ">=5.2.0"

ports/esp32/main_esp32s2/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dependencies:
33
espressif/mdns: "~1.1.0"
44
espressif/esp_tinyusb: "~1.0.0"
55
idf:
6-
version: ">=5.0.4"
6+
version: ">=5.2.0"

ports/esp32/main_esp32s3/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dependencies:
33
espressif/mdns: "~1.1.0"
44
espressif/esp_tinyusb: "~1.0.0"
55
idf:
6-
version: ">=5.0.4"
6+
version: ">=5.2.0"

ports/esp32/modesp32.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static mp_obj_t esp32_wake_on_touch(const mp_obj_t wake) {
5353
if (machine_rtc_config.ext0_pin != -1) {
5454
mp_raise_ValueError(MP_ERROR_TEXT("no resources"));
5555
}
56-
// mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("touchpad wakeup not available for this version of ESP-IDF"));
5756

5857
machine_rtc_config.wake_on_touch = mp_obj_is_true(wake);
5958
return mp_const_none;

0 commit comments

Comments
 (0)