You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SparkFun Toolkit provides a common set of core functionality for use across the SparkFun Arduino Driver library. Instead of each device driver library implementing it's own communication layers, error types and design, the SparkFun Toolkit library is used.
6
+
7
+
By using the SparkFun Toolkit, Arduino drivers achieve the following benefits:
8
+
9
+
* Use a well-tested and validated implementation
10
+
* Reduce development effort
11
+
* Implement functionality following a common structure
12
+
* Set the foundation for future enhancements - as the capabilities of the toolkit grow, these features become available with little to any implementation effort.
13
+
14
+
## Current Status
15
+
16
+
### December 2023
17
+
18
+
The SparkFun Toolkit is available as a *Beta* release, with the intent of testing and validation by SparkFun. The community are free to use this toolkit with the understanding that interfaces, types and class structures could change.
19
+
20
+
### Documentation
21
+
22
+
|||
23
+
|---|---|
24
+
|[Bus Implementation](docs/ar_ibus.md) | The architecture and use of the Tookkit Communication Bus Interface
Copy file name to clipboardExpand all lines: docs/ar_ibus.md
+32-15Lines changed: 32 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -94,29 +94,33 @@ The class diagram of these base class interfaces/implementation:
94
94
95
95

96
96
97
-
## sfeTkIIBus - Arduino Implementation
97
+
## sfeTkIBus - Arduino Implementation
98
98
99
99
The initial implementation of the toolkit IBus interface is for the Arduino environment. This implementation consists of two classes, ```sfeTkArdI2C``` and ```sfeTkArdSPI```, each of which sub-class from their respective bus type interfaces within the core toolkit.
100
100
101
101
These driver implementations provide the platform specific implementation for the toolkit bus interfaces, supporting the methods defined by the interfaces, as well as contain and manage the platform specific settings and attributes for each bus type.
102
102
103
103
> [!IMPORTANT]
104
-
> The intent is that each user of an particular bus - a device in most cases - contains an instance of the specific bus object.
104
+
> The intent is that each user of an particular - a device in most cases - contains an instance of the specific bus class.
105
105
106
-
The class diagram for the Arduino implementation is as follows:
This class provides the Arduino implementation of I2C in the SparkFun Toolkit. It implements the methods of the ```sfeTkIBus``` and ```sfeTkII2C``` interfaces, as well as manages any Arduino specific state.
109
109
110
-
### The sfeTkArdI2C Class
110
+
The class diagram for the sfeTkArdI2C class:
111
111
112
-
This class provides the Arduino implementation of I2C in the SparkFun Toolkit. It implements the methods of the ```sfeTkIIBus``` and ```sfeTkII2C``` interfaces, as well as manages any Arduino specific state.
112
+

113
113
114
114
### The sfeTkArdSPI Class
115
115
116
-
This class provides the Arduino implementation of SPI in the SparkFun Toolkit. It implements the methods of the ```sfeTkIIBus``` and ```sfeTkISPI``` interfaces, as well as manages any Arduino specific state for the SPI bus - namely the SPISettings class.
116
+
This class provides the Arduino implementation of SPI in the SparkFun Toolkit. It implements the methods of the ```sfeTkIBus``` and ```sfeTkISPI``` interfaces, as well as manages any Arduino specific state for the SPI bus - namely the SPISettings class.
117
117
118
118
Before each use of the SPI bus, the methods of the ```sfeTkArdSPI``` uses an internal SPISettings class to ensure the SPI bus is operating in the desired mode for the device.
119
119
120
+
The class diagram for the sfeTkArdSPI class:
121
+
122
+

123
+
120
124
## sfeTkIBus Use
121
125
122
126
The general steps when using the sfeTkIBus in device development are outlined in the following steps. This example uses the Arduino implementation of the bus.
@@ -125,7 +129,7 @@ The general pattern for a device driver implementation that uses the SparkFun To
125
129
126
130
### Implement a Platform Independent Driver
127
131
128
-
The first step is to implement a core, platform independent version of the driver that communicates to the target device using the methods of a ```sfeTkIIBus``` interface.
132
+
The first step is to implement a core, platform independent version of the driver that communicates to the target device using the methods of a ```sfeTkIBus``` interface. By limiting use to the IBus interface, the core implementation can use any bus type or platform that implements the sfeTkIBus interface.
129
133
130
134
>[!IMPORTANT]
131
135
> At this level, the driver is only using a ```sfeTkIBus``` interface, not any specific bus implementation.
@@ -135,7 +139,10 @@ This driver has the following unique functionality:
135
139
1) A method to set the object that implements the ```sfeTkIBus``` interface object should use. Since
136
140
1) If the device supports identification capabilities, the driver provides this functionality.
137
141
138
-
#### SImple Example of an Independent Driver Implementation
142
+
#### Simple Example of an Independent Driver Implementation
143
+
144
+
>[!NOTE]
145
+
> This code is **pseudo-code**, used to demonstrate the key concepts of the implementation pattern.
139
146
140
147
This implementation would take the following form:
if (!_theSPIBus.init(SPI, spiSettings, MY_DEFAULT_CS, true))
254
+
if (_theSPIBus.init(SPI, spiSettings, MY_DEFAULT_CS, true) != kSTkErrOk)
247
255
return false;
248
256
setCommunicationBus(&_theSPIBus);
249
257
@@ -259,3 +267,12 @@ private:
259
267
sfeTkArdSPI _theSPIBus;
260
268
};
261
269
```
270
+
271
+
## Summary
272
+
273
+
In summary, the SparkFun Toolkit Bus Interface sets a standard that device drivers can implement against without concern for platform or bus type. Using common interface implementation patterns, the implementation delivers on the goals for this subsystem - namely:
274
+
275
+
* Separate device setup from device communication
276
+
* Define a common bus interface for use across a variety of common device bus types
277
+
* Deliver support for both SPI and I2C bus types initially, focusing on Arduino
278
+
* Structure the bus/toolkit implementation such that it's platform independent
0 commit comments