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);
5252const sfeTkError_t kSTkErrBusNoResponse = kSTkErrFail * (kSTkErrBaseBus + 3 );
5353
5454/* *
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.
5656 */
5757const sfeTkError_t kSTkErrBusDataTooLong = kSTkErrFail * (kSTkErrBaseBus + 4 );
5858
@@ -86,6 +86,12 @@ const sfeTkError_t kSTkErrBusNotEnabled = kSTkErrBaseBus + 8;
8686class sfeTkIBus
8787{
8888 public:
89+ /* *
90+ * @brief Constructor
91+ */
92+ sfeTkIBus () {
93+ _byteOrder = sftk_system_byteorder ();
94+ }
8995 /* *--------------------------------------------------------------------------
9096 * @brief Send a single byte to the device*
9197 * @param data Data to write.
@@ -294,6 +300,29 @@ class sfeTkIBus
294300 {
295301 return 0 ;
296302 }
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;
297327};
298328
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.
3232 @brief Common include file for the core of the SparkFun Electronics Toolkit
3333*/
3434#include "sfeTkError.h"
35- #include "sfeTkIBus.h"
35+
3636
3737// byte order types/enum
3838enum class sfeTKByteOrder : uint8_t
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class sfeTkArdI2C : public sfeTkII2C
4545 @brief Constructor
4646 */
4747
48- sfeTkArdI2C (void ) : _i2cPort(nullptr ), _bufferChunkSize{kDefaultBufferChunk }, _byteOrder{SFTK_LSBFIRST}
48+ sfeTkArdI2C (void ) : _i2cPort(nullptr ), _bufferChunkSize{kDefaultBufferChunk }
4949 {
5050 }
5151 /* *
@@ -293,26 +293,7 @@ class sfeTkArdI2C : public sfeTkII2C
293293 return _bufferChunkSize;
294294 }
295295
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+
316297
317298 protected:
318299 // note: The wire port is protected, allowing access if a sub-class is
@@ -333,6 +314,4 @@ class sfeTkArdI2C : public sfeTkII2C
333314 /* * The I2C buffer chunker - chunk size*/
334315 size_t _bufferChunkSize;
335316
336- /* * flag to manage byte swapping */
337- sfeTKByteOrder _byteOrder;
338317};
You can’t perform that action at this time.
0 commit comments