@@ -22,6 +22,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222*/
2323
2424#include " sfeTkArdI2C.h"
25+ #include < cstddef>
26+ #include < cstdint>
2527
2628// ---------------------------------------------------------------------------------
2729// init()
@@ -87,7 +89,7 @@ sfeTkError_t sfeTkArdI2C::ping()
8789// ---------------------------------------------------------------------------------
8890// writeByte()
8991//
90- // Writes a single byte to the device.
92+ // Writes a single byte to the device, without indexing to a register .
9193//
9294// Returns true on success, false on failure
9395//
@@ -102,6 +104,33 @@ sfeTkError_t sfeTkArdI2C::writeByte(uint8_t dataToWrite)
102104 return _i2cPort->endTransmission () == 0 ? kSTkErrOk : kSTkErrFail ;
103105}
104106
107+ // ---------------------------------------------------------------------------------
108+ // writeWord()
109+ //
110+ // Writes a word to the device, without indexing to a register.
111+ //
112+ // Returns true on success, false on failure
113+ //
114+ sfeTkError_t sfeTkArdI2C::writeWord (uint16_t dataToWrite)
115+ {
116+ if (!_i2cPort)
117+ return kSTkErrBusNotInit ;
118+
119+ return writeRegion ((uint8_t *)&dataToWrite, sizeof (uint16_t ));
120+ }
121+
122+ // ---------------------------------------------------------------------------------
123+ // writeRegion()
124+ //
125+ // Writes a word to the device, without indexing to a register.
126+ //
127+ // Returns true on success, false on failure
128+ //
129+ sfeTkError_t sfeTkArdI2C::writeRegion (const uint8_t *data, size_t length)
130+ {
131+ return writeRegisterRegionAddress (nullptr , 0 , data, length) == 0 ? kSTkErrOk : kSTkErrFail ;
132+ }
133+
105134// ---------------------------------------------------------------------------------
106135// writeRegisterByte()
107136//
@@ -152,7 +181,10 @@ sfeTkError_t sfeTkArdI2C::writeRegisterRegionAddress(uint8_t *devReg, size_t reg
152181 return kSTkErrBusNotInit ;
153182
154183 _i2cPort->beginTransmission (address ());
155- _i2cPort->write (devReg, regLength);
184+
185+ if (devReg != nullptr && regLength > 0 )
186+ _i2cPort->write (devReg, regLength);
187+
156188 _i2cPort->write (data, (int )length);
157189
158190 return _i2cPort->endTransmission () ? kSTkErrFail : kSTkErrOk ;
@@ -183,7 +215,7 @@ sfeTkError_t sfeTkArdI2C::writeRegister16Region(uint16_t devReg, const uint8_t *
183215 return writeRegisterRegionAddress ((uint8_t *)&devReg, 2 , data, length);
184216}
185217
186- // ---------------------------------------------------------------------------------
218+
187219
188220/* *
189221 * @brief Reads an array of bytes to a register on the target address. Supports any address size
0 commit comments