Extended MaximInterface
Dependents: mbed_DS28EC20_GPIO
Diff: Links/I2CMaster.hpp
- Revision:
- 6:a8c83a2e6fa4
- Parent:
- 3:f818ea5172ed
- Child:
- 7:471901a04573
--- a/Links/I2CMaster.hpp Fri Jan 19 10:25:02 2018 -0600 +++ b/Links/I2CMaster.hpp Wed Jan 23 13:11:04 2019 -0600 @@ -33,9 +33,9 @@ #ifndef MaximInterface_I2CMaster #define MaximInterface_I2CMaster -#include <stddef.h> #include <stdint.h> #include <MaximInterface/Utilities/Export.h> +#include <MaximInterface/Utilities/span.hpp> #include <MaximInterface/Utilities/system_error.hpp> namespace MaximInterface { @@ -63,16 +63,16 @@ /// Write data block to the bus. MaximInterface_EXPORT virtual error_code - writeBlock(const uint_least8_t * data, size_t dataLen); + writeBlock(span<const uint_least8_t> data); /// Perform a complete write transaction on the bus with optional stop /// condition. /// @param address Address in 8-bit format. /// @param sendStop /// True to send a stop condition or false to set up a repeated start. - error_code writePacket(uint_least8_t address, const uint_least8_t * data, - size_t dataLen, bool sendStop = true) { - return writePacketImpl(address, data, dataLen, sendStop); + error_code writePacket(uint_least8_t address, span<const uint_least8_t> data, + bool sendStop = true) { + return writePacketImpl(address, data, sendStop); } /// Read data byte from the bus. @@ -83,40 +83,39 @@ /// Read data block from the bus. /// @param status Determines whether an ACK or NACK is sent after reading. /// @param[out] data Data read from the bus if successful. - /// @param dataLen Number of bytes to read and length of data. MaximInterface_EXPORT virtual error_code - readBlock(AckStatus status, uint_least8_t * data, size_t dataLen); + readBlock(AckStatus status, span<uint_least8_t> data); /// Perform a complete read transaction on the bus with optional stop /// condition. /// @param address Address in 8-bit format. /// @param sendStop /// True to send a stop condition or false to set up a repeated start. - error_code readPacket(uint_least8_t address, uint_least8_t * data, - size_t dataLen, bool sendStop = true) { - return readPacketImpl(address, data, dataLen, sendStop); + error_code readPacket(uint_least8_t address, span<uint_least8_t> data, + bool sendStop = true) { + return readPacketImpl(address, data, sendStop); } MaximInterface_EXPORT static const error_category & errorCategory(); protected: MaximInterface_EXPORT virtual error_code - writePacketImpl(uint_least8_t address, const uint_least8_t * data, - size_t dataLen, bool sendStop); + writePacketImpl(uint_least8_t address, span<const uint_least8_t> data, + bool sendStop); - MaximInterface_EXPORT virtual error_code readPacketImpl(uint_least8_t address, - uint_least8_t * data, - size_t dataLen, - bool sendStop); + MaximInterface_EXPORT virtual error_code + readPacketImpl(uint_least8_t address, span<uint_least8_t> data, + bool sendStop); }; inline error_code make_error_code(I2CMaster::ErrorValue e) { return error_code(e, I2CMaster::errorCategory()); } + inline error_condition make_error_condition(I2CMaster::ErrorValue e) { return error_condition(e, I2CMaster::errorCategory()); } } // namespace MaximInterface -#endif \ No newline at end of file +#endif