1
1
/* *
2
2
* @file sfTkISerialBus.h
3
3
* @brief Header file for the SparkFun Toolkit Base Serial Bus Interface Definition.
4
- *
4
+ *
5
5
* This file contains the interface declaration for connecting sfTkISerial to the sfTkIBus.
6
- *
6
+ *
7
7
* @author SparkFun Electronics
8
8
* @date 2025
9
9
* @copyright Copyright (c) 2025, SparkFun Electronics Inc. This project is released under the MIT License.
10
10
*
11
- * SPDX-License-Identifier: MIT
11
+ * SPDX-License-Identifier: MIT
12
12
*/
13
13
14
14
#pragma once
15
+
16
+ // clang-format off
15
17
#include " sfTkError.h"
16
18
#include " sfTkIBus.h"
17
19
#include " sfTkISerial.h"
18
20
#include < cstdint>
21
+ // clang-format on
19
22
20
23
const uint8_t ksfTkBusTypeSerialBus = 0x03 ;
21
24
@@ -24,26 +27,26 @@ class sfTkISerialBus : sfTkIBus
24
27
public:
25
28
/* *
26
29
* @brief Constructor for the serial bus
27
- *
30
+ *
28
31
*/
29
32
sfTkISerialBus ()
30
33
{
31
34
}
32
-
35
+
33
36
virtual ~sfTkISerialBus () = default ;
34
37
35
38
/* *
36
39
* @brief Writes an array of bytes to the serial interface.
37
- *
40
+ *
38
41
* @param data The data to write
39
42
* @param length The length of the data buffer
40
43
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
41
44
*/
42
45
virtual sfTkError_t write (const uint8_t *data, size_t length) = 0;
43
-
46
+
44
47
/* *
45
48
* @brief Writes an array of bytes to a register on the target address. Supports any address size
46
- *
49
+ *
47
50
* @param devReg The device's register's address - can be any size, If nullptr, address is not sent
48
51
* @param regLength The length of the register address. If 0, address is not sent
49
52
* @param data The data to write
@@ -63,7 +66,7 @@ class sfTkISerialBus : sfTkIBus
63
66
64
67
/* *
65
68
* @brief Read an array of bytes from the serial interface
66
- *
69
+ *
67
70
* @param data The data buffer to read into
68
71
* @param length The length of the data buffer
69
72
* @param readBytes[out] The number of bytes read
@@ -73,15 +76,16 @@ class sfTkISerialBus : sfTkIBus
73
76
74
77
/* *
75
78
* @brief Reads an array of bytes to a register on the target address. Supports any address size
76
- *
79
+ *
77
80
* @param devReg The device's register's address - can be any size
78
81
* @param regLength The length of the register address
79
82
* @param data The data to buffer to read into
80
83
* @param numBytes The length of the data buffer
81
84
* @param readBytes[out] The number of bytes read
82
85
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
83
86
*/
84
- virtual sfTkError_t readRegister (uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes, size_t &readBytes) override
87
+ virtual sfTkError_t readRegister (uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes,
88
+ size_t &readBytes) override
85
89
{
86
90
// Buffer valid?
87
91
if (!data)
@@ -93,7 +97,7 @@ class sfTkISerialBus : sfTkIBus
93
97
if (devReg != nullptr && regLength > 0 )
94
98
retVal = write (devReg, regLength);
95
99
96
- if (retVal != ksfTkErrOk)
100
+ if (retVal != ksfTkErrOk)
97
101
return retVal;
98
102
99
103
// Read the data.
@@ -104,7 +108,7 @@ class sfTkISerialBus : sfTkIBus
104
108
105
109
/* *
106
110
* @brief Get the type of the object
107
- *
111
+ *
108
112
* @return uint8_t The type of the object
109
113
*/
110
114
virtual uint8_t type (void ) override
0 commit comments