Skip to content

Commit cfebd4b

Browse files
committed
Add documentation on configs
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
1 parent 8a89a5b commit cfebd4b

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

docs/tools/mbed_targets.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,39 @@ The build system errors when you use features outside of this list.
149149

150150
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.
151151

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+
152185
#### `device_has`
153186

154187
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:
291324
- `extra_labels`.
292325
- `public`.
293326
- `config`.
327+
- `override`
294328
- `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.
297330
- `extra_labels` may not contain any target names
298331
- `device_has` may only contain values from the following list:
299332
- `ANALOGIN`.

0 commit comments

Comments
 (0)