File tree Expand file tree Collapse file tree 3 files changed +34
-26
lines changed Expand file tree Collapse file tree 3 files changed +34
-26
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ const sfeTkError_t kSTkErrBusTimeout = kSTkErrFail * (kSTkErrBaseBus + 2);
52
52
const sfeTkError_t kSTkErrBusNoResponse = kSTkErrFail * (kSTkErrBaseBus + 3 );
53
53
54
54
/* *
55
- * @brief Returned when the data to be sent is too long or recieved is too short.
55
+ * @brief Returned when the data to be sent is too long or received is too short.
56
56
*/
57
57
const sfeTkError_t kSTkErrBusDataTooLong = kSTkErrFail * (kSTkErrBaseBus + 4 );
58
58
@@ -86,6 +86,12 @@ const sfeTkError_t kSTkErrBusNotEnabled = kSTkErrBaseBus + 8;
86
86
class sfeTkIBus
87
87
{
88
88
public:
89
+ /* *
90
+ * @brief Constructor
91
+ */
92
+ sfeTkIBus () {
93
+ _byteOrder = sftk_system_byteorder ();
94
+ }
89
95
/* *--------------------------------------------------------------------------
90
96
* @brief Send a single byte to the device*
91
97
* @param data Data to write.
@@ -294,6 +300,29 @@ class sfeTkIBus
294
300
{
295
301
return 0 ;
296
302
}
303
+ /* *
304
+ * @brief Set the byte order for multi-byte data transfers
305
+ *
306
+ * @param order The byte order to set - set to either SFTK_MSBFIRST or SFTK_LSBFIRST. The default is SFTK_LSBFIRST
307
+ *
308
+ */
309
+ void setByteOrder (sfeTKByteOrder order)
310
+ {
311
+ _byteOrder = order;
312
+ }
313
+
314
+ /* *
315
+ * @brief Get the current byte order
316
+ *
317
+ * @retval The current byte order
318
+ */
319
+ sfeTKByteOrder byteOrder (void )
320
+ {
321
+ return _byteOrder;
322
+ }
323
+
324
+ protected:
325
+ /* * flag to manage byte swapping */
326
+ sfeTKByteOrder _byteOrder;
297
327
};
298
328
299
- // };
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
32
@brief Common include file for the core of the SparkFun Electronics Toolkit
33
33
*/
34
34
#include "sfeTkError.h"
35
- #include "sfeTkIBus.h"
35
+
36
36
37
37
// byte order types/enum
38
38
enum class sfeTKByteOrder : uint8_t
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class sfeTkArdI2C : public sfeTkII2C
45
45
@brief Constructor
46
46
*/
47
47
48
- sfeTkArdI2C (void ) : _i2cPort(nullptr ), _bufferChunkSize{kDefaultBufferChunk }, _byteOrder{SFTK_LSBFIRST}
48
+ sfeTkArdI2C (void ) : _i2cPort(nullptr ), _bufferChunkSize{kDefaultBufferChunk }
49
49
{
50
50
}
51
51
/* *
@@ -293,26 +293,7 @@ class sfeTkArdI2C : public sfeTkII2C
293
293
return _bufferChunkSize;
294
294
}
295
295
296
- /* *
297
- * @brief Set the byte order for multi-byte data transfers
298
- *
299
- * @param order The byte order to set - set to either SFTK_MSBFIRST or SFTK_LSBFIRST. The default is SFTK_LSBFIRST
300
- *
301
- */
302
- void setByteOrder (sfeTKByteOrder order)
303
- {
304
- _byteOrder = order;
305
- }
306
-
307
- /* *
308
- * @brief Get the current byte order
309
- *
310
- * @retval The current byte order
311
- */
312
- sfeTKByteOrder byteOrder (void )
313
- {
314
- return _byteOrder;
315
- }
296
+
316
297
317
298
protected:
318
299
// note: The wire port is protected, allowing access if a sub-class is
@@ -333,6 +314,4 @@ class sfeTkArdI2C : public sfeTkII2C
333
314
/* * The I2C buffer chunker - chunk size*/
334
315
size_t _bufferChunkSize;
335
316
336
- /* * flag to manage byte swapping */
337
- sfeTKByteOrder _byteOrder;
338
317
};
You can’t perform that action at this time.
0 commit comments