Skip to content

Commit dbd43bb

Browse files
authored
Merge pull request #2278 from mbedmicro/fix_config_docs
Documentation updates for the configuration system
2 parents c17132a + a43919e commit dbd43bb

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

docs/config_system.md

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -237,34 +237,58 @@ For `myapp` above:
237237

238238
# Using configuration data in the code
239239

240-
When compiling, the configuration system will automatically generate macro definitions for the configuration parameters and all the macros defined in libraries and the application in their `macros` keys. These definitions will be appended to the compiler's command line. When compiling `myapp` for target `Base`, the following extra macros will be generated (not necessarily in this order):
240+
When compiling, the configuration system will automatically generate macro definitions for the configuration parameters and all the macros defined in libraries and the application in their `macros` keys. These definitions will be written in a file named `mbed_config.h` located in the build directory. When compiling `myapp` for target `Base`, the `mbed_config.h` file will look like this (note that the order of the definitions might be different):
241241

242242
```
243-
-DMBED_CONF_MYAPP_WELCOME_STRING="Hello!"
244-
-DMBED_SERIAL_UART_SPEED=9600
245-
-DMBED_CONF_TARGET_STACK_SIZE=128
246-
-DINTERNAL_GPTMR_PERIOD=100
247-
-DMBED_CONF_MYLIB_BUFFER_SIZE=1024
248-
-DMBED_CONF_MYLIB_QUEUE_SIZE=10
249-
-DMYMOD_MACRO1
250-
-DMYMOD_MACRO2="TEST"
243+
// Automatically generated configuration file.
244+
// DO NOT EDIT, content will be overwritten.
245+
246+
#ifndef __MBED_CONFIG_DATA__
247+
#define __MBED_CONFIG_DATA__
248+
249+
// Configuration parameters
250+
#define MBED_CONF_MYAPP_WELCOME_STRING "Hello!" // set by application
251+
#define MBED_SERIAL_UART_SPEED 9600 // set by application[Base]
252+
#define MBED_CONF_TARGET_STACK_SIZE 128 // set by target
253+
#define INTERNAL_GPTMR_PERIOD 100 // set by application[*]
254+
#define MBED_CONF_MYLIB_BUFFER_SIZE 1024 // set by library:mylib
255+
#define MBED_CONF_MYLIB_QUEUE_SIZE 10 // set by library:mylib
256+
// Macros
257+
#define MYMOD_MACRO1 // defined by library:mylib
258+
#define MYMOD_MACRO2 "TEST" // defined by library:mylib
259+
260+
#endif
251261
```
252262

253-
When compiling for `Derived`, the following extra macros will be generated:
263+
When compiling for `Derived`, `mbed_config.h` will look like this:
264+
254265

255266
```
256-
-DMBED_CONF_MYAPP_WELCOME_STRING="Hello!"
257-
-DMBED_SERIAL_UART_SPEED=2400
258-
-DMBED_CONF_TARGET_STACK_SIZE=256
259-
-DMBED_CONF_TARGET_MY_OWN_CONFIG=0
260-
-DINTERNAL_GPTMR_PERIOD=100
261-
-DMBED_CONF_MYLIB_BUFFER_SIZE=128
262-
-DMBED_CONF_MYLIB_QUEUE_SIZE=20
263-
-DMYMOD_MACRO1
264-
-DMYMOD_MACRO2="TEST"
267+
// Automatically generated configuration file.
268+
// DO NOT EDIT, content will be overwritten.
269+
270+
#ifndef __MBED_CONFIG_DATA__
271+
#define __MBED_CONFIG_DATA__
272+
273+
// Configuration parameters
274+
#define MBED_CONF_MYAPP_WELCOME_STRING "Hello!" // set by application
275+
#define MBED_SERIAL_UART_SPEED 2400 // set by application[*]
276+
#define MBED_CONF_TARGET_STACK_SIZE 256 // set by target
277+
#define MBED_CONF_TARGET_MY_OWN_CONFIG 0 // set by target
278+
#define INTERNAL_GPTMR_PERIOD 100 // set by application[*]
279+
#define MBED_CONF_MYLIB_BUFFER_SIZE 128 // set by library:mylib[NXP]
280+
#define MBED_CONF_MYLIB_QUEUE_SIZE 20 // set by library:mylib[NXP]
281+
// Macros
282+
#define MYMOD_MACRO1 // defined by library:mylib
283+
#define MYMOD_MACRO2 "TEST" // defined by library:mylib
284+
285+
#endif
265286
```
266287

267288
Note that a macro definition will *not* be generated for a parameter that doesn't have a value.
268289

269290
The names of the macros for the configuration parameter (unless explicitly specified by `macro_name`) are prefixed by **MBED_CONF_**, followed by the full (prefixed) name of the parameter, capitalized and converted to a valid C macro name (if needed).
270291

292+
`mbed_config.h` will be included automatically by the toolchain in all compiled sources, so you'll have access to the configuration data without having to include `mbed_config.h` manually.
293+
294+
*Do not edit mbed_config.h manually*. It will be overwritten the next time you compile or export your project and all your changes will be lost.

0 commit comments

Comments
 (0)