@@ -75,7 +75,8 @@ class sfTkIBus
7575 /* *
7676 * @brief Constructor
7777 */
78- sfTkIBus () {
78+ sfTkIBus ()
79+ {
7980 _byteOrder = sftk_system_byteorder ();
8081 }
8182 /* *--------------------------------------------------------------------------
@@ -245,6 +246,31 @@ class sfTkIBus
245246 return readRegisterRegion (reg, data, numBytes, readBytes);
246247 }
247248
249+ /* *
250+ * @brief Overloaded function to read a 32-bit value from the given 16-bit register address.
251+ *
252+ * This function reads a 32-bit value from the specified 16-bit register address.
253+ *
254+ * @param reg The device's 16-bit register's address.
255+ * @param[out] value The 32-bit value read from the register.
256+ *
257+ * @return sfTkError_t Returns ksfTkErrOk on success, or an error code on failure.
258+ */
259+ virtual sfTkError_t readRegister (uint16_t reg, uint32_t &value)
260+ {
261+ size_t readBytes = 0 ;
262+
263+ // this is a reg 16 address - so call the method to manage this. Note - it manages the
264+ // byte swapping of the address.
265+
266+ sfTkError_t retValue = readRegister16Region (reg, (uint8_t *)&value, sizeof (uint32_t ), readBytes);
267+
268+ // The data is a uint32 - byte swap the result?
269+ if (retValue == ksfTkErrOk && sftk_system_byteorder () != _byteOrder)
270+ value = sftk_byte_swap (value);
271+
272+ return retValue;
273+ }
248274 /* *--------------------------------------------------------------------------
249275 * @brief Reads a block of data from the given 16-bit register address.
250276 *
@@ -311,4 +337,3 @@ class sfTkIBus
311337 /* * flag to manage byte swapping */
312338 sfTkByteOrder _byteOrder;
313339};
314-
0 commit comments