Extended MaximInterface

Dependents:   mbed_DS28EC20_GPIO

Revision:
6:a8c83a2e6fa4
Parent:
0:f77ad7f72d04
Child:
7:471901a04573
--- a/Devices/DS28E17.hpp	Fri Jan 19 10:25:02 2018 -0600
+++ b/Devices/DS28E17.hpp	Wed Jan 23 13:11:04 2019 -0600
@@ -36,6 +36,7 @@
 #include <stdint.h>
 #include <MaximInterface/Links/SelectRom.hpp>
 #include <MaximInterface/Utilities/Export.h>
+#include <MaximInterface/Utilities/span.hpp>
 
 namespace MaximInterface {
 
@@ -69,6 +70,7 @@
       : selectRom(selectRom), master(&master) {}
 
   void setMaster(OneWireMaster & master) { this->master = &master; }
+  
   void setSelectRom(const SelectRom & selectRom) {
     this->selectRom = selectRom;
   }
@@ -78,53 +80,49 @@
   /// @param[in] I2C_addr
   /// I2C slave address. The least significant bit of the I2C
   /// address is automatically cleared by the command.
-  /// @param[in] data I2C data to write.
-  /// @param[in] data_len Length of data. Valid from 1-255.
+  /// @param[in] data I2C data to write with length 1-255.
   /// @param[out] wr_status
   /// Indicates which write byte NACK’d. A value of 00h indicates all bytes
   /// were acknowledged by the slave. A non-zero value indicates the byte number
   /// that NACK’d. May be set to NULL.
   MaximInterface_EXPORT error_code
-  writeDataWithStop(uint_least8_t I2C_addr, const uint_least8_t * data,
-                    size_t data_len, uint_least8_t * wr_status = NULL);
+  writeDataWithStop(uint_least8_t I2C_addr, span<const uint_least8_t> data,
+                    uint_least8_t * wr_status = NULL);
 
   /// Write Data No Stop command.
   /// @details Output on I2C: S, Address + Write, Write Data [1-255]
   /// @param[in] I2C_addr
   /// I2C slave address. The least significant bit of the I2C address
   /// is automatically cleared by the command.
-  /// @param[in] data I2C data to write.
-  /// @param[in] data_len Length of data. Valid from 1-255.
+  /// @param[in] data I2C data to write with length 1-255.
   /// @param[out] wr_status
   /// Indicates which write byte NACK’d. A value of 00h indicates all bytes
   /// were acknowledged by the slave. A non-zero value indicates the byte number
   /// that NACK’d. May be set to NULL.
   MaximInterface_EXPORT error_code
-  writeDataNoStop(uint_least8_t I2C_addr, const uint_least8_t * data,
-                  size_t data_len, uint_least8_t * wr_status = NULL);
+  writeDataNoStop(uint_least8_t I2C_addr, span<const uint_least8_t> data,
+                  uint_least8_t * wr_status = NULL);
 
   /// Write Data Only command.
   /// @details Output on I2C: Write Data [1-255]
-  /// @param[in] data I2C data to write.
-  /// @param[in] data_len Length of data. Valid from 1-255.
+  /// @param[in] data I2C data to write with length 1-255.
   /// @param[out] wr_status
   /// Indicates which write byte NACK’d. A value of 00h indicates all bytes
   /// were acknowledged by the slave. A non-zero value indicates the byte number
   /// that NACK’d. May be set to NULL.
   MaximInterface_EXPORT error_code
-  writeDataOnly(const uint_least8_t * data, size_t data_len,
+  writeDataOnly(span<const uint_least8_t> data,
                 uint_least8_t * wr_status = NULL);
 
   /// Write Data Only With Stop command.
   /// @details Output on I2C: Write Data [1-255], P
-  /// @param[in] data I2C data to write.
-  /// @param[in] data_len Length of data. Valid from 1-255.
+  /// @param[in] data I2C data to write with length 1-255.
   /// @param[out] wr_status
   /// Indicates which write byte NACK’d. A value of 00h indicates all bytes
   /// were acknowledged by the slave. A non-zero value indicates the byte number
   /// that NACK’d. May be set to NULL.
   MaximInterface_EXPORT error_code
-  writeDataOnlyWithStop(const uint_least8_t * data, size_t data_len,
+  writeDataOnlyWithStop(span<const uint_least8_t> data,
                         uint_least8_t * wr_status = NULL);
 
   /// Write, Read Data With Stop command.
@@ -134,18 +132,15 @@
   /// @param[in] I2C_addr
   /// I2C slave address. The least significant bit of the I2C address
   /// is automatically cleared and set by the command.
-  /// @param[in] write_data I2C data to write.
-  /// @param[in] write_data_len Length of write_data. Valid from 1-255.
-  /// @param[out] read_data I2C data that was read.
-  /// @param[in] read_data_len Length of read_data. Valid from 1-255.
+  /// @param[in] write_data I2C data to write with length 1-255.
+  /// @param[out] read_data I2C data that was read with length 1-255.
   /// @param[out] wr_status
   /// Indicates which write byte NACK’d. A value of 00h indicates all bytes
   /// were acknowledged by the slave. A non-zero value indicates the byte number
   /// that NACK’d. May be set to NULL.
   MaximInterface_EXPORT error_code writeReadDataWithStop(
-      uint_least8_t I2C_addr, const uint_least8_t * write_data,
-      size_t write_data_len, uint_least8_t * read_data, size_t read_data_len,
-      uint_least8_t * wr_status = NULL);
+      uint_least8_t I2C_addr, span<const uint_least8_t> write_data,
+      span<uint_least8_t> read_data, uint_least8_t * wr_status = NULL);
 
   /// Read Data With Stop command.
   /// @details Output on I2C:
@@ -153,11 +148,9 @@
   /// @param[in]  I2C_addr
   /// I2C slave address. The least significant bit of the I2C address
   /// is automatically set by the command.
-  /// @param[out] data I2C data that was read.
-  /// @param[in] data_len Length of data. Valid from 1-255.
+  /// @param[out] data I2C data that was read with length 1-255.
   MaximInterface_EXPORT error_code readDataWithStop(uint_least8_t I2C_addr,
-                                                    uint_least8_t * data,
-                                                    size_t data_len);
+                                                    span<uint_least8_t> data);
 
   /// Write to Configuration Register of DS28E17.
   MaximInterface_EXPORT error_code writeConfigReg(I2CSpeed speed);
@@ -195,8 +188,8 @@
   };
 
   error_code sendPacket(Command command, const uint_least8_t * I2C_addr,
-                        const uint_least8_t * write_data, size_t write_data_len,
-                        uint_least8_t * read_data, size_t read_data_len,
+                        span<const uint_least8_t> write_data,
+                        span<uint_least8_t> read_data,
                         uint_least8_t * wr_status);
 
   SelectRom selectRom;