Extended MaximInterface
Dependents: mbed_DS28EC20_GPIO
Diff: Links/OneWireMaster.hpp
- Revision:
- 6:a8c83a2e6fa4
- Parent:
- 3:f818ea5172ed
- Child:
- 7:471901a04573
--- a/Links/OneWireMaster.hpp Fri Jan 19 10:25:02 2018 -0600 +++ b/Links/OneWireMaster.hpp Wed Jan 23 13:11:04 2019 -0600 @@ -33,9 +33,9 @@ #ifndef MaximInterface_OneWireMaster #define MaximInterface_OneWireMaster -#include <stddef.h> #include <stdint.h> #include <MaximInterface/Utilities/Export.h> +#include <MaximInterface/Utilities/span.hpp> #include <MaximInterface/Utilities/system_error.hpp> namespace MaximInterface { @@ -90,15 +90,13 @@ /// Send a block of communication on the 1-Wire bus. /// @param[in] sendBuf Buffer to send on the 1-Wire bus. - /// @param sendLen Length of the buffer to send. MaximInterface_EXPORT virtual error_code - writeBlock(const uint_least8_t * sendBuf, size_t sendLen); + writeBlock(span<const uint_least8_t> sendBuf); /// Receive a block of communication on the 1-Wire bus. /// @param[out] recvBuf Buffer to receive the data from the 1-Wire bus. - /// @param recvLen Length of the buffer to receive. - MaximInterface_EXPORT virtual error_code readBlock(uint_least8_t * recvBuf, - size_t recvLen); + MaximInterface_EXPORT virtual error_code + readBlock(span<uint_least8_t> recvBuf); /// Set the 1-Wire bus communication speed. virtual error_code setSpeed(Speed newSpeed) = 0; @@ -132,27 +130,39 @@ } // Alternate forms of the read and write functions. + + error_code touchBit(bool & sendRecvBit) { + return touchBitSetLevel(sendRecvBit, NormalLevel); + } + error_code writeBit(bool sendBit) { return writeBitSetLevel(sendBit, NormalLevel); } + error_code readBit(bool & recvBit) { return readBitSetLevel(recvBit, NormalLevel); } + error_code writeBitPower(bool sendBit) { return writeBitSetLevel(sendBit, StrongLevel); } + error_code readBitPower(bool & recvBit) { return readBitSetLevel(recvBit, StrongLevel); } + error_code writeByte(uint_least8_t sendByte) { return writeByteSetLevel(sendByte, NormalLevel); } + error_code readByte(uint_least8_t & recvByte) { return readByteSetLevel(recvByte, NormalLevel); } + error_code writeBytePower(uint_least8_t sendByte) { return writeByteSetLevel(sendByte, StrongLevel); } + error_code readBytePower(uint_least8_t & recvByte) { return readByteSetLevel(recvByte, StrongLevel); } @@ -163,6 +173,7 @@ inline error_code make_error_code(OneWireMaster::ErrorValue e) { return error_code(e, OneWireMaster::errorCategory()); } + inline error_condition make_error_condition(OneWireMaster::ErrorValue e) { return error_condition(e, OneWireMaster::errorCategory()); }