Skip to content

Commit

Permalink
[Dallas] Fix Dallas 1Wire plugins on ESP32
Browse files Browse the repository at this point in the history
Apparently the `pinMode` call on ESP SDK 2.0.3 and 2.0.4 now takes 16 usec to complete, compared to 4 msec before.

The [OneWire library maintained by PaulStoffregen](https://github.com/PaulStoffregen/OneWire/blob/master/OneWire.cpp) does perform direct GPIO handling on the registers instead of searching for the pins.
This is apparently working as reported [here by @Jason2866](espressif/arduino-esp32#7049 (comment))

So I replaced all time critical calls for the Dallas plugins with the macros from Paul's library.
  • Loading branch information
TD-er committed Jul 28, 2022
1 parent b03aa23 commit 7011094
Show file tree
Hide file tree
Showing 5 changed files with 589 additions and 52 deletions.
12 changes: 6 additions & 6 deletions platformio_core_defs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ platform_packages =
; Just for those who lost track of the extremely confusing numbering schema.
; For MUSTFIX_CLIENT_TIMEOUT_IN_SECONDS See: https://github.com/espressif/arduino-esp32/pull/6676
[core_esp32_IDF4_4__2_0_4]
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.4/platform-espressif32-2.0.4.zip
platform = https://github.com/Jason2866/platform-espressif32.git
platform_packages =
build_flags = -DESP32_STAGE
-DMUSTFIX_CLIENT_TIMEOUT_IN_SECONDS

[core_esp32_stage]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
platform_packages = framework-arduinoespressif32 @ https://github.com/tasmota/arduino-esp32/releases/download/2.0.1/framework-arduinoespressif32-release_IDF4.4.tar.gz
platformio/tool-esptoolpy @ https://github.com/tasmota/esptool/releases/download/v3.2/esptool-v3.2.zip
build_flags = -DESP32_STAGE
-DMUSTFIX_CLIENT_TIMEOUT_IN_SECONDS
platform = https://github.com/Jason2866/platform-espressif32.git
platform_packages = framework-arduinoespressif32 @ https://github.com/tasmota/arduino-esp32/releases/download/2.0.1/framework-arduinoespressif32-release_IDF4.4.tar.gz
platformio/tool-esptoolpy @ https://github.com/tasmota/esptool/releases/download/v3.2/esptool-v3.2.zip
build_flags = -DESP32_STAGE
-DMUSTFIX_CLIENT_TIMEOUT_IN_SECONDS
61 changes: 61 additions & 0 deletions src/src/DataTypes/GPIO_Direct_RegType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef DATATYPES_GPIO_DIRECT_REGTYPE_H
#define DATATYPES_GPIO_DIRECT_REGTYPE_H

// Original code from Paul Stoffregen
// See: https://github.com/PaulStoffregen/OneWire/blob/master/util/OneWire_direct_regtype.h


#include <stdint.h>

// Platform specific I/O register type

#if defined(__AVR__)
#define IO_REG_TYPE uint8_t

#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__)
#define IO_REG_TYPE uint8_t

#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
#define IO_REG_TYPE uint32_t

#elif defined(__MKL26Z64__)
#define IO_REG_TYPE uint8_t

#elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__)
#define IO_REG_TYPE uint32_t

#elif defined(__PIC32MX__)
#define IO_REG_TYPE uint32_t

#elif defined(ARDUINO_ARCH_ESP8266)
#define IO_REG_TYPE uint32_t

#elif defined(ARDUINO_ARCH_ESP32)
#define IO_REG_TYPE uint32_t
#define IO_REG_MASK_ATTR

#elif defined(ARDUINO_ARCH_STM32)
#define IO_REG_TYPE uint32_t

#elif defined(__SAMD21G18A__)
#define IO_REG_TYPE uint32_t

#elif defined(__ASR6501__)
#define IO_REG_TYPE uint32_t

#elif defined(RBL_NRF51822)
#define IO_REG_TYPE uint32_t

#elif defined(__arc__) /* Arduino101/Genuino101 specifics */
#define IO_REG_TYPE uint32_t

#elif defined(__riscv)
#define IO_REG_TYPE uint32_t

#else
#define IO_REG_TYPE unsigned int

#endif


#endif

0 comments on commit 7011094

Please sign in to comment.