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
Note: This guide has not been confirmed for UART and I2C connections yet, please edit and add clarification as needed
74
74
75
+
### 1. Update the Board Overlay (TODO Change this if we are using the dtsi instead)
75
76
76
-
you also want to add aliases
77
77
78
+
Declare your hardware devices in the Zephyr device tree overlay or .dts file
79
+
80
+
81
+
GPIO examples:
82
+
```
78
83
aliases {
79
84
burnwire0 = &burnwire0;
80
85
burnwire1 = &burnwire1;
81
86
};
82
87
88
+
burnwire0: burnwire0 {
89
+
gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
90
+
label = "Burnwire 0, 28";
91
+
};
92
+
93
+
...
94
+
```
95
+
96
+
I2C Example
97
+
98
+
```
99
+
/ {
100
+
aliases {
101
+
myi2c = &i2c1; // alias for the I²C bus
102
+
mysensor = &sensor0; // alias for the device on the bus
103
+
};
104
+
};
105
+
106
+
&i2c1 {
107
+
status = "okay";
108
+
mysensor: sensor0@48 {
109
+
compatible = "myvendor,my-sensor";
110
+
reg = <0x48>; // I²C address of the sensor
111
+
};
112
+
};
113
+
```
114
+
For GPIOs, the alias points to a pin node.
115
+
116
+
For I²C, you can alias either the bus or a device on the bus.
117
+
118
+
For UART, the alias points to the UART hardware peripheral.
119
+
120
+
### 2. Pull the device tree nodes into C++ structs that Zephyr can use. Zephyr drivers require a handle to the hardware node; this step binds your C++ driver to the actual hardware configuration from the overlay.
121
+
122
+
TODO: Check if the open step needs to happen (can't find clear documentation on it!@@@@@@@@)
123
+
124
+
125
+
In RefereneceDeploymentTopology.cpp, you want to get it from the device tree.
83
126
84
-
2.
127
+
Start by creating a node identifier https://docs.zephyrproject.org/latest/build/dts/api-usage.html#dt-node-identifiers. In this example we use DT_ALIAS because we assume you used ALIAS from step 1, but you can create the node identifier however you want.
### 3. Declare each driver in the F´ topology and connect it to your component.
98
156
99
-
connections burnwire1 {
100
-
burnwire1.gpioSet -> gpioDriver.gpioWrite
101
-
}
157
+
The topology defines how components communicate (ports) and ensures F´ can route commands/events between drivers and components.
102
158
159
+
#### In Topology.fpp
103
160
161
+
```
162
+
# GPIO drivers
163
+
instance gpioBurnwire0
164
+
instance gpioBurnwire1
165
+
166
+
167
+
# Connect burnwire to GPIOs
168
+
connections burnwire {
169
+
burnwire0.gpioSet -> gpioBurnwire0.gpioWrite
170
+
}
171
+
172
+
# Connect sensor to I²C driver
173
+
connections mysensor {
174
+
mySensor.i2cSend -> i2cDriver.i2cWrite
175
+
i2cDriver.i2cRead -> mySensor.i2cReceive
176
+
}
177
+
178
+
# Connect UART to communication component
179
+
connections comms {
180
+
comms.tx -> uartDriver.write
181
+
uartDriver.read -> comms.rx
182
+
}
183
+
```
104
184
105
185
106
-
in instances.fpp
186
+
4. Add Component Instances
187
+
188
+
Assign Base IDs and create instances of each driver/component. Base IDs are used internally by F´ to route commands/events. Every component must have a unique Base ID.
189
+
190
+
in instances.fpp create an instance of your new pin. Get the base Id by looking at the instructions for the number at the top of file under Base ID Convention of the instances.fpp
191
+
192
+
```
107
193
instance gpioBurnwire0: Zephyr.ZephyrGpioDriver base id 0x10015100
194
+
```
108
195
109
-
instance gpioBurnwire1: Zephyr.ZephyrGpioDriver base id 0x10015200
196
+
5. Make a new component in the components folder. Use the command
110
197
198
+
fprime-util new --component Components/New_Component
111
199
112
-
in topology.fpp
200
+
6. Add the component (not the port) to the instances.fpp and topology.fpp folder
113
201
114
-
instance gpioBurnwire0
115
-
instance gpioBurnwire1
202
+
In topology.fpp:
116
203
117
-
3. Make a new component in the components folder
118
-
4. Add the component to the instances and topology folder
204
+
```
205
+
instance burnwire
206
+
```
119
207
120
-
in topology.fpp also instance burnwire
208
+
In instances.fpp:
209
+
```
210
+
instance burnwire: Components.Burnwire base id 0x10017000
211
+
```
212
+
Get the base Id by looking at the insrtecutions for the number at the top of file under Base ID Convention of the instances.fpp
0 commit comments