Skip to content

Commit

Permalink
EPS32 driver: removed dependency on Arduino API
Browse files Browse the repository at this point in the history
  • Loading branch information
pstolarz committed Oct 19, 2023
1 parent 2a46ba0 commit f313908
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/arduino-ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
28 changes: 13 additions & 15 deletions src/platform/OneWireNg_ArduinoIdfESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,15 @@
#if (defined(ARDUINO_ARCH_ESP32) || defined(IDF_VER)) && \
!(defined(ARDUINO_ARCH_ESP8266) || defined(CONFIG_IDF_TARGET_ESP8266))
#include <assert.h>
#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),
Expand All @@ -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"
Expand Down Expand Up @@ -183,7 +177,7 @@ void OneWireNg_ArduinoIdfESP32::initDtaGpio(unsigned pin, bool pullUp)
_dtaGpio.modClrReg = &REG_GPIO_MOD_CLR_HI;
}
#endif
pinMode(pin, INPUT | (pullUp ? PULLUP : 0));
_pinMode(pin, __INPUT | (pullUp ? __PULLUP : 0));
setupDtaGpio();
}

Expand All @@ -208,7 +202,7 @@ void OneWireNg_ArduinoIdfESP32::initPwrCtrlGpio(unsigned pin)
_pwrCtrlGpio.modClrReg = &REG_GPIO_MOD_CLR_HI;
}
# endif
pinMode(pin, OUTPUT);
_pinMode(pin, __OUTPUT);
setupPwrCtrlGpio(true);
}
#endif /* CONFIG_PWR_CTRL_ENABLED */
Expand All @@ -220,4 +214,8 @@ void OneWireNg_ArduinoIdfESP32::initPwrCtrlGpio(unsigned pin)
#undef __WRITE0_GPIO
#undef __READ_GPIO

#undef __PULLUP
#undef __OUTPUT
#undef __INPUT

#endif /* ESP32 */

0 comments on commit f313908

Please sign in to comment.