...
Code Block |
---|
/****************************************************************************/ /** Loads the variables from permanent storage using the appropriate target * function * * @retval GOAL_OK Values loaded * @retval other failed */ GOAL_STATUS_T goal_cmLoad( void ); |
The GOAL CM tries to load a variable storage automatically at startup. You can use goal_cmVarIsDefault
to check whether loading a config was successful. The function returns GOAL_TRUE
if loading a config failed, otherwise it returns GOAL_FALSE
. So we could use an initialization code for our variables like this:
Code Block | ||
---|---|---|
| ||
/* if no config was loaded, create an initial value set and save it */
if ((GOAL_TRUE == goal_cmVarIsDefault())) {
/* set initial baud rate */
val32 = APPL_BAUD_INITIAL;
res = goal_cmSetVarValue(APPL_CM_MOD_ID, APPL_CM_VAR_BAUD, &val32, sizeof(val32), GOAL_FALSE, NULL);
if (GOAL_RES_ERR(res)) {
goal_logErr("error updating 32-bit variable");
}
...
/* write the config to storage */
if (GOAL_RES_ERR(res)) {
res = goal_cmSave();
}
}
|
Virtual variables
When we think about our firmware revision variable GOAL_CM_FWVERSION
, this would be normally a value that is “baked in” in our firmware itself, and not a value you would set and store.
...