OneWire Library for Arduino  version: 1.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
OneWire::DS248x Class Reference

Interface to the DS2484, DS2482-100, DS2482-101, DS2482-800 1-Wire masters. More...

#include <DS248x.h>

Inheritance diagram for OneWire::DS248x:
OneWire::OneWireMaster OneWire::DS2484

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...
 
- Public Types inherited from OneWire::OneWireMaster
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...
 
- Public Member Functions inherited from OneWire::OneWireMaster
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
 

Detailed Description

Interface to the DS2484, DS2482-100, DS2482-101, DS2482-800 1-Wire masters.

Member Enumeration Documentation

enum OneWire::DS248x::Command
protected
Enumerator
DeviceResetCmd 
WriteDeviceConfigCmd 
AdjustOwPortCmd 
ChannelSelectCmd 
SetReadPointerCmd 
OwResetCmd 
OwWriteByteCmd 
OwReadByteCmd 
OwSingleBitCmd 
OwTripletCmd 

Device register pointers.

Enumerator
ConfigReg 
StatusReg 
ReadDataReg 
PortConfigReg 
ChannelSelectReg 

Constructor & Destructor Documentation

DS248x::DS248x ( )

Default Constructor.

Member Function Documentation

OneWireMaster::CmdResult DS248x::begin ( uint8_t  i2cAdrs = 0x18)

Begin mbr function, creates Wire object

Parameters
[in]i2cAdrs- 7-bit slave adrs of master; default value is 0x18
OneWireMaster::CmdResult DS248x::configureLevel ( OWLevel  level)
protected

Ensure that the desired 1-Wire level is set in the configuration.

Parameters
levelDesired 1-Wire level.
Config OneWire::DS248x::currentConfig ( ) const
inline

Read the current DS248x configuration.

Returns
The cached current configuration.
void DS248x::end ( )

End mbr function.

OneWireMaster::CmdResult DS248x::OWInitMaster ( void  )
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.

OneWireMaster::CmdResult DS248x::OWReadByteSetLevel ( uint8_t &  recvByte,
OWLevel  afterLevel 
)
virtual

Receive one byte of communication and set a new level on the 1-Wire bus.

Parameters
recvByteBuffer to receive the data from the 1-Wire bus.
afterLevelLevel to set the 1-Wire bus to after communication.

Implements OneWire::OneWireMaster.

OneWireMaster::CmdResult DS248x::OWReset ( )
virtual

Reset all of the devices on the 1-Wire bus and check for a presence pulse.

Returns
OperationFailure if reset was performed but no presence pulse was detected.

Implements OneWire::OneWireMaster.

OneWireMaster::CmdResult DS248x::OWSetLevel ( OWLevel  newLevel)
virtual

Set the 1-Wire bus level.

Implements OneWire::OneWireMaster.

OneWireMaster::CmdResult DS248x::OWSetSpeed ( OWSpeed  newSpeed)
virtual

Set the 1-Wire bus communication speed.

Implements OneWire::OneWireMaster.

OneWireMaster::CmdResult DS248x::OWTouchBitSetLevel ( uint8_t &  sendRecvBit,
OWLevel  afterLevel 
)
virtual

Send and receive one bit of communication and set a new level on the 1-Wire bus.

Parameters
[in,out]sendRecvBitBuffer containing the bit to send on 1-Wire bus in lsb. Read data from 1-Wire bus will be returned in lsb.
afterLevelLevel to set the 1-Wire bus to after communication.

Implements OneWire::OneWireMaster.

OneWireMaster::CmdResult DS248x::OWTriplet ( SearchDirection searchDirection,
uint8_t &  sbr,
uint8_t &  tsb 
)
virtual
Note
Perform a 1-Wire triplet using the DS248x command.

Reimplemented from OneWire::OneWireMaster.

OneWireMaster::CmdResult DS248x::OWWriteByteSetLevel ( uint8_t  sendByte,
OWLevel  afterLevel 
)
virtual

Send one byte of communication and set a new level on the 1-Wire bus.

Parameters
sendByteByte to send on the 1-Wire bus.
afterLevelLevel to set the 1-Wire bus to after communication.

Implements OneWire::OneWireMaster.

OneWireMaster::CmdResult DS248x::pollBusy ( uint8_t *  pStatus = NULL)
protected

Polls the DS248x status waiting for the 1-Wire Busy bit (1WB) to be cleared.

Parameters
[out]pStatusOptionally retrive the status byte when 1WB cleared.
Returns
Success or TimeoutError if poll limit reached.
OneWireMaster::CmdResult DS248x::readRegister ( Register  reg,
uint8_t &  buf,
bool  skipSetPointer = false 
) const

Reads a register from the DS248x.

Parameters
regRegister to read from.
[out]bufBuffer to hold read data.
skipSetPointerAssume that the read pointer is already set to the correct register.
OneWireMaster::CmdResult DS248x::reset ( void  )

Performs a soft reset on the DS248x.

Note
This is note a 1-Wire Reset.
OneWireMaster::CmdResult DS248x::sendCommand ( Command  cmd) const
protected
Note
Allow marking const since not public.
OneWireMaster::CmdResult DS248x::sendCommand ( Command  cmd,
uint8_t  param 
) const
protected
Note
Allow marking const since not public.
OneWireMaster::CmdResult DS248x::writeConfig ( const Config config,
bool  verify 
)

Write a new configuration to the DS248x.

Parameters
[in]configNew configuration to write.
verifyVerify that the configuration was written successfully.

Member Data Documentation

uint8_t OneWire::DS248x::m_adrs
protected
Config OneWire::DS248x::m_curConfig
protected

The documentation for this class was generated from the following files: