1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.

Dependents:   MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more

Embed: (wiki syntax)

« Back to documentation index

DS2465 Class Reference

Interface to the DS2465 1-Wire master and SHA-256 coprocessor. More...

#include <DS2465.h>

Inherits OneWire::OneWireMaster, and OneWire::ISha256MacCoproc.

Data Structures

class  Config
 Represents a DS2465 configuration. More...

Public Types

enum  PageRegion
 

Page region to use for swapping.

More...
enum  MemoryAddress
 

Starting memory addresses.

More...
enum  OWSpeed
 

Speed of the 1-Wire bus.

More...
enum  OWLevel
 

Level of the 1-Wire bus.

More...
enum  SearchDirection
 

Search direction for the triplet operation.

More...
enum  CmdResult
 

Result of all 1-Wire commands.

More...
typedef array< uint8_t, 32 > DevicePage
 Holds the contents of a device memory page.
typedef array< uint8_t, 32 > DeviceScratchpad
 Holds the contents of a device scratchpad.
typedef array< uint8_t, 32 > Secret
 Holds the contents of a device secret.
typedef array< uint8_t, 32 > Mac
 Container for a SHA-256 MAC.
typedef array< uint8_t, 20 > WriteMacData
 Additional data fields for Compute Write MAC operation.
typedef array< uint8_t, 12 > AuthMacData
 Additional data fields for the Compute Auth. MAC operation.
typedef array< uint8_t, 12 > SlaveSecretData
 Additional data field for the Compute Slave Secret operation.

Public Member Functions

 DS2465 (mbed::I2C &I2C_interface, uint8_t I2C_address=0x30)
OneWireMaster::CmdResult reset ()
 Performs a soft reset on the DS2465.
OneWireMaster::CmdResult writeConfig (const Config &config, bool verify)
 Write a new configuration to the DS2465.
Config currentConfig () const
 Read the current DS2465 configuration.
OneWireMaster::CmdResult readMemory (uint8_t addr, uint8_t *buf, size_t bufLen, bool skipSetPointer=false) const
 Read memory from the DS2465.
OneWireMaster::CmdResult writeMemory (uint8_t addr, const uint8_t *buf, size_t bufLen)
 Write to SRAM memory on the DS2465.
OneWireMaster::CmdResult writeScratchpad (const uint8_t *buf, size_t bufLen) const
 Write data to the scratchpad area of the DS2465.
OneWireMaster::CmdResult copyScratchpadToPage (unsigned int pageNum)
 Copy the scratchpad contents to an EEPROM memory page.
OneWireMaster::CmdResult copyScratchpadToSegment (unsigned int pageNum, unsigned int segmentNum)
 Copy the scratchpad contents to an EEPROM memory segment.
OneWireMaster::CmdResult copyScratchpadToSecret ()
 Copy the scratchpad contents to the secret EEPROM memory page.
virtual OneWireMaster::CmdResult OWInitMaster ()
 Initialize a master for use.
virtual OneWireMaster::CmdResult OWReset ()
 Reset all of the devices on the 1-Wire bus and check for a presence pulse.
virtual OneWireMaster::CmdResult OWTouchBitSetLevel (uint8_t &sendRecvBit, OWLevel afterLevel)
 Send and receive one bit of communication and set a new level on the 1-Wire bus.
virtual OneWireMaster::CmdResult OWReadByteSetLevel (uint8_t &recvByte, OWLevel afterLevel)
 Receive one byte of communication and set a new level on the 1-Wire bus.
virtual OneWireMaster::CmdResult OWWriteByteSetLevel (uint8_t sendByte, OWLevel afterLevel)
 Send one byte of communication and set a new level on the 1-Wire bus.
virtual OneWireMaster::CmdResult OWReadBlock (uint8_t *recvBuf, size_t recvLen)
 Receive a block of communication on the 1-Wire bus.
virtual OneWireMaster::CmdResult OWWriteBlock (const uint8_t *sendBuf, size_t sendLen)
 Send a block of communication on the 1-Wire bus.
virtual OneWireMaster::CmdResult OWSetSpeed (OWSpeed newSpeed)
 Set the 1-Wire bus communication speed.
virtual OneWireMaster::CmdResult OWSetLevel (OWLevel newLevel)
virtual OneWireMaster::CmdResult OWTriplet (SearchDirection &searchDirection, uint8_t &sbr, uint8_t &tsb)
 1-Wire Triplet operation.
OneWireMaster::CmdResult OWWriteBlockMac ()
 Write the last computed MAC to the 1-Wire bus.
OneWireMaster::CmdResult computeNextMasterSecret ()
 Compute Next Master Secret with scratchpad data.
OneWireMaster::CmdResult computeNextMasterSecretSwap (unsigned int pageNum, PageRegion region)
 Compute Next Master Secret with page swapping.
OneWireMaster::CmdResult computeWriteMac (bool regwrite) const
 Compute Write MAC with scratchpad data.
OneWireMaster::CmdResult computeWriteMacSwap (bool regwrite, unsigned int pageNum, unsigned int segmentNum) const
 Compute Write MAC with page swapping.
OneWireMaster::CmdResult computeSlaveSecret ()
 Compute Slave Secret (S-Secret) with scratchpad data.
OneWireMaster::CmdResult computeSlaveSecretSwap (unsigned int pageNum, PageRegion region)
 Compute Slave Secret (S-Secret) with page swapping.
OneWireMaster::CmdResult computeAuthMac () const
 Compute Authentication MAC with scratchpad data.
OneWireMaster::CmdResult computeAuthMacSwap (unsigned int pageNum, PageRegion region) const
 Compute Authentication MAC with page swapping.
virtual ISha256MacCoproc::CmdResult setMasterSecret (const Secret &masterSecret)
 Set Master Secret in coprocessor.
virtual ISha256MacCoproc::CmdResult computeSlaveSecret (const DevicePage &devicePage, const DeviceScratchpad &deviceScratchpad, const SlaveSecretData &slaveSecretData)
 Compute Slave Secret in the coprocessor.
virtual ISha256MacCoproc::CmdResult computeWriteMac (const WriteMacData &writeMacData, Mac &mac) const
 Compute Write MAC.
virtual ISha256MacCoproc::CmdResult computeAuthMac (const DevicePage &devicePage, const DeviceScratchpad &challenge, const AuthMacData &authMacData, Mac &mac) const
 Compute Authentication MAC.
CmdResult OWWriteBitSetLevel (uint8_t sendBit, OWLevel afterLevel)
 Send one bit of communication and set a new level on the 1-Wire bus.
CmdResult OWReadBitSetLevel (uint8_t &recvBit, OWLevel afterLevel)
 Receive one bit of communication and set a new level on the 1-Wire bus.

Static Public Attributes

static const unsigned int eepromSegmentWriteDelayMs = 10
 Delay required after writing an EEPROM segment.
static const unsigned int eepromPageWriteDelayMs = 8 * eepromSegmentWriteDelayMs
 Delay required after writing an EEPROM page such as the secret memory.
static const unsigned int shaComputationDelayMs = 2
 Delay required for a SHA computation to complete.

Detailed Description

Interface to the DS2465 1-Wire master and SHA-256 coprocessor.

Definition at line 44 of file DS2465.h.


Member Typedef Documentation

typedef array<uint8_t, 12> AuthMacData [inherited]

Additional data fields for the Compute Auth. MAC operation.

Definition at line 68 of file ISha256MacCoproc.h.

typedef array<uint8_t, 32> DevicePage [inherited]

Holds the contents of a device memory page.

Definition at line 53 of file ISha256MacCoproc.h.

typedef array<uint8_t, 32> DeviceScratchpad [inherited]

Holds the contents of a device scratchpad.

Definition at line 56 of file ISha256MacCoproc.h.

typedef array<uint8_t, 32> Mac [inherited]

