samples: canbus: canopen: add configuration for devices with no storage

Add CANopen sample configuration file for devices with no
storage/settings support.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
Henrik Brix Andersen 2020-11-07 16:24:58 +01:00 committed by Maureen Helm
parent 499b4c9069
commit df51a8a5c7
3 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,11 @@
CONFIG_LOG=y
CONFIG_CANOPEN_LOG_LEVEL_DBG=y
CONFIG_CAN=y
CONFIG_CAN_MAX_FILTER=13
CONFIG_CANOPEN=y
CONFIG_CANOPEN_SYNC_THREAD=y
CONFIG_CANOPEN_LEDS=y
CONFIG_REBOOT=y

View file

@ -15,3 +15,5 @@ tests:
sample.subsys.canbus.canopen.program_download:
extra_configs:
- CONFIG_BOOTLOADER_MCUBOOT=y
sample.subsys.canbus.canopen.no_storage:
extra_args: CONF_FILE=prj_no_storage.conf

View file

@ -206,7 +206,9 @@ void main(void)
uint16_t timeout;
uint32_t elapsed;
int64_t timestamp;
#ifdef CONFIG_CANOPEN_STORAGE
int ret;
#endif /* CONFIG_CANOPEN_STORAGE */
can.dev = device_get_binding(CAN_INTERFACE);
if (!can.dev) {
@ -214,6 +216,7 @@ void main(void)
return;
}
#ifdef CONFIG_CANOPEN_STORAGE
ret = settings_subsys_init();
if (ret) {
LOG_ERR("failed to initialize settings subsystem (err = %d)",
@ -226,6 +229,7 @@ void main(void)
LOG_ERR("failed to load settings (err = %d)", ret);
return;
}
#endif /* CONFIG_CANOPEN_STORAGE */
OD_powerOnCounter++;
@ -242,7 +246,10 @@ void main(void)
LOG_INF("CANopen stack initialized");
#ifdef CONFIG_CANOPEN_STORAGE
canopen_storage_attach(CO->SDO[0], CO->em);
#endif /* CONFIG_CANOPEN_STORAGE */
config_leds(CO->NMT);
CO_OD_configure(CO->SDO[0], OD_2102_buttonPressCounter,
odf_2102, NULL, 0U, 0U);
@ -268,11 +275,13 @@ void main(void)
OD_buttonPressCounter = counter;
CO_UNLOCK_OD();
#ifdef CONFIG_CANOPEN_STORAGE
ret = canopen_storage_save(
CANOPEN_STORAGE_EEPROM);
if (ret) {
LOG_ERR("failed to save EEPROM");
}
#endif /* CONFIG_CANOPEN_STORAGE */
/*
* Try to sleep for as long as the
* stack requested and calculate the