Open jmhunter opened 7 years ago
Have this code been tested on any non-AVR chips?
I have tried it on a chipKit MAX32 Controller with a PIC chip and didn't manage it to work. But it would be great to see that function in your library. I have used that page to change your library and the embedded one in chipKits mpide: https://github.com/PaulStoffregen/OneWire/pull/30/commits/d8cbd4726dee9eb70d7a01a6e869ef9bc1044ddd
Any tried on any other non-AVR boards? (I'm pretty sure it will not work on any of them)
If it only works on AVR boards (sorry, I only have Arduino here to test with), would it be an idea to update this to have some kind of #ifdef that limits its use to AVR?
it will work on some controllers like AVR, but won't do harm on the others. the changes could be more minimal though. the digitalWrite() in constructor shouldn't be needed
but won't do harm on the others
Which others have you tested?
This code uses the AVR quirk where writing to the output register affects the input pullups. I do not intend to merge it as-is.
-> I tested this code without the preprocessor-guards with atmega328p, teensy3.2 and the esp8266, works as expected on atmega. won't do harm on the others. but you are right. i wouldn't merge this either without some cleanup.
what do you expect to happen on other architectures? we are using macros that rely on low level register access. there is no controller in your list that magically changes the pin-direction after the pin is set to input and the output-registers are written afterwards. here is a list of gpio-behaviors (compiled from the datasheets) for proving my point:
ReferenceDataSheet atmega328p
K20 / Cortex M4 Reference Manual page 239FF - Port control : Individual pull control registers with pullup, pulldown and pull-disable support page 1597FF - GPIO
MK64 / Cortex M4 Reference Manual page 1757ff -> same design as K20
K66 / Cortex M4 Reference Manual page 2185ff -> same design as K20
KL2x Cortex M0 Reference Manual page 844ff -> same design as K20
SAM3X \ SAM3A Cortex M3 Datasheet page 618ff PIO
PIC32MX MIPS32 datasheet page 307ff io ports
ESP8266 Datasheet page 17: Each GPIO can be configured with internal pull-up
ESP8266 Technical Reference page 14ff GPIO
GPIO_ENABE_W1TS: output enable register
GPIO_ENABE_W1TC: output disable register
GPIO_ENABLE: output enable status register
GPIO_OUT_W1TC: output low level register
GPIO_OUT_W1TS: output high level register, If the related bit is set to be 1, it means the IO output is high level (at the same time, users should enable the output).
GPIO_OUT: output status register
GPIO_Input_registers for input status
gpio parameter configuration with extra registers -> api uses macros for everything -> no pin magic
SAMD21 Cortex M0+ Datasheet page 339ff PORT IO PIN CONTROLLER
DIR INEN PULLEN OUT Configuration 0 0 0 X Reset or analog I/O: all digital disabled 0 0 1 0 Pull-down; input disabled 0 0 1 1 Pull-up; input disabled 0 1 0 X Input 0 1 1 0 Input with pull-down 0 1 1 1 Input with pull-up 1 0 X X Output; input disabled 1 1 X X Output; input enabled
nRF51 Reference Manual page 56ff: config registers for direction, drive strengh, pull-up and down resistors, pin sensing
Intel Curie Module (Quark SE C1000) Datasheet page 54: Separate data register bit and data direction control bit for each GPIO
Quark SE C1000 page 410 GPIO
Add the ability to use internal pull-up resistor for device search. Greatly reduces required components for the simple use case of detecting the presence of a DS1990 or similar unit