1-wire bitbanging
Contents
One wire overview and bitbanging
TL;DR
This text is about 1-wire bus.
On physical layer it's made of GND and data line (parasitic powering); It might also contain a separate power source.
The speeds reach up to 16kbps in normal mode, and 142kbps in overdrive.
1-wire is also called iButton. It's basically the same thing.
Use a pull-up of 1-5k.
Link layer
I will only mention regular speed, overdrive is similar, only timings are different.
Line is driven high by a pull-up, so master and slave basically only signal zeroes.
Reset pulse
Reset puts the device into predefined state. It's just a 480us+ low pulse followed by 480us+ high in which time devices mark their presence.
Write 0
This is a 60-120us long low pulse followed by 1us+ high pulse
Write 1 / Read from slave
Write of one is the same as read from slave (slave shorts the line, when it wants to signal 0). Data starts with 1-15us low pulse, after which it's the slave's turn. Whole bit lasts 60-120us, and is followed by 1us+ high pulse, like in "Write 0" cycle.
See standard for details, under "Read Time Slots".
Network layer
Read/Write byte
Read or write is just eight read or write bit commands. All data is transferred LSb first.
Device discovery
First lets define the term triplet. Triplet is two read bit slots followed by one write bit.
Device ID's are 64-bit long, composed of family id (first 8 bits), unique id for that family, and crc8 (reversed, with polynomial 0x131, last 8 bits).
For discovery master will send SEARCH ROM command and generate 64 triplets. It has to do that for every discovered device, with resets in between. In the read slots devices respond with their address bit and negated address bit. The write slot is for master to select devices which match it - the devices that don't match it will deactivate until next reset.
For responses from devices there are four possibilities:
- 0 0 - two devices answered and they have different bit on current place in address field. Master selects which device to activate/deactivate. - 0 1 - all devices have 0 in that place in address. Master will want to write 0 here, or all devices are deactivated. - 1 0 - all devices have 1 in that place in address. Master will want to write 1 here, or all devices are deactivated. - 1 1 - bus error. Ie. no devices on bus.
References
Book of iButton standards: http://www.maxim-ic.com/app-notes/index.mvp/id/937