PaulStoffregen / OneWire

Library for Dallas/Maxim 1-Wire Chips
http://www.pjrc.com/teensy/td_libs_OneWire.html
579 stars 382 forks source link

ESP8266 Pin16 not working #27

Open ScheintodX opened 7 years ago

ScheintodX commented 7 years ago

pin16 is not working as 1wire pin with the special esp8266 code. It is working with the generic driver.

This is because pin 16 needs special treatment (other registers).

s. e.g. esp8266 wiring:

extern int ICACHE_RAM_ATTR __digitalRead(uint8_t pin) { pwm_stop_pin(pin); if(pin < 16){ return GPIP(pin); } else if(pin == 16){ return GP16I & 0x01; } return 0; }

This is so for the other funktions, too :(

(code taken from here: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/core_esp8266_wiring_digital.c )

bneedhamia commented 6 years ago

Another reason pin 16 won't work: OneWire.h contains, under the ESP8266 code, #define PIN_TO_BITMASK(pin) (1 << pin). Because 1 is an int (16 bits) and the mask is 32 bits, shifting the 1 by 16 results in 0 rather than 0x10000L. Looking at the Adafruit ESP8266 OneWire version replaces this line with #define PIN_TO_BITMASK(pin) (1UL << (pin)).

tretyakovsa commented 5 years ago

ESP8266 Pin14 not working!

Emmanuel-FR commented 5 years ago

ESP8266 Pin14 not working!

Hello, I had the same problem and spent hours trying to figure why. I found out that it works if you use version 2.3.0 of the onewire library. It seems to be a regression, I tried other pins and only one worked (the standard pin of the exemple code).

gnalbandian commented 4 years ago

Another reason pin 16 won't work: OneWire.h contains, under the ESP8266 code, #define PIN_TO_BITMASK(pin) (1 << pin). Because 1 is an int (16 bits) and the mask is 32 bits, shifting the 1 by 16 results in 0 rather than 0x10000L. Looking at the Adafruit ESP8266 OneWire version replaces this line with #define PIN_TO_BITMASK(pin) (1UL << (pin)).

Saved my day! This should be fixed! Thanks!

PaulStoffregen commented 4 years ago

Can anyone else using ESP8266 confirm this is now fixed?