From 218109571ce1e13a25dd0ed3ff547621c0dd219b Mon Sep 17 00:00:00 2001 From: Piotr Stolarz Date: Tue, 9 Apr 2024 21:56:22 +0200 Subject: [PATCH] ESP-IDF: ESP32P4 support added --- .github/workflows/espidf-builds.yml | 1 + README.md | 2 +- src/platform/OneWireNg_ArduinoIdfESP32.cpp | 25 ++++++++++++++++------ src/platform/Platform_TimeCritical.h | 5 +++-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/espidf-builds.yml b/.github/workflows/espidf-builds.yml index 4ffd6f4..23d5710 100644 --- a/.github/workflows/espidf-builds.yml +++ b/.github/workflows/espidf-builds.yml @@ -38,6 +38,7 @@ jobs: - esp32c3 - esp32c6 - esp32h2 + - esp32p4 - esp8266 example: - DallasTemperature diff --git a/README.md b/README.md index ba9a7f5..f73dbf2 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ While added the library shall be configured via Mbed native configuration (see * Arduino ESP8266/ESP-IDF. * Platform class: `OneWireNg_ArduinoIdfESP8266`. * Tested on WemOS D1. -* Arduino/ESP-IDF ESP32 (classic, S, C and H families). +* Arduino/ESP-IDF ESP32 (classic, S, C, H and P families). * Platform class: `OneWireNg_ArduinoIdfESP32`. * Tested on ESP32-WROOM-32, ESP32-S2-WROVER, ESP32-S3-WROOM-1, ESP32-C3-32S-Kit. * Arduino/Pico SDK RP2040. diff --git a/src/platform/OneWireNg_ArduinoIdfESP32.cpp b/src/platform/OneWireNg_ArduinoIdfESP32.cpp index a102290..101b35d 100644 --- a/src/platform/OneWireNg_ArduinoIdfESP32.cpp +++ b/src/platform/OneWireNg_ArduinoIdfESP32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Piotr Stolarz + * Copyright (c) 2022,2024 Piotr Stolarz * OneWireNg: Arduino 1-wire service library * * Distributed under the 2-clause BSD License (the License) @@ -40,7 +40,10 @@ static void _pinMode(uint8_t pin, uint8_t mode) .mode = GPIO_MODE_DISABLE, .pull_up_en = GPIO_PULLUP_DISABLE, .pull_down_en = GPIO_PULLDOWN_DISABLE, - .intr_type = GPIO_INTR_DISABLE + .intr_type = GPIO_INTR_DISABLE, +#if SOC_GPIO_SUPPORT_PIN_HYS_FILTER + .hys_ctrl_mode = GPIO_HYS_SOFT_DISABLE, +#endif }; conf.mode = (gpio_mode_t)(mode & (__INPUT | __OUTPUT)); if (mode & __PULLUP) { @@ -60,15 +63,23 @@ static void _pinMode(uint8_t pin, uint8_t mode) # define REG_GPIO_MOD_SET_LO GPIO.enable_w1ts.val # define REG_GPIO_MOD_CLR_LO GPIO.enable_w1tc.val #else -# define REG_GPIO_IN_LO GPIO.in +# if defined(CONFIG_IDF_TARGET_ESP32P4) +# define REG_GPIO_IN_LO GPIO.in.val +# define REG_GPIO_OUT_SET_LO GPIO.out_w1ts.val +# define REG_GPIO_OUT_CLR_LO GPIO.out_w1tc.val +# define REG_GPIO_MOD_SET_LO GPIO.enable_w1ts.val +# define REG_GPIO_MOD_CLR_LO GPIO.enable_w1tc.val +# else +# define REG_GPIO_IN_LO GPIO.in +# define REG_GPIO_OUT_SET_LO GPIO.out_w1ts +# define REG_GPIO_OUT_CLR_LO GPIO.out_w1tc +# define REG_GPIO_MOD_SET_LO GPIO.enable_w1ts +# define REG_GPIO_MOD_CLR_LO GPIO.enable_w1tc +# endif # define REG_GPIO_IN_HI GPIO.in1.val -# define REG_GPIO_OUT_SET_LO GPIO.out_w1ts # define REG_GPIO_OUT_SET_HI GPIO.out1_w1ts.val -# define REG_GPIO_OUT_CLR_LO GPIO.out_w1tc # define REG_GPIO_OUT_CLR_HI GPIO.out1_w1tc.val -# define REG_GPIO_MOD_SET_LO GPIO.enable_w1ts # define REG_GPIO_MOD_SET_HI GPIO.enable1_w1ts.val -# define REG_GPIO_MOD_CLR_LO GPIO.enable_w1tc # define REG_GPIO_MOD_CLR_HI GPIO.enable1_w1tc.val #endif diff --git a/src/platform/Platform_TimeCritical.h b/src/platform/Platform_TimeCritical.h index 91ec9d3..2616248 100644 --- a/src/platform/Platform_TimeCritical.h +++ b/src/platform/Platform_TimeCritical.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021,2022 Piotr Stolarz + * Copyright (c) 2021,2022,2024 Piotr Stolarz * OneWireNg: Arduino 1-wire service library * * Distributed under the 2-clause BSD License (the License) @@ -26,7 +26,8 @@ #if CONFIG_BITBANG_DELAY_CCOUNT # if defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C3) || \ - defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) + defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) || \ + defined(CONFIG_IDF_TARGET_ESP32P4) # include "esp_cpu.h" # include "esp_idf_version.h" # if (ESP_IDF_VERSION_MAJOR >= 5)