1-wire library

Before I head down the path of trying to implement one, is there already a 1-wire library available?

thanks, jon

Hello, jrosennc.

I assume you are talking about this 1-Wire. No, we don’t have a Wixel library for that and I don’t know of any that are available. This sounds like a cool project, so let us know how it goes!


That’s the one…
I’ll give it a go and report back…

thanks, jon.

Did you get it working, Jon? I’m working on a waterproof sensor which I’ll lower into the water to take measurements (conductivity, temperature, and depth), and report back via radio. I’ll need a 1-Wire driver for the DS18B20.

I ported the Arduino OneWire library over. It’s in the SDK now.

Hm, I don’t see it here:
github.com/RussNelson/wixel-sdk … raries/src

Maybe you just forgot to push it?


I looked at making it a library as on the Arduino. However, the 8051 processor has no low-overhead way to write indirectly to ports. You can see this in the implementation of the GPIO library. Thus, I had to hard-code the port and bit into a #define. Blah. But I was thinking that a reasonable work-around is to create 24 different files (automagically, obviously), one for having a one-wire on each pin. Then you would include OneWire0, OneWire1, OneWire2, etc, using the same pin numbering enumeration as GPIO. There would be no code bloat, because only the one pin would get pulled in. The library would blow up in size, but who cares? Hard drive space on your PC is practically free.

The Arduino’s digitalWrite and digitalRead functions are typically used for manipulating a pin when you don’t know what the pin will be until runtime. You can use the Wixel’s GPIO functions to get the same effect. That’s how the Wixel’s i2c library was implemented. The Wixel’s setDigitalOutput function takes about 3.2 microseconds. Would that be good enough for you or can One-Wire benefit from high-speed communication?


Hey, Russ.

Another idea: If you need high speed communication and want the ability to select the pin number at run time, you can actually execute code from the CC2511’s RAM. Here’s an example of how to do that:

XDATA uint8 myfunc[] = {
  /** insert your compiled code here as a list of bytes **/
  0x22 // ret, returns to the calling function.

void main()
  __asm lcall _myfunc __endasm;

By putting the code in RAM, you make it easy to modify some parts of it at run time, for example the parts of it that read and write from the pin.