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
Copy file name to clipboardExpand all lines: docs/ar_ibus.md
+22-9Lines changed: 22 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ This class sub-classes from the ```sfeTkIBus``` interface adding additional func
52
52
**address** | Returns the address used by this I2C object |
53
53
54
54
> [!NOTE]
55
-
> The ```sfeTkII2C``` class manages the device address for the I2C bus. As such, each I2C device instantiates/uses a instance of the ```sfeTkII2C``` class.
55
+
> The ```sfeTkII2C``` class manages the device address for the I2C bus. As such, each I2C device instantiates/uses an instance of the ```sfeTkII2C``` class.
56
56
57
57
### The sfeTkISPI Implementation
58
58
@@ -64,7 +64,7 @@ This class sub-classes from the ```sfeTkIBus``` interface adding additional func
64
64
**cs** | Returns the CS Pin used by this SPI object |
65
65
66
66
> [!NOTE]
67
-
> The ```sfeTkISPI``` class manages CS Pin for the SPI bus. As such, each SPI device instantiates/uses a instance of the ```sfeTkISPI``` class.
67
+
> The ```sfeTkISPI``` class manages CS Pin for the SPI bus. As such, each SPI device instantiates/uses an instance of the ```sfeTkISPI``` class.
68
68
69
69
The class diagram of these base class interfaces/implementation:
70
70
@@ -111,9 +111,7 @@ This driver has the following unique functionality:
111
111
1) A method to set the object that implements the ```sfeTkIBus``` interface object should use. Since
112
112
1) If the device supports identification capabilities, the driver provides this functionality.
113
113
114
-
### Platform Independent/Bus Independent Driver
115
-
116
-
Develop a platform independent version of a device driver that commutates using the sfeTkIBus interface. This driver should include a method to set the bus object, accepting a pointer to a sfeTkIBus interface/object. Actual bus setup is provided outside of the driver.
114
+
#### SImple Example of an Independent Driver Implementation
117
115
118
116
This implementation would take the following form:
119
117
@@ -160,7 +158,17 @@ private:
160
158
161
159
This driver sub-classes from the general/core driver class, builds and configures the desired bus object and passes this into the core driver.
162
160
163
-
Basic concept - creating an I2C class in Arduino
161
+
The key concepts for these Platform specific drivers include:
162
+
163
+
1) Perform any platform specific bus setup during the instantiation of the device. This might just be setting the target (pin, address) for the device on the bus.
164
+
1) Implement any bus specific device identification use at this level. For example, on I2C, a ping call might be made on the bus before a more detailed identification method is used.
165
+
166
+
#### Basic concept - creating an I2C class in Arduino
167
+
168
+
The following is an example of an I2C class in Arduino based on the previous platform independent driver.
169
+
170
+
> [!NOTE]
171
+
> This class implements a ```isConnected()``` method that calls the ```ping()``` method of the I2C bus class being used, and if this passes, then calls the ```checkDeviceID()``` method of the superclass.
164
172
165
173
```c++
166
174
@@ -179,7 +187,7 @@ class myArduinoDriverI2C : public myDriverClass
179
187
return myDriverClass::begin();
180
188
}
181
189
182
-
bool ping()
190
+
bool isConnected()
183
191
{
184
192
if (!_theI2CBus.ping())
185
193
return false;
@@ -192,7 +200,12 @@ private:
192
200
};
193
201
```
194
202
195
-
Basic concept - creating an SPI class in Arduino
203
+
#### Basic concept - creating an SPI class in Arduino
204
+
205
+
The following is a SPI version of the driver implemented in Arduino. While similar to the I2C implementation, it focuses on the specific needs of the SPI bus, specifically the ```SPISettings``` this particular device requires when using the SPI bus.
206
+
207
+
> [!NOTE]
208
+
> This class implements a ```isConnected()``` method that just calls the superclasses ```checkDeviceID()``` method to determine if the device is available on the bus.
196
209
197
210
```c++
198
211
@@ -213,7 +226,7 @@ class myArduinoDriveSPI : public myDriverClass
0 commit comments