Extended MaximInterface

Dependents:   mbed_DS28EC20_GPIO

Revision:
6:a8c83a2e6fa4
Parent:
0:f77ad7f72d04
Child:
7:471901a04573
--- a/Devices/DS2431.hpp	Fri Jan 19 10:25:02 2018 -0600
+++ b/Devices/DS2431.hpp	Wed Jan 23 13:11:04 2019 -0600
@@ -35,6 +35,7 @@
 
 #include <MaximInterface/Links/SelectRom.hpp>
 #include <MaximInterface/Links/Sleep.hpp>
+#include <MaximInterface/Utilities/array_span.hpp>
 #include <MaximInterface/Utilities/Export.h>
 
 namespace MaximInterface {
@@ -55,15 +56,16 @@
 public:
   enum ErrorValue { CrcError = 1, OperationFailure };
 
-  typedef array<uint_least8_t, 8> Scratchpad;
+  typedef array_span<uint_least8_t, 8> Scratchpad;
   typedef uint_least8_t Address;
 
-  DS2431(const Sleep & sleep, OneWireMaster & master,
-         const SelectRom & selectRom)
+  DS2431(Sleep & sleep, OneWireMaster & master, const SelectRom & selectRom)
       : selectRom(selectRom), master(&master), sleep(&sleep) {}
 
-  void setSleep(const Sleep & sleep) { this->sleep = &sleep; }
+  void setSleep(Sleep & sleep) { this->sleep = &sleep; }
+  
   void setMaster(OneWireMaster & master) { this->master = &master; }
+  
   void setSelectRom(const SelectRom & selectRom) {
     this->selectRom = selectRom;
   }
@@ -71,22 +73,20 @@
   /// Reads block of data from EEPROM memory.
   /// @param[in] beginAddress EEPROM memory address to start reading from.
   /// @param[out] data EEPROM data read from the device.
-  /// @param[in] dataLen Length of data parameter and number of bytes to read.
   MaximInterface_EXPORT error_code readMemory(Address beginAddress,
-                                              uint_least8_t * data,
-                                              size_t dataLen) const;
+                                              span<uint_least8_t> data) const;
 
   /// Writes 8 bytes to the scratchpad.
   /// @param[in] targetAddress EEPROM memory address that this data.
   /// will be copied to.  Must be on row boundary.
   /// @param[in] data Data to write to scratchpad.
   MaximInterface_EXPORT error_code writeScratchpad(Address targetAddress,
-                                                   const Scratchpad & data);
+                                                   Scratchpad::const_span data);
 
   /// Reads contents of scratchpad.
   /// @param[out] data Data read from scratchpad.
   /// @param[out] esByte E/S byte read before scratchpad data.
-  MaximInterface_EXPORT error_code readScratchpad(Scratchpad & data,
+  MaximInterface_EXPORT error_code readScratchpad(Scratchpad::span data,
                                                   uint_least8_t & esByte);
 
   /// Copies contents of scratchpad to EEPROM.
@@ -110,7 +110,7 @@
 /// @param[in] data Data to write to EEPROM.
 MaximInterface_EXPORT error_code writeMemory(DS2431 & device,
                                              DS2431::Address targetAddress,
-                                             const DS2431::Scratchpad & data);
+                                             DS2431::Scratchpad::const_span data);
 
 inline error_code make_error_code(DS2431::ErrorValue e) {
   return error_code(e, DS2431::errorCategory());