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
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.
Container for a SHA-256 MAC.
Definition at line 62 of file ISha256MacCoproc.h.
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.
enum MemoryAddress |
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 |
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_interface Configured I2C communication interface for DS2465. I2C_address I2C bus address of the DS2465 in mbed format.
Definition at line 114 of file DS2465.cpp.
Member Function Documentation
OneWireMaster::CmdResult computeAuthMac | ( | ) | const |
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] devicePage Page data stored on device. [in] challege Random challenge for device. [in] authMacData Additional data fields as specified by device. [out] mac The computed MAC.
Implements ISha256MacCoproc.
Definition at line 195 of file DS2465.cpp.
OneWireMaster::CmdResult computeAuthMacSwap | ( | unsigned int | pageNum, |
PageRegion | region | ||
) | const |
OneWireMaster::CmdResult computeNextMasterSecret | ( | ) |
OneWireMaster::CmdResult computeNextMasterSecretSwap | ( | unsigned int | pageNum, |
PageRegion | region | ||
) |
OneWireMaster::CmdResult computeSlaveSecret | ( | ) |
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] devicePage Page data stored on device. [in] deviceScratchpad Scratchpad data stored on device. [in] slaveSecretData Additional data fields as specified by device.
Implements ISha256MacCoproc.
Definition at line 225 of file DS2465.cpp.
OneWireMaster::CmdResult computeSlaveSecretSwap | ( | unsigned int | pageNum, |
PageRegion | region | ||
) |
OneWireMaster::CmdResult computeWriteMac | ( | bool | regwrite ) | const |
ISha256MacCoproc::CmdResult computeWriteMac | ( | const WriteMacData & | writeMacData, |
Mac & | mac | ||
) | const [virtual] |
Compute Write MAC.
- Note:
- Uses the previously computed Slave Secret in computation.
- Parameters:
-
[in] writeMacData Additional data fields as specified by device. [out] mac The computed MAC.
Implements ISha256MacCoproc.
Definition at line 176 of file DS2465.cpp.
OneWireMaster::CmdResult computeWriteMacSwap | ( | bool | regwrite, |
unsigned int | pageNum, | ||
unsigned int | segmentNum | ||
) | const |
OneWireMaster::CmdResult copyScratchpadToPage | ( | unsigned int | pageNum ) |
OneWireMaster::CmdResult copyScratchpadToSecret | ( | ) |
OneWireMaster::CmdResult copyScratchpadToSegment | ( | unsigned int | pageNum, |
unsigned int | segmentNum | ||
) |
Config currentConfig | ( | ) | const |
OneWireMaster::CmdResult OWInitMaster | ( | ) | [virtual] |
Receive one bit of communication and set a new level on the 1-Wire bus.
- Parameters:
-
[out] sendRecvBit Read data from 1-Wire bus will be returned in lsb. afterLevel Level 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] recvBuf Buffer to receive the data from the 1-Wire bus. recvLen Length 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:
-
recvByte Buffer to receive the data from the 1-Wire bus. afterLevel Level 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] 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 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] searchDirection Input with desired direction in case both read bits are zero. Output with direction taken based on read bits. [out] sbr Bit result of first read operation. [out] tsb Bit result of second read operation.
Reimplemented from OneWireMaster.
Definition at line 301 of file DS2465.cpp.
Send one bit of communication and set a new level on the 1-Wire bus.
- Parameters:
-
sendBit Buffer containing the bit to send on 1-Wire bus in lsb. afterLevel Level 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] sendBuf Buffer to send on the 1-Wire bus. sendLen Length 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:
-
sendByte Byte to send on the 1-Wire bus. afterLevel Level 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:
-
addr Address to begin reading from. [out] buf Buffer to hold read data. bufLen Length of buffer, buf, and number of bytes to read. skipSetPointer Assume that the read pointer is already set to the correct address.
Definition at line 533 of file DS2465.cpp.
OneWireMaster::CmdResult reset | ( | ) |
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] masterSecret New 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] config New configuration to write. verify Verify 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 | ||
) |
OneWireMaster::CmdResult writeScratchpad | ( | const uint8_t * | buf, |
size_t | bufLen | ||
) | const |
Field Documentation
const unsigned int eepromPageWriteDelayMs = 8 * eepromSegmentWriteDelayMs [static] |
const unsigned int eepromSegmentWriteDelayMs = 10 [static] |
const unsigned int shaComputationDelayMs = 2 [static] |
Generated on Tue Jul 12 2022 15:46:21 by 1.7.2