![]() |
OneWire Library for Arduino
version: 1.0.0
|
Interface to the DS2484, DS2482-100, DS2482-101, DS2482-800 1-Wire masters. More...
#include <DS248x.h>
Classes | |
class | Config |
Represents a DS248x configuration. More... | |
Public Types | |
enum | Register { ConfigReg = 0xC3, StatusReg = 0xF0, ReadDataReg = 0xE1, PortConfigReg = 0xB4, ChannelSelectReg = 0xD2 } |
Device register pointers. More... | |
![]() | |
enum | OWSpeed { StandardSpeed = 0x00, OverdriveSpeed = 0x01 } |
Speed of the 1-Wire bus. More... | |
enum | OWLevel { NormalLevel = 0x00, StrongLevel = 0x02 } |
Level of the 1-Wire bus. More... | |
enum | SearchDirection { WriteZero = 0, WriteOne = 1 } |
Search direction for the triplet operation. More... | |
enum | CmdResult { Success, CommunicationWriteError, CommunicationReadError, TimeoutError, OperationFailure } |
Result of all 1-Wire commands. More... | |
Public Member Functions | |
DS248x () | |
Default Constructor. More... | |
OneWireMaster::CmdResult | begin (uint8_t i2cAdrs=0x18) |
void | end () |
End mbr function. More... | |
OneWireMaster::CmdResult | reset (void) |
OneWireMaster::CmdResult | writeConfig (const Config &config, bool verify) |
Config | currentConfig () const |
OneWireMaster::CmdResult | readRegister (Register reg, uint8_t &buf, bool skipSetPointer=false) const |
virtual OneWireMaster::CmdResult | OWInitMaster () |
virtual OneWireMaster::CmdResult | OWTriplet (SearchDirection &searchDirection, uint8_t &sbr, uint8_t &tsb) |
virtual OneWireMaster::CmdResult | OWReset () |
virtual OneWireMaster::CmdResult | OWTouchBitSetLevel (uint8_t &sendRecvBit, OWLevel afterLevel) |
virtual OneWireMaster::CmdResult | OWReadByteSetLevel (uint8_t &recvByte, OWLevel afterLevel) |
virtual OneWireMaster::CmdResult | OWWriteByteSetLevel (uint8_t sendByte, OWLevel afterLevel) |
virtual OneWireMaster::CmdResult | OWSetSpeed (OWSpeed newSpeed) |
Set the 1-Wire bus communication speed. More... | |
virtual OneWireMaster::CmdResult | OWSetLevel (OWLevel newLevel) |
Set the 1-Wire bus level. More... | |
![]() | |
virtual | ~OneWireMaster () |
Allow freeing through a base class pointer. More... | |
virtual CmdResult | OWWriteBlock (const uint8_t *sendBuf, uint8_t sendLen) |
virtual CmdResult | OWReadBlock (uint8_t *recvBuf, uint8_t recvLen) |
CmdResult | OWWriteBitSetLevel (uint8_t sendBit, OWLevel afterLevel) |
CmdResult | OWReadBitSetLevel (uint8_t &recvBit, OWLevel afterLevel) |
CmdResult | OWWriteBit (uint8_t sendBit) |
CmdResult | OWReadBit (uint8_t &recvBit) |
CmdResult | OWWriteBitPower (uint8_t sendBit) |
CmdResult | OWReadBitPower (uint8_t &recvBit) |
CmdResult | OWWriteByte (uint8_t sendByte) |
CmdResult | OWReadByte (uint8_t &recvByte) |
CmdResult | OWWriteBytePower (uint8_t sendByte) |
CmdResult | OWReadBytePower (uint8_t &recvByte) |
Protected Types | |
enum | Command { DeviceResetCmd = 0xF0, WriteDeviceConfigCmd = 0xD2, AdjustOwPortCmd = 0xC3, ChannelSelectCmd = 0xC3, SetReadPointerCmd = 0xE1, OwResetCmd = 0xB4, OwWriteByteCmd = 0xA5, OwReadByteCmd = 0x96, OwSingleBitCmd = 0x87, OwTripletCmd = 0x78 } |
Protected Member Functions | |
OneWireMaster::CmdResult | pollBusy (uint8_t *pStatus=NULL) |
OneWireMaster::CmdResult | configureLevel (OWLevel level) |
OneWireMaster::CmdResult | sendCommand (Command cmd) const |
OneWireMaster::CmdResult | sendCommand (Command cmd, uint8_t param) const |
Protected Attributes | |
uint8_t | m_adrs |
Config | m_curConfig |
Interface to the DS2484, DS2482-100, DS2482-101, DS2482-800 1-Wire masters.
|
protected |
DS248x::DS248x | ( | ) |
Default Constructor.
OneWireMaster::CmdResult DS248x::begin | ( | uint8_t | i2cAdrs = 0x18 | ) |
Begin mbr function, creates Wire object
[in] | i2cAdrs | - 7-bit slave adrs of master; default value is 0x18 |
|
protected |
Ensure that the desired 1-Wire level is set in the configuration.
level | Desired 1-Wire level. |
|
inline |
Read the current DS248x configuration.
void DS248x::end | ( | ) |
End mbr function.
|
virtual |
Performs a device reset followed by writing the configuration byte to default values: 1-Wire Speed Standard Strong Pullup Off 1-Wire Powerdown Off Active Pullup On
Implements OneWire::OneWireMaster.
|
virtual |
Receive one byte of communication and set a new level on the 1-Wire bus.
recvByte | Buffer to receive the data from the 1-Wire bus. |
afterLevel | Level to set the 1-Wire bus to after communication. |
Implements OneWire::OneWireMaster.
|
virtual |
Reset all of the devices on the 1-Wire bus and check for a presence pulse.
Implements OneWire::OneWireMaster.
|
virtual |
Set the 1-Wire bus level.
Implements OneWire::OneWireMaster.
|
virtual |
Set the 1-Wire bus communication speed.
Implements OneWire::OneWireMaster.
|
virtual |
Send and receive one bit of communication and set a new level on the 1-Wire bus.
[in,out] | sendRecvBit | Buffer containing the bit to send on 1-Wire bus in lsb. Read data from 1-Wire bus will be returned in lsb. |
afterLevel | Level to set the 1-Wire bus to after communication. |
Implements OneWire::OneWireMaster.
|
virtual |
Reimplemented from OneWire::OneWireMaster.
|
virtual |
Send one byte of communication and set a new level on the 1-Wire bus.
sendByte | Byte to send on the 1-Wire bus. |
afterLevel | Level to set the 1-Wire bus to after communication. |
Implements OneWire::OneWireMaster.
|
protected |
Polls the DS248x status waiting for the 1-Wire Busy bit (1WB) to be cleared.
[out] | pStatus | Optionally retrive the status byte when 1WB cleared. |
OneWireMaster::CmdResult DS248x::readRegister | ( | Register | reg, |
uint8_t & | buf, | ||
bool | skipSetPointer = false |
||
) | const |
Reads a register from the DS248x.
reg | Register to read from. | |
[out] | buf | Buffer to hold read data. |
skipSetPointer | Assume that the read pointer is already set to the correct register. |
OneWireMaster::CmdResult DS248x::reset | ( | void | ) |
Performs a soft reset on the DS248x.
|
protected |
|
protected |
OneWireMaster::CmdResult DS248x::writeConfig | ( | const Config & | config, |
bool | verify | ||
) |
Write a new configuration to the DS248x.
[in] | config | New configuration to write. |
verify | Verify that the configuration was written successfully. |
|
protected |
|
protected |