Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Diff: Slaves/Authenticators/DS28E15_22_25/DS28E25.h
- Revision:
- 139:f0e0a7976846
- Parent:
- 113:13e2865603df
--- a/Slaves/Authenticators/DS28E15_22_25/DS28E25.h Fri Dec 02 19:21:55 2016 +0000 +++ b/Slaves/Authenticators/DS28E15_22_25/DS28E25.h Tue Dec 13 13:31:30 2016 -0800 @@ -36,15 +36,75 @@ #include "DS28E15_22_25.h" namespace OneWire -{ +{ /// Interface to the DS28E25 and DS28EL25 (low power) authenticators. class DS28E25 : public DS28E15_22_25 { - public: + public: + // DS28E15_22_25 traits + static const unsigned int memoryPages = 16; + static const unsigned int protectionBlocks = 8; + /// @param owMaster 1-Wire Master to use for communication with DS28E15. /// @param lowVoltage Enable low voltage timing. DS28E25(RandomAccessRomIterator & selector, bool lowVoltage = false) - : DS28E15_22_25(selector, lowVoltage, DS28E25_Family) { } + : DS28E15_22_25(selector, lowVoltage) { } + + /// Perform Write Scratchpad operation on the device. + /// @note 1-Wire ROM selection should have already occurred. + /// @param[in] data Data to write to the scratchpad. + CmdResult writeScratchpad(const Scratchpad & data) const; + + /// Perform a Read Scratchpad operation on the device. + /// @note 1-Wire ROM selection should have already occurred. + /// @param[out] data Buffer to read data from the scratchpad into. + CmdResult readScratchpad(Scratchpad & data) const; + + /// Read the status of a memory protection block using the Read Status command. + /// @note 1-Wire ROM selection should have already occurred. + /// @param blockNum Block number to to read status of. + /// @param[out] protection Receives protection status read from device. + CmdResult readBlockProtection(unsigned int blockNum, BlockProtection & protection) const; + + /// Read the personality bytes using the Read Status command. + /// @note 1-Wire ROM selection should have already occurred. + /// @param[out] personality Receives personality read from device. + CmdResult readPersonality(Personality & personality) const; + + /// Write memory segment with authentication using the Authenticated Write Memory command. + /// @note 1-Wire ROM selection should have already occurred. + /// @param MacCoproc Coprocessor to use for Write MAC computation. + /// @param pageNum Page number for write operation. + /// @param segmentNum Segment number within page for write operation. + /// @param[in] newData New data to write to the segment. + /// @param[in] oldData Existing data contained in the segment. + /// @param continuing True to continue writing with the next sequential segment. + /// False to begin a new command. + CmdResult writeAuthSegment(const ISha256MacCoproc & MacCoproc, + unsigned int pageNum, + unsigned int segmentNum, + const Segment & newData, + const Segment & oldData, + bool continuing = false); + + /// Write memory segment with authentication using the Authenticated Write Memory command. + /// @note 1-Wire ROM selection should have already occurred. + /// @param pageNum Page number for write operation. + /// @param segmentNum Segment number within page for write operation. + /// @param[in] newData New data to write to the segment. + /// @param[in] mac Write MAC computed for this operation. + /// @param continuing True to continue writing with the next sequential segment. + /// False to begin a new command. + CmdResult writeAuthSegmentMac(unsigned int pageNum, + unsigned int segmentNum, + const Segment & newData, + const Mac & mac, + bool continuing = false); + + /// Read the status of all memory protection blocks using the Read Status command. + /// @note 1-Wire ROM selection should have already occurred. + /// @param[out] protection Receives protection statuses read from device. + CmdResult readAllBlockProtection(array<BlockProtection, protectionBlocks> & protection) const; }; }