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
Adds some much-needed documentation on how to use the `config` key when
defining a new target, as well as overriding it in other targets or in
the mbed_app.json file
Copy file name to clipboardExpand all lines: docs/tools/mbed_targets.md
+35-2Lines changed: 35 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -149,6 +149,39 @@ The build system errors when you use features outside of this list.
149
149
150
150
When you use target inheritance, you may alter the values of `features` using `features_add` and `features_remove`. This is similar to the `macros_add` and `macros_remove` mechanism the previous section describes.
151
151
152
+
#### `config` and `overrides`
153
+
154
+
_configs_ provide a more flexible way to manage macros for a target. Each configuration has a macro name as well as a default value and an optional help value. For example, this config flag defines a configuration `lf_clock_src` that defines the source for the low frequency clock on the nRF51 target, with a default value of `NRF_LF_SRC_XTAL`. When compiled, this value will be set for the macro `MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC`:
155
+
156
+
```json
157
+
"config": {
158
+
"lf_clock_src": {
159
+
"value": "NRF_LF_SRC_XTAL",
160
+
"macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC"
161
+
}
162
+
}
163
+
```
164
+
165
+
_overrides_ allow a child target to change the value of a config. For example, if a child target of the nRF51 used the internal RC clock instead of the crystal, it can add an override like so:
166
+
167
+
```json
168
+
"overrides": {
169
+
"lf_clock_src": "NRF_LF_SRC_RC"
170
+
}
171
+
```
172
+
173
+
configurations can also be modified in a project in the mbed_app.json file using `target_overrides`.
174
+
175
+
```json
176
+
"target_overrides": {
177
+
"*": {
178
+
"config1": "value_for_all_targets"
179
+
},
180
+
"NRF51_DK": {
181
+
"config2": "value_for_single_target"
182
+
}
183
+
}
184
+
152
185
#### `device_has`
153
186
154
187
The list in `device_has` defines what hardware a device has.
@@ -291,9 +324,9 @@ For each of these target roles, some restrictions are in place:
291
324
-`extra_labels`.
292
325
-`public`.
293
326
-`config`.
327
+
-`override`
294
328
-`forced_reset_timeout`.
295
-
-`target_overrides`
296
-
-`macros` are not used. That is intentional: they do not provide any benefit over `config` and `target_overrides` but can be very difficult to use. In practice it is very difficult to override the value of a macro with a value. `config` and `target_overries`, on the other hand, are designed for this use case.
329
+
-`macros` are not used. That is intentional: they do not provide any benefit over `config` and `overrides` but can be very difficult to use. In practice it is very difficult to override the value of a macro with a value. `config` and `overrides`, on the other hand, are designed for this use case.
297
330
-`extra_labels` may not contain any target names
298
331
-`device_has` may only contain values from the following list:
0 commit comments