Minor syntax fixes for the 1-wire docs

This commit is contained in:
Marcel Stör 2016-01-17 14:05:41 +01:00
parent c7a40ea3ae
commit e86347acf3
2 changed files with 50 additions and 48 deletions

View File

@ -1,7 +1,9 @@
# onewire Module # 1-Wire Module
This module provides functions to work with the [1-Wire](https://en.wikipedia.org/wiki/1-Wire) device communications bus system.
## ow.check_crc16() ## ow.check_crc16()
Compute the 1-Wire CRC16 and compare it against the received CRC. Computes the 1-Wire CRC16 and compare it against the received CRC.
#### Syntax #### Syntax
`ow.check_crc16(buf, inverted_crc0, inverted_crc1[, crc])` `ow.check_crc16(buf, inverted_crc0, inverted_crc1[, crc])`
@ -13,10 +15,10 @@ Compute the 1-Wire CRC16 and compare it against the received CRC.
- `crc` CRC starting value (optional) - `crc` CRC starting value (optional)
#### Returns #### Returns
`bool` true, if the CRC matches; false for mismatch. true if the CRC matches, false otherwise
## ow.crc16() ## ow.crc16()
Compute a Dallas Semiconductor 16 bit CRC. This is required to check the integrity of data received from many 1-Wire devices. Note that the CRC computed here is **not** what you'll get from the 1-Wire network, for two reasons: Computes a Dallas Semiconductor 16 bit CRC. This is required to check the integrity of data received from many 1-Wire devices. Note that the CRC computed here is **not** what you'll get from the 1-Wire network, for two reasons:
1. The CRC is transmitted bitwise inverted. 1. The CRC is transmitted bitwise inverted.
2. Depending on the endian-ness of your processor, the binary representation of the two-byte return value may have a different byte order than the two bytes you get from 1-Wire. 2. Depending on the endian-ness of your processor, the binary representation of the two-byte return value may have a different byte order than the two bytes you get from 1-Wire.
@ -25,32 +27,32 @@ Compute a Dallas Semiconductor 16 bit CRC. This is required to check the integr
`ow.crc16(buf[, crc])` `ow.crc16(buf[, crc])`
#### Parameters #### Parameters
- `buf` string value, data to be calculated check sum in string. - `buf` string value, data to be calculated check sum in string
- `crc` CRC starting value (optional) - `crc` CRC starting value (optional)
#### Returns #### Returns
`crc16` the CRC16, as defined by Dallas Semiconductor. the CRC16 as defined by Dallas Semiconductor
## ow.crc8() ## ow.crc8()
Compute a Dallas Semiconductor 8 bit CRC, these are used in the ROM and scratchpad registers. Computes a Dallas Semiconductor 8 bit CRC, these are used in the ROM and scratchpad registers.
#### Syntax #### Syntax
`ow.crc8(buf)` `ow.crc8(buf)`
#### Parameters #### Parameters
`buf` string value, data to be calculated check sum in string. `buf` string value, data to be calculated check sum in string
#### Returns #### Returns
CRC result as byte. CRC result as byte
## ow.depower() ## ow.depower()
Stop forcing power onto the bus. You only need to do this if you used the 'power' flag to `ow.write()` or used a `ow.write_bytes()` and aren't about to do another read or write. Stops forcing power onto the bus. You only need to do this if you used the 'power' flag to `ow.write()` or used a `ow.write_bytes()` and aren't about to do another read or write.
#### Syntax #### Syntax
`ow.depower(pin)` `ow.depower(pin)`
#### Parameters #### Parameters
`pin` 1~12, IO index `pin` 1~12, I/O index
#### Returns #### Returns
`nil` `nil`
@ -60,63 +62,63 @@ Stop forcing power onto the bus. You only need to do this if you used the 'power
- [ow.write_bytes()](#owwrite_bytes) - [ow.write_bytes()](#owwrite_bytes)
## ow.read() ## ow.read()
Read a byte. Reads a byte.
####Syntax ####Syntax
`ow.read(pin)` `ow.read(pin)`
#### Parameters #### Parameters
`pin` 1~12, IO index `pin` 1~12, I/O index
#### Returns #### Returns
Byte read from slave device. byte read from slave device
## ow.read_bytes() ## ow.read_bytes()
Read multi bytes. Reads multi bytes.
#### Syntax #### Syntax
`ow.read_bytes(pin, size)` `ow.read_bytes(pin, size)`
#### Parameters #### Parameters
- `pin` 1~12, IO index - `pin` 1~12, I/O index
- `size` number of bytes to be read from slave device - `size` number of bytes to be read from slave device
#### Returns #### Returns
`string` bytes read from slave device `string` bytes read from slave device
## ow.reset() ## ow.reset()
Perform a 1-Wire reset cycle. Performs a 1-Wire reset cycle.
#### Syntax #### Syntax
`ow.reset(pin)` `ow.reset(pin)`
#### Parameters #### Parameters
`pin` 1~12, IO index `pin` 1~12, I/O index
#### Returns #### Returns
- `1` if a device responds with a presence pulse. - `1` if a device responds with a presence pulse
- `0` if there is no device or the bus is shorted or otherwise held low for more than 250 µS. - `0` if there is no device or the bus is shorted or otherwise held low for more than 250 µS
## ow.reset_search() ## ow.reset_search()
Clear the search state so that it will start from the beginning again. Clears the search state so that it will start from the beginning again.
#### Syntax #### Syntax
`ow.reset_search(pin)` `ow.reset_search(pin)`
#### Parameters #### Parameters
`pin` 1~12, IO index `pin` 1~12, I/O index
#### Returns #### Returns
`nil` `nil`
## ow.search() ## ow.search()
Look for the next device. Looks for the next device.
#### Syntax #### Syntax
`ow.search(pin)` `ow.search(pin)`
#### Parameters #### Parameters
`pin` 1~12, IO index `pin` 1~12, I/O index
#### Returns #### Returns
`rom_code` string with length of 8 upon success. It contains the rom code of slave device. Returns `nil` if search was unsuccessful. `rom_code` string with length of 8 upon success. It contains the rom code of slave device. Returns `nil` if search was unsuccessful.
@ -125,13 +127,13 @@ Look for the next device.
[ow.target_search()](#owtargetsearch) [ow.target_search()](#owtargetsearch)
## ow.select() ## ow.select()
Issue a 1-Wire rom select command. Make sure you do the `ow.reset(pin)` first. Issues a 1-Wire rom select command. Make sure you do the `ow.reset(pin)` first.
#### Syntax #### Syntax
`ow.select(pin, rom)` `ow.select(pin, rom)`
#### Parameters #### Parameters
- `pin` 1~12, IO index - `pin` 1~12, I/O index
- `rom` string value, len 8, rom code of the salve device - `rom` string value, len 8, rom code of the salve device
#### Returns #### Returns
@ -195,37 +197,37 @@ end
[ow.reset()](#owreset) [ow.reset()](#owreset)
## ow.setup() ## ow.setup()
Set a pin in onewire mode. Sets a pin in onewire mode.
#### Syntax #### Syntax
`ow.setup(pin)` `ow.setup(pin)`
#### Parameters #### Parameters
`pin` 1~12, IO index `pin` 1~12, I/O index
#### Returns #### Returns
`nil` `nil`
## ow.skip() ## ow.skip()
Issue a 1-Wire rom skip command, to address all on bus. Issues a 1-Wire rom skip command, to address all on bus.
#### Syntax #### Syntax
`ow.skip(pin)` `ow.skip(pin)`
#### Parameters #### Parameters
`pin` 1~12, IO index `pin` 1~12, I/O index
#### Returns #### Returns
`nil` `nil`
## ow.target_search() ## ow.target_search()
Set up the search to find the device type `family_code`. The search itself has to be initiated with a subsequent call to `ow.search()`. Sets up the search to find the device type `family_code`. The search itself has to be initiated with a subsequent call to `ow.search()`.
#### Syntax #### Syntax
`ow.target_search(pin, family_code)` `ow.target_search(pin, family_code)`
#### Parameters #### Parameters
- `pin` 1~12, IO index - `pin` 1~12, I/O index
- `family_code` byte for family code - `family_code` byte for family code
#### Returns #### Returns
@ -235,13 +237,13 @@ Set up the search to find the device type `family_code`. The search itself has t
[ow.search()](#owsearch) [ow.search()](#owsearch)
## ow.write() ## ow.write()
Write a byte. If `power` is 1 then the wire is held high at the end for parasitically powered devices. You are responsible for eventually depowering it by calling `ow.depower()` or doing another read or write. Writes a byte. If `power` is 1 then the wire is held high at the end for parasitically powered devices. You are responsible for eventually depowering it by calling `ow.depower()` or doing another read or write.
#### Syntax #### Syntax
`ow.write(pin, v, power)` `ow.write(pin, v, power)`
#### Parameters #### Parameters
- `pin` 1~12, IO index - `pin` 1~12, I/O index
- `v` byte to be written to salve device - `v` byte to be written to salve device
- `power` 1 for wire being held high for parasitically powered devices - `power` 1 for wire being held high for parasitically powered devices
@ -252,7 +254,7 @@ Write a byte. If `power` is 1 then the wire is held high at the end for parasiti
[ow.depower()](#owdepower) [ow.depower()](#owdepower)
## ow.write_bytes() ## ow.write_bytes()
Write multi bytes. If `power` is 1 then the wire is held high at the end for parasitically powered devices. You are responsible for eventually depowering it by calling `ow.depower()` or doing another read or write. Writes multi bytes. If `power` is 1 then the wire is held high at the end for parasitically powered devices. You are responsible for eventually depowering it by calling `ow.depower()` or doing another read or write.
#### Syntax #### Syntax
`ow.write_bytes(pin, buf, power)` `ow.write_bytes(pin, buf, power)`

View File

@ -46,7 +46,7 @@ pages:
- 'mqtt': 'en/modules/mqtt.md' - 'mqtt': 'en/modules/mqtt.md'
- 'net': 'en/modules/net.md' - 'net': 'en/modules/net.md'
- 'node': 'en/modules/node.md' - 'node': 'en/modules/node.md'
- 'ow': 'en/modules/ow.md' - 'ow (1-Wire)': 'en/modules/ow.md'
- 'pwm' : 'en/modules/pwm.md' - 'pwm' : 'en/modules/pwm.md'
- 'rtcmem': 'en/modules/rtcmem.md' - 'rtcmem': 'en/modules/rtcmem.md'
- 'rtctime': 'en/modules/rtctime.md' - 'rtctime': 'en/modules/rtctime.md'