Container for a SHA-256 MAC.

Definition at line 62 of file ISha256MacCoproc.h.

typedef array<uint8_t, 32> Secret [inherited]

Holds the contents of a device secret.

Definition at line 59 of file ISha256MacCoproc.h.

typedef array<uint8_t, 12> SlaveSecretData [inherited]

Additional data field for the Compute Slave Secret operation.

Definition at line 71 of file ISha256MacCoproc.h.

typedef array<uint8_t, 20> WriteMacData [inherited]

Additional data fields for Compute Write MAC operation.

Definition at line 65 of file ISha256MacCoproc.h.


Member Enumeration Documentation

enum CmdResult [inherited]

Result of all 1-Wire commands.

Definition at line 67 of file OneWireMaster.h.

Starting memory addresses.

Definition at line 63 of file DS2465.h.

enum OWLevel [inherited]

Level of the 1-Wire bus.

Definition at line 53 of file OneWireMaster.h.

enum OWSpeed [inherited]

Speed of the 1-Wire bus.

Definition at line 46 of file OneWireMaster.h.

enum PageRegion

Page region to use for swapping.

Definition at line 55 of file DS2465.h.

enum SearchDirection [inherited]

Search direction for the triplet operation.

Definition at line 60 of file OneWireMaster.h.


Constructor & Destructor Documentation

DS2465 ( mbed::I2C &  I2C_interface,
uint8_t  I2C_address = 0x30 
)
Parameters:
I2C_interfaceConfigured I2C communication interface for DS2465.
I2C_addressI2C bus address of the DS2465 in mbed format.

Definition at line 114 of file DS2465.cpp.


Member Function Documentation

OneWireMaster::CmdResult computeAuthMac (  ) const

Compute Authentication MAC with scratchpad data.

Definition at line 220 of file DS2465.h.

ISha256MacCoproc::CmdResult computeAuthMac ( const DevicePage devicePage,
const DeviceScratchpad challenge,
const AuthMacData authMacData,
Mac mac 
) const [virtual]

Compute Authentication MAC.

Note:
Uses the previously computed Slave Secret in computation.
Parameters:
[in]devicePagePage data stored on device.
[in]challegeRandom challenge for device.
[in]authMacDataAdditional data fields as specified by device.
[out]macThe computed MAC.

Implements ISha256MacCoproc.

Definition at line 195 of file DS2465.cpp.

OneWireMaster::CmdResult computeAuthMacSwap ( unsigned int  pageNum,
PageRegion  region 
) const

Compute Authentication MAC with page swapping.

Parameters:
pageNumPage number to swap in.
regionRegion of the page to swap in.

Definition at line 225 of file DS2465.h.

OneWireMaster::CmdResult computeNextMasterSecret (  )

Compute Next Master Secret with scratchpad data.

Definition at line 194 of file DS2465.h.

OneWireMaster::CmdResult computeNextMasterSecretSwap ( unsigned int  pageNum,
PageRegion  region 
)

Compute Next Master Secret with page swapping.

Parameters:
pageNumPage number to swap in.
regionRegion of the page to swap in.

Definition at line 199 of file DS2465.h.

OneWireMaster::CmdResult computeSlaveSecret (  )

Compute Slave Secret (S-Secret) with scratchpad data.

Definition at line 212 of file DS2465.h.

ISha256MacCoproc::CmdResult computeSlaveSecret ( const DevicePage devicePage,
const DeviceScratchpad deviceScratchpad,
const SlaveSecretData slaveSecretData 
) [virtual]

Compute Slave Secret in the coprocessor.

Note:
Uses the previously set Master Secret in computation.
Parameters:
[in]devicePagePage data stored on device.
[in]deviceScratchpadScratchpad data stored on device.
[in]slaveSecretDataAdditional data fields as specified by device.

Implements ISha256MacCoproc.

Definition at line 225 of file DS2465.cpp.

OneWireMaster::CmdResult computeSlaveSecretSwap ( unsigned int  pageNum,
PageRegion  region 
)

