From f3139089673681c518d01bd01b75c26253abd21b Mon Sep 17 00:00:00 2001 From: Piotr Stolarz Date: Thu, 19 Oct 2023 18:56:54 +0200 Subject: [PATCH] EPS32 driver: removed dependency on Arduino API --- .github/arduino-ci/Dockerfile | 3 ++- src/platform/OneWireNg_ArduinoIdfESP32.cpp | 28 ++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/arduino-ci/Dockerfile b/.github/arduino-ci/Dockerfile index 2d3d635..00e80cf 100644 --- a/.github/arduino-ci/Dockerfile +++ b/.github/arduino-ci/Dockerfile @@ -34,13 +34,14 @@ RUN arduino-cli config add board_manager.additional_urls \ https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json && \ arduino-cli config add board_manager.additional_urls \ http://drazzy.com/package_drazzy.com_index.json && \ + curl https://drazzy.com/package_drazzy.com_index.json >~/.arduino15/package_drazzy.com_index.json && \ arduino-cli update +RUN arduino-cli core install megaTinyCore:megaavr RUN arduino-cli core install esp32:esp32 RUN arduino-cli core install esp8266:esp8266 RUN arduino-cli core install STMicroelectronics:stm32 RUN arduino-cli core install rp2040:rp2040 -RUN arduino-cli core install megaTinyCore:megaavr RUN apt-get install -y \ python3 \ diff --git a/src/platform/OneWireNg_ArduinoIdfESP32.cpp b/src/platform/OneWireNg_ArduinoIdfESP32.cpp index c9c7fb8..a102290 100644 --- a/src/platform/OneWireNg_ArduinoIdfESP32.cpp +++ b/src/platform/OneWireNg_ArduinoIdfESP32.cpp @@ -25,20 +25,15 @@ #if (defined(ARDUINO_ARCH_ESP32) || defined(IDF_VER)) && \ !(defined(ARDUINO_ARCH_ESP8266) || defined(CONFIG_IDF_TARGET_ESP8266)) #include -#include "platform/Platform_TimeCritical.h" #include "driver/gpio.h" #include "soc/gpio_periph.h" +#include "platform/Platform_TimeCritical.h" -#ifdef ARDUINO -# include "Arduino.h" -#else -/* ESP-IDF */ - -# define INPUT 0x01 -# define OUTPUT 0x02 -# define PULLUP 0x04 +#define __INPUT 0x01 +#define __OUTPUT 0x02 +#define __PULLUP 0x04 -void pinMode(uint8_t pin, uint8_t mode) +static void _pinMode(uint8_t pin, uint8_t mode) { gpio_config_t conf = { .pin_bit_mask = (1ULL << pin), @@ -47,13 +42,12 @@ void pinMode(uint8_t pin, uint8_t mode) .pull_down_en = GPIO_PULLDOWN_DISABLE, .intr_type = GPIO_INTR_DISABLE }; - conf.mode = (gpio_mode_t)(mode & (INPUT | OUTPUT)); - if (mode & PULLUP) { + conf.mode = (gpio_mode_t)(mode & (__INPUT | __OUTPUT)); + if (mode & __PULLUP) { conf.pull_up_en = GPIO_PULLUP_ENABLE; } gpio_config(&conf); } -#endif #ifndef GPIO_PIN_COUNT # error "GPIO_PIN_COUNT not defined for this version of SDK" @@ -183,7 +177,7 @@ void OneWireNg_ArduinoIdfESP32::initDtaGpio(unsigned pin, bool pullUp) _dtaGpio.modClrReg = ®_GPIO_MOD_CLR_HI; } #endif - pinMode(pin, INPUT | (pullUp ? PULLUP : 0)); + _pinMode(pin, __INPUT | (pullUp ? __PULLUP : 0)); setupDtaGpio(); } @@ -208,7 +202,7 @@ void OneWireNg_ArduinoIdfESP32::initPwrCtrlGpio(unsigned pin) _pwrCtrlGpio.modClrReg = ®_GPIO_MOD_CLR_HI; } # endif - pinMode(pin, OUTPUT); + _pinMode(pin, __OUTPUT); setupPwrCtrlGpio(true); } #endif /* CONFIG_PWR_CTRL_ENABLED */ @@ -220,4 +214,8 @@ void OneWireNg_ArduinoIdfESP32::initPwrCtrlGpio(unsigned pin) #undef __WRITE0_GPIO #undef __READ_GPIO +#undef __PULLUP +#undef __OUTPUT +#undef __INPUT + #endif /* ESP32 */