From d0fcdf254f3e79db113738d77e31f86e3cd062bf Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Sun, 12 Nov 2023 20:43:52 +0200 Subject: [PATCH 1/3] esp32/network: Add WiFi AUTH_WPA3_ENT_192 authenticate mode. --- ports/esp32/modnetwork_globals.h | 3 +++ ports/esp32/network_common.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/ports/esp32/modnetwork_globals.h b/ports/esp32/modnetwork_globals.h index 7326d453be5aa..94ee810c7cc34 100644 --- a/ports/esp32/modnetwork_globals.h +++ b/ports/esp32/modnetwork_globals.h @@ -29,6 +29,9 @@ { MP_ROM_QSTR(MP_QSTR_AUTH_WPA2_WPA3_PSK), MP_ROM_INT(WIFI_AUTH_WPA2_WPA3_PSK) }, { MP_ROM_QSTR(MP_QSTR_AUTH_WAPI_PSK), MP_ROM_INT(WIFI_AUTH_WAPI_PSK) }, { MP_ROM_QSTR(MP_QSTR_AUTH_OWE), MP_ROM_INT(WIFI_AUTH_OWE) }, +#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 1, 0) +{ MP_ROM_QSTR(MP_QSTR_AUTH_WPA3_ENT_192), MP_ROM_INT(WIFI_AUTH_WPA3_ENT_192) }, +#endif { MP_ROM_QSTR(MP_QSTR_AUTH_MAX), MP_ROM_INT(WIFI_AUTH_MAX) }, #endif diff --git a/ports/esp32/network_common.c b/ports/esp32/network_common.c index ca07f3c06ba18..bad58589b10dd 100644 --- a/ports/esp32/network_common.c +++ b/ports/esp32/network_common.c @@ -168,4 +168,8 @@ STATIC mp_obj_t esp_phy_mode(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_network_phy_mode_obj, 0, 1, esp_phy_mode); +#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 1, 0) +_Static_assert(WIFI_AUTH_MAX == 11, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h"); +#else _Static_assert(WIFI_AUTH_MAX == 10, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h"); +#endif From 5887414b3b77bb8c6e0accf80b78e1c9b76b6db5 Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Sun, 12 Nov 2023 20:46:26 +0200 Subject: [PATCH 2/3] esp32/DAC: Support one-shot mode of driver. --- ports/esp32/machine_dac.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/ports/esp32/machine_dac.c b/ports/esp32/machine_dac.c index 0e85dc9c9bfb2..3008406f70863 100644 --- a/ports/esp32/machine_dac.c +++ b/ports/esp32/machine_dac.c @@ -32,23 +32,33 @@ #include "modmachine.h" #if MICROPY_PY_MACHINE_DAC +#if SOC_DAC_SUPPORTED #include "driver/gpio.h" +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) +#include "driver/dac_oneshot.h" +#else #include "driver/dac.h" +#define DAC_CHAN_0 DAC_CHANNEL_1 +#define DAC_CHAN_1 DAC_CHANNEL_2 +#endif typedef struct _mdac_obj_t { mp_obj_base_t base; gpio_num_t gpio_id; dac_channel_t dac_id; +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) + dac_oneshot_handle_t dac_oneshot_handle; +#endif } mdac_obj_t; -STATIC const mdac_obj_t mdac_obj[] = { +STATIC mdac_obj_t mdac_obj[] = { #if CONFIG_IDF_TARGET_ESP32 - {{&machine_dac_type}, GPIO_NUM_25, DAC_CHANNEL_1}, - {{&machine_dac_type}, GPIO_NUM_26, DAC_CHANNEL_2}, + {{&machine_dac_type}, GPIO_NUM_25, DAC_CHAN_0}, + {{&machine_dac_type}, GPIO_NUM_26, DAC_CHAN_1}, #else - {{&machine_dac_type}, GPIO_NUM_17, DAC_CHANNEL_1}, - {{&machine_dac_type}, GPIO_NUM_18, DAC_CHANNEL_2}, + {{&machine_dac_type}, GPIO_NUM_17, DAC_CHAN_0}, + {{&machine_dac_type}, GPIO_NUM_18, DAC_CHAN_1}, #endif }; @@ -68,6 +78,12 @@ STATIC mp_obj_t mdac_make_new(const mp_obj_type_t *type, size_t n_args, size_t n mp_raise_ValueError(MP_ERROR_TEXT("invalid Pin for DAC")); } +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) + dac_oneshot_config_t dac_oneshot_config = {.chan_id = self->dac_id}; + check_esp_err(dac_oneshot_new_channel(&dac_oneshot_config, &self->dac_oneshot_handle)); + check_esp_err(dac_oneshot_output_voltage(self->dac_oneshot_handle, 0)); + return MP_OBJ_FROM_PTR(self); +#else esp_err_t err = dac_output_enable(self->dac_id); if (err == ESP_OK) { err = dac_output_voltage(self->dac_id, 0); @@ -76,6 +92,7 @@ STATIC mp_obj_t mdac_make_new(const mp_obj_type_t *type, size_t n_args, size_t n return MP_OBJ_FROM_PTR(self); } mp_raise_ValueError(MP_ERROR_TEXT("parameter error")); +#endif } STATIC void mdac_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { @@ -90,11 +107,16 @@ STATIC mp_obj_t mdac_write(mp_obj_t self_in, mp_obj_t value_in) { mp_raise_ValueError(MP_ERROR_TEXT("value out of range")); } +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) + check_esp_err(dac_oneshot_output_voltage(self->dac_oneshot_handle, value)); + return mp_const_none; +#else esp_err_t err = dac_output_voltage(self->dac_id, value); if (err == ESP_OK) { return mp_const_none; } mp_raise_ValueError(MP_ERROR_TEXT("parameter error")); +#endif } MP_DEFINE_CONST_FUN_OBJ_2(mdac_write_obj, mdac_write); @@ -113,4 +135,7 @@ MP_DEFINE_CONST_OBJ_TYPE( locals_dict, &mdac_locals_dict ); +#else +#error DAC is not supported! +#endif // SOC_DAC_SUPPORTED #endif // MICROPY_PY_MACHINE_DAC From 43f8aa0c13cc5222f14c362aa4bcee59cd42cb80 Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Sun, 12 Nov 2023 20:49:07 +0200 Subject: [PATCH 3/3] esp32/README: v5.1 is available. --- ports/esp32/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp32/README.md b/ports/esp32/README.md index 169de4073bf71..ef8bcabfe67b0 100644 --- a/ports/esp32/README.md +++ b/ports/esp32/README.md @@ -28,7 +28,7 @@ manage the ESP32 microcontroller, as well as a way to manage the required build environment and toolchains needed to build the firmware. The ESP-IDF changes quickly and MicroPython only supports certain versions. -Currently MicroPython supports only v5.0.2. +Currently MicroPython supports v5.0.2, v5.1. To install the ESP-IDF the full instructions can be found at the [Espressif Getting Started guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#installation-step-by-step).