Compute Slave Secret (S-Secret) with page swapping.

Parameters:
pageNumPage number to swap in.
regionRegion of the page to swap in.

Definition at line 217 of file DS2465.h.

OneWireMaster::CmdResult computeWriteMac ( bool  regwrite ) const

Compute Write MAC with scratchpad data.

Parameters:
regwriteTrue if writing to a register or false if regular memory.

Definition at line 203 of file DS2465.h.

ISha256MacCoproc::CmdResult computeWriteMac ( const WriteMacData writeMacData,
Mac mac 
) const [virtual]

Compute Write MAC.

Note:
Uses the previously computed Slave Secret in computation.
Parameters:
[in]writeMacDataAdditional data fields as specified by device.
[out]macThe computed MAC.

Implements ISha256MacCoproc.

Definition at line 176 of file DS2465.cpp.

OneWireMaster::CmdResult computeWriteMacSwap ( bool  regwrite,
unsigned int  pageNum,
unsigned int  segmentNum 
) const

Compute Write MAC with page swapping.

Parameters:
regwriteTrue if writing to a register or false if regular memory.
pageNumPage number to swap in.
segmentNumSegment number to swap in.

Definition at line 209 of file DS2465.h.

OneWireMaster::CmdResult copyScratchpadToPage ( unsigned int  pageNum )

Copy the scratchpad contents to an EEPROM memory page.

Parameters:
pageNumPage number to copy to.

Definition at line 165 of file DS2465.h.

OneWireMaster::CmdResult copyScratchpadToSecret (  )

Copy the scratchpad contents to the secret EEPROM memory page.

Definition at line 173 of file DS2465.h.

OneWireMaster::CmdResult copyScratchpadToSegment ( unsigned int  pageNum,
unsigned int  segmentNum 
)

Copy the scratchpad contents to an EEPROM memory segment.

Parameters:
pageNumPage number to copy to.
segmentNumSegment number to copy to.

Definition at line 170 of file DS2465.h.

Config currentConfig (  ) const

Read the current DS2465 configuration.

Returns:
The cached current configuration.

Definition at line 141 of file DS2465.h.

OneWireMaster::CmdResult OWInitMaster (  ) [virtual]

Initialize a master for use.

Implements OneWireMaster.

Definition at line 120 of file DS2465.cpp.

CmdResult OWReadBitSetLevel ( uint8_t &  recvBit,
OWLevel  afterLevel 
) [inherited]

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

Parameters:
[out]sendRecvBitRead data from 1-Wire bus will be returned in lsb.
afterLevelLevel to set the 1-Wire bus to after communication.

Definition at line 143 of file OneWireMaster.h.

OneWireMaster::CmdResult OWReadBlock ( uint8_t *  recvBuf,
size_t  recvLen 
) [virtual]

Receive a block of communication on the 1-Wire bus.

Parameters:
[out]recvBufBuffer to receive the data from the 1-Wire bus.
recvLenLength of the buffer to receive.

Reimplemented from OneWireMaster.

Definition at line 328 of file DS2465.cpp.

OneWireMaster::CmdResult 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 OneWireMaster.

Definition at line 394 of file DS2465.cpp.

OneWireMaster::CmdResult 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 OneWireMaster.

Definition at line 630 of file DS2465.cpp.

OneWireMaster::CmdResult OWSetLevel ( OWLevel  newLevel ) [virtual]
Note:
The DS2465 only supports enabling strong pullup following a 1-Wire read or write operation.

Implements OneWireMaster.

Definition at line 275 of file DS2465.cpp.

OneWireMaster::CmdResult OWSetSpeed ( OWSpeed  newSpeed ) [virtual]

Set the 1-Wire bus communication speed.

Implements OneWireMaster.

Definition at line 285 of file DS2465.cpp.

OneWireMaster::CmdResult 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 OneWireMaster.

Definition at line 463 of file DS2465.cpp.

