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
+53-18Lines changed: 53 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ The key class to support this pattern are:
20
20
|||
21
21
|------|-------|
22
22
**sfeTkIBus** | A virtual C++ class that device the bus ```sfeTkIBus``` interface |
23
-
**sfeTkBusI2C** | Provides an Arduino I2C implementation for the toolkit |
24
-
**sfeTkBusSPI** | Provides an Arduino SPI implementation for the toolkit |
23
+
**sfeTkII2C** | Sub-class of the ```sfeTkIIBus``` interface, it provides an interface for I2C devices|
24
+
**sfeTkISPI** | Sub-class of the ```sfeTkIIBus``` interface, it provides an interface for SPI devices |
25
25
26
26
### The sfeTkIBus Interface
27
27
@@ -31,18 +31,35 @@ The interface methods:
31
31
32
32
| Method| Definition |
33
33
|------|-------|
34
-
**ping** | A method used to determine if a device is connected to the bus |
35
34
**writeRegisterByte** | Write a byte of data to a particular register of a device |
35
+
**writeRegisterWord** | Write a word of data to a particular register of a device |
36
36
**writeRegisterRegion** | Write an array of data to a particular register of a device|
37
+
**readRegisterByte** | Read a byte of data from a particular register of a device |
38
+
**readRegisterWord** | Read a word of data from a particular register of a device |
37
39
**readRegisterRegion** | Read an array of data from a particular register of a device |
38
40
39
-
### Arduino Implementation
41
+
### The sfeTkII2C Implementation
40
42
41
-
The first implementation of the IBus interface is for the Arduino development environment, as noted above. The implementation consists of two classes, ```sfeTkBusI2C``` and ```sfeTkBusSPI```, each implementing the sfeTkIBus interface using the Arduino SDK.
43
+
This class sub-classes from the ```sfeTkIBus``` interface adding additional functionally focused on supporting an I2C implementation. This interface provides the additional functionality.
42
44
43
-
The results is outlined in the following class diagram:
45
+
| Method| Definition |
46
+
|------|-------|
47
+
**ping** | Determine if a devices is connected to the I2C device at the address set on this bus object. This is an interface method |
48
+
**setAddress** | Set the I2C address to use for this I2C object |
49
+
**address** | Returns the address used by this I2C object |
50
+
51
+
> Note: The ```sfeTkII2C``` class manages the I2C address
44
52
45
-

53
+
### The sfeTkISPI Implementation
54
+
55
+
This class sub-classes from the ```sfeTkIBus``` interface adding additional functionally focused on supporting an SPI implementation. This interface provides the additional functionality.
56
+
57
+
| Method| Definition |
58
+
|------|-------|
59
+
**setCS** | Set the CS Pin to use for this SPI object |
60
+
**cs** | Returns the CS Pin used by this SPI object |
61
+
62
+
> Note: The ```sfeTkISPI``` class manages the CS Pin
46
63
47
64
## sfeTkIBus Use
48
65
@@ -78,13 +95,18 @@ public:
78
95
if (!_theBus || !data || len == 0)
79
96
return false;
80
97
81
-
int status = _theBus->writeRegisterRegion(_addr, THE_REG, data, len);
98
+
int status = _theBus->writeRegisterRegion(THE_REG, data, len);
82
99
83
100
return (status == 0);
84
101
}
102
+
103
+
bool checkDeviceID()
104
+
{
105
+
// do some device ID checks in registers ...etc
106
+
return true;
107
+
}
85
108
private:
86
-
sfeTkIBus *_theBus
87
-
uint8_t _addr;
109
+
sfeTkIBus *_theBus;
88
110
};
89
111
```
90
112
@@ -96,23 +118,31 @@ Basic concept - creating an I2C class in Arduino
0 commit comments