The 1-Wire protocol was developed by Dallas Semiconductor to communicate with chips using a single signalling line.
There are four commands that you can use:
ONEWIRE RESET pin Reset the 1-Wire bus
ONEWIRE WRITE pin, flag, length, data [, data…] Send a number of bytes
ONEWIRE READ pin, flag, length, data [, data…] Get a number of bytes
OWSEARCH pin, srchflag, ser [,ser…]
Where:
pin – The Maximite I/O pin to use. It can be any pin capable of digital I/O.
flag – A combination of the following options:
1 – Send reset before command
2 – Send reset after command
4 – Only send/recv a bit instead of a byte of data
8 – Invoke a strong pullup after the command (the pin will be set high and open drain disabled)
length – Length of data to send or receive
data – Data to send or receive. The number of data items must agree with the length parameter.
srchflag – a combination of the following options:
1 – start a new search
2 – only return devices in alarm state
4 – search for devices in the requested family (first byte of ser)
8 – skip the current device family and return the next device
16 – verify that the device with the serial number in ser is available
If srchflag = 0 (or 2) then the search will return the next device found
ser – serial number (8 bytes) will be returned (srchflag 4 and 16 will also use the values in ser)
After the command is executed, the I/O pin will be set to the not configured state unless flag option 8 is used.
When a reset is requested the automatic variable MM.ONEWIRE will return true if a device was found. This will occur with the OW RESET command and the OW READ and OW WRITE commands if a reset was requested (flag = 1 or 2).
Information from Geoff Graham http://geoffg.net This implementation was written for MMBasic by Gerard Sexton.
Leave a Reply