Skip to content

Commit

Permalink
fix OneWire for IDF5.1 and C2/C6 (#19303)
Browse files Browse the repository at this point in the history
* fix OneWire for IDF5.1 and C2/C6

* Use Onewire in arduino30 builds

* use SOC specific defines for C2,C3 and C6
  • Loading branch information
Staars committed Aug 14, 2023
1 parent f40f4a1 commit 7d18dd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 8 additions & 5 deletions lib/lib_basic/OneWire-Stickbreaker/OneWire.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@

#elif defined(ARDUINO_ARCH_ESP32)
#include <driver/rtc_io.h>
#if ESP_IDF_VERSION_MAJOR >= 5
#include "soc/gpio_periph.h"
#endif // ESP_IDF_VERSION_MAJOR >= 5
#define PIN_TO_BASEREG(pin) (0)
#define PIN_TO_BITMASK(pin) (pin)
#define IO_REG_TYPE uint32_t
Expand All @@ -156,7 +159,7 @@
static inline __attribute__((always_inline))
IO_REG_TYPE directRead(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 // max. usable Pins are 23 for C6 (below flash pins)
return (GPIO.in.val >> pin) & 0x1;
#else // plain ESP32
if ( pin < 32 )
Expand All @@ -171,7 +174,7 @@ IO_REG_TYPE directRead(IO_REG_TYPE pin)
static inline __attribute__((always_inline))
void directWriteLow(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
GPIO.out_w1tc.val = ((uint32_t)1 << pin);
#else // plain ESP32
if ( pin < 32 )
Expand All @@ -184,7 +187,7 @@ void directWriteLow(IO_REG_TYPE pin)
static inline __attribute__((always_inline))
void directWriteHigh(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
GPIO.out_w1ts.val = ((uint32_t)1 << pin);
#else // plain ESP32
if ( pin < 32 )
Expand All @@ -197,7 +200,7 @@ void directWriteHigh(IO_REG_TYPE pin)
static inline __attribute__((always_inline))
void directModeInput(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
GPIO.enable_w1tc.val = ((uint32_t)1 << (pin));
#else
if ( digitalPinIsValid(pin) )
Expand All @@ -223,7 +226,7 @@ void directModeInput(IO_REG_TYPE pin)
static inline __attribute__((always_inline))
void directModeOutput(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
GPIO.enable_w1ts.val = ((uint32_t)1 << (pin));
#else
if ( digitalPinIsValid(pin) && pin <= 33 ) // pins above 33 can be only inputs
Expand Down
2 changes: 0 additions & 2 deletions platformio_tasmota_env32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ lib_ignore =
ESP Mail Client
IRremoteESP8266
NeoPixelBus
OneWire
MFRC522
universal display Library
ESP8266Audio
Expand All @@ -75,7 +74,6 @@ lib_ignore =
ESP Mail Client
IRremoteESP8266
NeoPixelBus
OneWire
MFRC522
universal display Library
ESP8266Audio
Expand Down

0 comments on commit 7d18dd0

Please sign in to comment.