Behaviours: gen_server
.
Driver API for the DS2482-100 Single-Channel 1-Wire Master .
The functions in this module refer to the function commands documented in the masters data sheet . Each function has a hexadecimal command code that is referenced in the specification sheet.bus_reset/0 | Reset the bus and check the register for devices. |
detect/0 | Reset device and activate active pullup (APU). |
read_byte/0 | Read one data byte from the 1-Wire line. |
reset/0 | Reset the 1-Wire Master and terminate any ongoing 1-Wire communication. |
search/0 | Search the bus for devices. |
transaction/1 | Run a 1-Wire transaction. |
write_byte/1 | Write one data byte to the 1-Wire line. |
write_config/1 | Write configuration into 1-Wire master register. |
bus_reset() -> nothing_present | presence_detected | short_detected
Reset the bus and check the register for devices.
This function can only be used inside of a transaction/1
call.
Atom | Description |
---|---|
nothing_present | No device on the bus detected |
presence_detected | Some devices on the bus detected |
short_detected | A short circuit between data and ground on the bus detected |
b4h
.
detect() -> ok
Reset device and activate active pullup (APU).
This function can only be used inside of atransaction/1
call.
See also: reset/0, write_config/1.
read_byte() -> any()
Read one data byte from the 1-Wire line.
This function can only be used inside of a transaction/1
call.
96h
, e1h
reset() -> ok
Reset the 1-Wire Master and terminate any ongoing 1-Wire communication.
This function can only be used inside of a transaction/1
call.
f0h
.
search() -> fail | nothing_present | short_detected | [[byte()]]
Search the bus for devices.
This function can only be used inside of a transaction/1
call.
If there are connected devices, i.e., bus_reset/0
returns
presence_detected
, this function provides a list of the unique 64-bit
addresses of all detected devices.
Otherwise, the return values match the values from bus_reset/0
or
fail
for other failures during the search.
The addresses are represented as lists of eight byte values.
1> grisp_onewire:transaction(fun grisp_onewire:search/0). [[40,255,203,173,80,23,4,182], [40,255,67,77,96,23,5,138], [40,255,190,25,96,23,3,203], [40,255,54,42,96,23,5,35], [40,255,18,91,96,23,3,62]]
transaction(Fun::function()) -> any()
Run a 1-Wire transaction.
Use this function to make sure that there is only one process running on the 1-Wire.
2> grisp_onewire:transaction(fun() -> presence_detected = grisp_onewire:bus_reset(), grisp_onewire:write_byte(16#cc) end). ok
write_byte(Byte::integer()) -> ok
Write one data byte to the 1-Wire line.
This function can only be used inside of a transaction/1
call.
a5h
write_config(Conf::[apu | overdrive | spu] | integer()) -> ok
Write configuration into 1-Wire master register.
This function can only be used inside of a transaction/1
call.
The default configuration is 0
, i.e., all three configurable bits set to
0
. This corresponds to an empty list. Each atom in the list activates the
corresponding configuration (sets the bit to 1
) and each atom not present in
the list leads to a deactivation (sets the bit to 0
).
Atom | Integer | Configuration Bit | Activates |
---|---|---|---|
apu | 1 | Bit 0 (APU) | Active pullup |
spu | 4 | Bit 2 (SPU) | Strong pullup |
overdrive | 8 | Bit 3 (1WS) | 1-Wire overdrive speed |
3> grisp_onewire:transaction(fun() -> grisp_onewire:write_config([apu, overdrive]) end). okThis is the same as:
4> grisp_onewire:transaction(fun() -> grisp_onewire:write_config(1 bor 8) end). okCommand code:
d2h
.
Generated by EDoc