@@ -22,6 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
*/
23
23
24
24
#include " sfeTkArdI2C.h"
25
+ #include < cstdint>
25
26
26
27
// ---------------------------------------------------------------------------------
27
28
// init()
@@ -87,7 +88,7 @@ sfeTkError_t sfeTkArdI2C::ping()
87
88
// ---------------------------------------------------------------------------------
88
89
// writeByte()
89
90
//
90
- // Writes a single byte to the device.
91
+ // Sends a single byte to the device.
91
92
//
92
93
// Returns true on success, false on failure
93
94
//
@@ -102,6 +103,41 @@ sfeTkError_t sfeTkArdI2C::writeByte(uint8_t dataToWrite)
102
103
return _i2cPort->endTransmission () == 0 ? kSTkErrOk : kSTkErrFail ;
103
104
}
104
105
106
+ // ---------------------------------------------------------------------------------
107
+ // writeWord()
108
+ //
109
+ // Sends a word to the device.
110
+ //
111
+ // Returns true on success, false on failure
112
+ //
113
+ sfeTkError_t sfeTkArdI2C::writeWord (uint16_t dataToWrite)
114
+ {
115
+ if (!_i2cPort)
116
+ return kSTkErrBusNotInit ;
117
+
118
+ return writeBlock ((uint8_t *)&dataToWrite, sizeof (uint16_t ));
119
+ }
120
+
121
+ // ---------------------------------------------------------------------------------
122
+ // writeBlock()
123
+ //
124
+ // Sends an array of data to the device.
125
+ //
126
+ // Returns true on success, false on failure
127
+ //
128
+ sfeTkError_t sfeTkArdI2C::writeBlock (const uint8_t *dataToWrite, size_t length)
129
+ {
130
+ int nData = 0 ;
131
+ if (!_i2cPort)
132
+ return kSTkErrBusNotInit ;
133
+
134
+ // do the Arduino I2C work
135
+ _i2cPort->beginTransmission (address ());
136
+ _i2cPort->write (data, (int )length);
137
+
138
+ return _i2cPort->endTransmission () == 0 ? kSTkErrOk : kSTkErrFail ;
139
+ }
140
+
105
141
// ---------------------------------------------------------------------------------
106
142
// writeRegisterByte()
107
143
//
0 commit comments