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

Superseded by MaximInterface.

Revision:
50:e967f9befbd0
Parent:
49:36954b62f503
Child:
51:a65f031e997b
diff -r 36954b62f503 -r e967f9befbd0 OneWire_Memory/Authenticators/DS28E15_22_25/DS28E15_22_25.hpp
--- a/OneWire_Memory/Authenticators/DS28E15_22_25/DS28E15_22_25.hpp	Fri Apr 08 16:11:16 2016 -0500
+++ b/OneWire_Memory/Authenticators/DS28E15_22_25/DS28E15_22_25.hpp	Mon Apr 11 14:48:43 2016 -0500
@@ -79,6 +79,20 @@
   /// Container for a manufacturer ID.
   typedef array<std::uint8_t, 2> ManId;
   
+  /// Container for the device personality.
+  union Personality
+  {
+    array<std::uint8_t, 4>::Buffer bytes;
+    struct
+    {
+      std::uint8_t PB1;
+      std::uint8_t PB2;
+      ManId::Buffer manIdBytes;
+    } fields;
+    
+    bool secretLocked() const { return (fields.PB2 & 0x01); }
+  };
+  
   /// Represents the status of a memory protection block.
   class BlockProtection
   {
@@ -251,7 +265,9 @@
   /// @param pageNum Page number for read operation.
   /// @param segmentNum Segment number within page for read operation.
   /// @param[out] data Buffer to read data from the segment into.
-  CmdResult readSegment(unsigned int pageNum, unsigned int segmentNum, Segment & data) const;
+  /// @param continuing True if continuing a previous Read Memory command.
+  ///                   False to begin a new command.
+  CmdResult readSegment(unsigned int pageNum, unsigned int segmentNum, Segment & data, bool continuing = false) const;
   
   /// Write memory segment using the Write Memory command.
   /// @note 1-Wire ROM selection should have already occurred.
@@ -290,13 +306,27 @@
   /// @param[out] protection Receives protection status read from device.
   CmdResult readBlockProtection(unsigned int blockNum, BlockProtection & protection);
   
+  /// @defgroup readAllBlockProtection
+  /// @{
+  /// 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(BlockProtection (&protection)[DS28E15_BLOCKS]);
+  CmdResult readAllBlockProtection(BlockProtection (&protection)[DS28E25_BLOCKS]);
+  /// @}
+  
+  /// 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);
+  
   /// Update the status of a memory protection block using the Write Page Protection command.
   /// @note 1-Wire ROM selection should have already occurred.
   /// @param[in] Desired protection status for the block.
   ///            It is not possible to disable existing protections.
   /// @param continuing True to continue a previous Write Page Protection command.
   ///                   False to begin a new command.
-  CmdResult writeBlockProtection(const BlockProtection & protection, bool continuing = false);
+  CmdResult writeBlockProtection(const BlockProtection & protection);
   
   /// Update the status of a memory protection block using the Authenticated Write Page Protection command.
   /// @note 1-Wire ROM selection should have already occurred.
@@ -307,8 +337,7 @@
   ///                   False to begin a new command.
   CmdResult writeAuthBlockProtection(const ISha256MacCoprocessor & MacCoproc,
                                      const BlockProtection & newProtection,
-                                     const BlockProtection & oldProtection,
-                                     bool continuing = false);
+                                     const BlockProtection & oldProtection);
   
   /// Write memory segment with authentication using the Authenticated Write Memory command.
   /// @note 1-Wire ROM selection should have already occurred.
@@ -353,7 +382,10 @@
   /// @param allpages True to read all pages or false to read one page.
   /// @param pageNum Page number if reading block protection.
   /// @param rdbuf Buffer to receive data read from device.
-  CmdResult readStatus(bool personality, bool allpages, unsigned int pageNum, std::uint8_t * rdbuf) const;
+  CmdResult readStatus(bool personality, bool allpages, unsigned int blockNum, std::uint8_t * rdbuf) const;
+  
+  /// @ingroup readAllBlockProtection
+  template <ProtectionBlocks blocks> CmdResult readAllBlockProtection(BlockProtection (&protection)[blocks]);
 };
 
 #endif