OneWireMaster::CmdResult OWTriplet ( SearchDirection searchDirection,
uint8_t &  sbr,
uint8_t &  tsb 
) [virtual]

1-Wire Triplet operation.

Perform one bit of a 1-Wire search. This command does two read bits and one write bit. The write bit is either the default direction (all device have same bit) or in case of a discrepancy, the 'searchDirection' parameter is used.

Parameters:
[in,out]searchDirectionInput with desired direction in case both read bits are zero. Output with direction taken based on read bits.
[out]sbrBit result of first read operation.
[out]tsbBit result of second read operation.

Reimplemented from OneWireMaster.

Definition at line 301 of file DS2465.cpp.

CmdResult OWWriteBitSetLevel ( uint8_t  sendBit,
OWLevel  afterLevel 
) [inherited]

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

Parameters:
sendBitBuffer containing the bit to send on 1-Wire bus in lsb.
afterLevelLevel to set the 1-Wire bus to after communication.

Definition at line 138 of file OneWireMaster.h.

OneWireMaster::CmdResult OWWriteBlock ( const uint8_t *  sendBuf,
size_t  sendLen 
) [virtual]

Send a block of communication on the 1-Wire bus.

Parameters:
[in]sendBufBuffer to send on the 1-Wire bus.
sendLenLength of the buffer to send.

Reimplemented from OneWireMaster.

Definition at line 352 of file DS2465.cpp.

OneWireMaster::CmdResult OWWriteBlockMac (  )

Write the last computed MAC to the 1-Wire bus.

Definition at line 378 of file DS2465.cpp.

OneWireMaster::CmdResult 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 OneWireMaster.

Definition at line 435 of file DS2465.cpp.

OneWireMaster::CmdResult readMemory ( uint8_t  addr,
uint8_t *  buf,
size_t  bufLen,
bool  skipSetPointer = false 
) const

Read memory from the DS2465.

Parameters:
addrAddress to begin reading from.
[out]bufBuffer to hold read data.
bufLenLength of buffer, buf, and number of bytes to read.
skipSetPointerAssume that the read pointer is already set to the correct address.

Definition at line 533 of file DS2465.cpp.

Performs a soft reset on the DS2465.

Note:
This is not a 1-Wire Reset.

Definition at line 661 of file DS2465.cpp.

ISha256MacCoproc::CmdResult setMasterSecret ( const Secret masterSecret ) [virtual]

Set Master Secret in coprocessor.

Parameters:
[in]masterSecretNew master secret to set.

Implements ISha256MacCoproc.

Definition at line 161 of file DS2465.cpp.

OneWireMaster::CmdResult writeConfig ( const Config config,
bool  verify 
)

Write a new configuration to the DS2465.

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

Definition at line 574 of file DS2465.cpp.

OneWireMaster::CmdResult writeMemory ( uint8_t  addr,
const uint8_t *  buf,
size_t  bufLen 
)

Write to SRAM memory on the DS2465.

Parameters:
addrAddress to begin writing to.
[in]bufBuffer containing the data to write.
bufLenLength of buffer, buf, and number of bytes to write.

Definition at line 156 of file DS2465.h.

OneWireMaster::CmdResult writeScratchpad ( const uint8_t *  buf,
size_t  bufLen 
) const

Write data to the scratchpad area of the DS2465.

Parameters:
[in]bufBuffer containing the data to write.
bufLenLength of buffer, buf, and the number of bytes to write.

Definition at line 161 of file DS2465.h.


Field Documentation

const unsigned int eepromPageWriteDelayMs = 8 * eepromSegmentWriteDelayMs [static]

Delay required after writing an EEPROM page such as the secret memory.

Definition at line 50 of file DS2465.h.

const unsigned int eepromSegmentWriteDelayMs = 10 [static]

Delay required after writing an EEPROM segment.

Definition at line 48 of file DS2465.h.

const unsigned int shaComputationDelayMs = 2 [static]

Delay required for a SHA computation to complete.

Definition at line 52 of file DS2465.h.