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:
62:43039aeca2ab
Parent:
61:268612a10614
diff -r 268612a10614 -r 43039aeca2ab OneWire_Memory/Authenticators/DS28E15_22_25/DS28E15_22_25.cpp
--- a/OneWire_Memory/Authenticators/DS28E15_22_25/DS28E15_22_25.cpp	Thu Apr 14 14:38:42 2016 -0500
+++ b/OneWire_Memory/Authenticators/DS28E15_22_25/DS28E15_22_25.cpp	Tue Apr 19 10:05:06 2016 -0500
@@ -42,6 +42,20 @@
   CMD_WRITE_AUTH_PROTECT =    0xCC,
 };
 
+DS28E15_22_25::Segment DS28E15_22_25::Page::toSegment(unsigned int segmentNum) const
+{
+  if (segmentNum > (segmentsPerPage - 1))
+    segmentNum = (segmentsPerPage - 1);
+  return Segment(*reinterpret_cast<const Segment::Buffer *>(&m_data[segmentNum * sizeof(Segment::Buffer)]));
+}
+
+void DS28E15_22_25::Page::fromSegment(unsigned int segmentNum, const Segment & segment)
+{
+  if (segmentNum > (segmentsPerPage - 1))
+    segmentNum = (segmentsPerPage - 1);
+  std::memcpy(&m_data[segmentNum * sizeof(Segment::Buffer)], &static_cast<const Segment::Buffer &>(segment), Segment::length);
+}
+
 DS28E15_22_25::BlockProtection::BlockProtection(bool readProtection, bool writeProtection, bool eepromEmulation, bool authProtection, std::uint8_t blockNum)
 {
   setReadProtection(readProtection);
@@ -382,7 +396,7 @@
 
   authMacData[11] = 0x00;
 
-  return MacCoproc.computeAuthMac(pageData, challenge, authMacData, mac);
+  return MacCoproc.computeAuthMac(ISha256MacCoprocessor::DevicePage(pageData), challenge, authMacData, mac);
 }
 
 ISha256MacCoprocessor::CmdResult DS28E15_22_25::computeAuthMacAnon(const ISha256MacCoprocessor & MacCoproc, const Page & pageData, unsigned int pageNum, const Scratchpad & challenge, const ManId & manId, Mac & mac)
@@ -1008,5 +1022,5 @@
   slaveSecretData[9] = manId[0];
   slaveSecretData[8] = manId[1];
 
-  return MacCoproc.computeSlaveSecret(bindingPage, partialSecret, slaveSecretData);
+  return MacCoproc.computeSlaveSecret(ISha256MacCoprocessor::DevicePage(bindingPage), partialSecret, slaveSecretData);
 }