diff --git a/modules/canopennode/CMakeLists.txt b/modules/canopennode/CMakeLists.txt index 380f8a9faf9..d4b023f9e3b 100644 --- a/modules/canopennode/CMakeLists.txt +++ b/modules/canopennode/CMakeLists.txt @@ -28,9 +28,9 @@ if(CONFIG_CANOPENNODE) CO_driver.c ) - zephyr_library_sources_ifdef(CONFIG_CANOPEN_SYNC_THREAD canopen_sync.c) - zephyr_library_sources_ifdef(CONFIG_CANOPEN_STORAGE canopen_storage.c) - zephyr_library_sources_ifdef(CONFIG_CANOPEN_LEDS canopen_leds.c) - zephyr_library_sources_ifdef(CONFIG_CANOPEN_PROGRAM_DOWNLOAD canopen_program.c) + zephyr_library_sources_ifdef(CONFIG_CANOPENNODE_SYNC_THREAD canopen_sync.c) + zephyr_library_sources_ifdef(CONFIG_CANOPENNODE_STORAGE canopen_storage.c) + zephyr_library_sources_ifdef(CONFIG_CANOPENNODE_LEDS canopen_leds.c) + zephyr_library_sources_ifdef(CONFIG_CANOPENNODE_PROGRAM_DOWNLOAD canopen_program.c) endif() diff --git a/modules/canopennode/CO_driver.c b/modules/canopennode/CO_driver.c index 42602042817..ff2f8e48bec 100644 --- a/modules/canopennode/CO_driver.c +++ b/modules/canopennode/CO_driver.c @@ -9,14 +9,14 @@ #include #include -#include +#include #define LOG_LEVEL CONFIG_CANOPEN_LOG_LEVEL #include LOG_MODULE_REGISTER(canopen_driver); K_KERNEL_STACK_DEFINE(canopen_tx_workq_stack, - CONFIG_CANOPEN_TX_WORKQUEUE_STACK_SIZE); + CONFIG_CANOPENNODE_TX_WORKQUEUE_STACK_SIZE); struct k_work_q canopen_tx_workq; @@ -474,7 +474,7 @@ static int canopen_init(const struct device *dev) k_work_queue_start(&canopen_tx_workq, canopen_tx_workq_stack, K_KERNEL_STACK_SIZEOF(canopen_tx_workq_stack), - CONFIG_CANOPEN_TX_WORKQUEUE_PRIORITY, NULL); + CONFIG_CANOPENNODE_TX_WORKQUEUE_PRIORITY, NULL); k_work_init(&canopen_tx_queue.work, canopen_tx_retry); diff --git a/modules/canopennode/CO_driver_target.h b/modules/canopennode/CO_driver_target.h index 15d90fcfd35..65c967ee8f2 100644 --- a/modules/canopennode/CO_driver_target.h +++ b/modules/canopennode/CO_driver_target.h @@ -30,12 +30,12 @@ extern "C" { #define CO_USE_OWN_CRC16 /* Use SDO buffer size from Kconfig */ -#define CO_SDO_BUFFER_SIZE CONFIG_CANOPEN_SDO_BUFFER_SIZE +#define CO_SDO_BUFFER_SIZE CONFIG_CANOPENNODE_SDO_BUFFER_SIZE /* Use trace buffer size from Kconfig */ -#define CO_TRACE_BUFFER_SIZE_FIXED CONFIG_CANOPEN_TRACE_BUFFER_SIZE +#define CO_TRACE_BUFFER_SIZE_FIXED CONFIG_CANOPENNODE_TRACE_BUFFER_SIZE -#ifdef CONFIG_CANOPEN_LEDS +#ifdef CONFIG_CANOPENNODE_LEDS #define CO_USE_LEDS 1 #endif diff --git a/modules/canopennode/Kconfig b/modules/canopennode/Kconfig index 97143cf5d21..b8cc169291b 100644 --- a/modules/canopennode/Kconfig +++ b/modules/canopennode/Kconfig @@ -14,7 +14,7 @@ config CANOPENNODE if CANOPENNODE -config CANOPEN_SDO_BUFFER_SIZE +config CANOPENNODE_SDO_BUFFER_SIZE int "CANopen SDO buffer size" default 32 range 7 889 @@ -25,27 +25,27 @@ config CANOPEN_SDO_BUFFER_SIZE not limited to the SDO buffer size. If block transfer is implemented, value should be set to 889. -config CANOPEN_TRACE_BUFFER_SIZE +config CANOPENNODE_TRACE_BUFFER_SIZE int "CANopen trace buffer size" default 100 help Size of the CANopen trace buffer in bytes. -config CANOPEN_TX_WORKQUEUE_STACK_SIZE +config CANOPENNODE_TX_WORKQUEUE_STACK_SIZE int "Stack size for the CANopen transmit workqueue" default 320 help Size of the stack used for the internal CANopen transmit workqueue. -config CANOPEN_TX_WORKQUEUE_PRIORITY +config CANOPENNODE_TX_WORKQUEUE_PRIORITY int "Priority for CANopen transmit workqueue" default 0 if !COOP_ENABLED default -1 help Priority level of the internal CANopen transmit workqueue. -config CANOPEN_STORAGE +config CANOPENNODE_STORAGE bool "CANopen object dictionary storage" depends on SETTINGS default y @@ -53,29 +53,29 @@ config CANOPEN_STORAGE Enable support for storing the CANopen object dictionary to non-volatile storage. -config CANOPEN_STORAGE_HANDLER_ERASES_EEPROM +config CANOPENNODE_STORAGE_HANDLER_ERASES_EEPROM bool "Erase CANopen object dictionary EEPROM entries in storage handler" - depends on CANOPEN_STORAGE + depends on CANOPENNODE_STORAGE help Erase CANopen object dictionary EEPROM entries upon write to object dictionary index 0x1011 subindex 1. -config CANOPEN_LEDS +config CANOPENNODE_LEDS bool "CANopen LED indicators" default y help Enable support for CANopen LED indicators according to the CiA 303-3 specification. -config CANOPEN_LEDS_BICOLOR +config CANOPENNODE_LEDS_BICOLOR bool "CANopen bicolor LED indicator" - depends on CANOPEN_LEDS + depends on CANOPENNODE_LEDS help Handle CANopen LEDs as one bicolor LED, favoring the red LED over the green LED in accordance with the CiA 303-3 specification. -config CANOPEN_SYNC_THREAD +config CANOPENNODE_SYNC_THREAD bool "CANopen SYNC thread" default y help @@ -83,24 +83,24 @@ config CANOPEN_SYNC_THREAD TPDOs. Application layer must take care of SYNC RPDO and TPDO processing on its own if this is disabled. -config CANOPEN_SYNC_THREAD_STACK_SIZE +config CANOPENNODE_SYNC_THREAD_STACK_SIZE int "Stack size for the CANopen SYNC thread" - depends on CANOPEN_SYNC_THREAD + depends on CANOPENNODE_SYNC_THREAD default 256 help Size of the stack used for the internal thread which processes CANopen SYNC RPDOs and TPDOs. -config CANOPEN_SYNC_THREAD_PRIORITY +config CANOPENNODE_SYNC_THREAD_PRIORITY int "Priority for CANopen SYNC thread" - depends on CANOPEN_SYNC_THREAD + depends on CANOPENNODE_SYNC_THREAD default 0 if !COOP_ENABLED default -5 help Priority level of the internal thread which processes CANopen SYNC RPDOs and TPDOs. -config CANOPEN_PROGRAM_DOWNLOAD +config CANOPENNODE_PROGRAM_DOWNLOAD bool "CANopen program download" depends on BOOTLOADER_MCUBOOT select IMG_MANAGER diff --git a/modules/canopennode/canopen_leds.c b/modules/canopennode/canopen_leds.c index 8fccb130594..f1fad7659a5 100644 --- a/modules/canopennode/canopen_leds.c +++ b/modules/canopennode/canopen_leds.c @@ -5,7 +5,7 @@ */ #include -#include +#include struct canopen_leds_state { CO_NMT_t *nmt; @@ -37,7 +37,7 @@ static void canopen_leds_update(struct k_timer *timer_id) red = LED_RED_ERROR(canopen_leds.nmt); -#ifdef CONFIG_CANOPEN_LEDS_BICOLOR +#ifdef CONFIG_CANOPENNODE_LEDS_BICOLOR if (red && canopen_leds.red_cb) { green = false; } diff --git a/modules/canopennode/canopen_program.c b/modules/canopennode/canopen_program.c index 0bb35bcb90f..9c2cde9b39f 100644 --- a/modules/canopennode/canopen_program.c +++ b/modules/canopennode/canopen_program.c @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include @@ -101,7 +101,7 @@ static CO_SDO_abortCode_t canopen_odf_1f50(CO_ODF_arg_t *odf_arg) return CO_SDO_AB_HW; } ctx.flash_status = FLASH_STATUS_IN_PROGRESS; - if (IS_ENABLED(CONFIG_CANOPEN_LEDS)) { + if (IS_ENABLED(CONFIG_CANOPENNODE_LEDS)) { canopen_leds_program_download(true); } ctx.total = odf_arg->dataLengthTotal; diff --git a/modules/canopennode/canopen_storage.c b/modules/canopennode/canopen_storage.c index 2df537b2ad8..3a1f5e35458 100644 --- a/modules/canopennode/canopen_storage.c +++ b/modules/canopennode/canopen_storage.c @@ -10,7 +10,7 @@ #include #include -#include +#include #define LOG_LEVEL CONFIG_CANOPEN_LOG_LEVEL #include @@ -100,7 +100,7 @@ static CO_SDO_abortCode_t canopen_odf_1011(CO_ODF_arg_t *odf_arg) LOG_DBG("deleted object dictionary ROM entries"); } -#ifdef CONFIG_CANOPEN_STORAGE_HANDLER_ERASES_EEPROM +#ifdef CONFIG_CANOPENNODE_STORAGE_HANDLER_ERASES_EEPROM err = canopen_storage_erase(CANOPEN_STORAGE_EEPROM); if (err == -ENOENT) { LOG_DBG("no object dictionary EEPROM entries to delete"); diff --git a/modules/canopennode/canopen_sync.c b/modules/canopennode/canopen_sync.c index a01de7f1903..3a978d74055 100644 --- a/modules/canopennode/canopen_sync.c +++ b/modules/canopennode/canopen_sync.c @@ -45,6 +45,6 @@ static void canopen_sync_thread(void *p1, void *p2, void *p3) } } -K_THREAD_DEFINE(canopen_sync, CONFIG_CANOPEN_SYNC_THREAD_STACK_SIZE, +K_THREAD_DEFINE(canopen_sync, CONFIG_CANOPENNODE_SYNC_THREAD_STACK_SIZE, canopen_sync_thread, NULL, NULL, NULL, - CONFIG_CANOPEN_SYNC_THREAD_PRIORITY, 0, 1); + CONFIG_CANOPENNODE_SYNC_THREAD_PRIORITY, 0, 1); diff --git a/modules/canopennode/canbus/canopen.h b/modules/canopennode/canopennode.h similarity index 96% rename from modules/canopennode/canbus/canopen.h rename to modules/canopennode/canopennode.h index 280a265cc8f..dfa877abd25 100644 --- a/modules/canopennode/canbus/canopen.h +++ b/modules/canopennode/canopennode.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ - /** * @defgroup CAN CAN BUS * @{ @@ -18,8 +17,8 @@ * @{ */ -#ifndef ZEPHYR_INCLUDE_CANOPEN_H_ -#define ZEPHYR_INCLUDE_CANOPEN_H_ +#ifndef ZEPHYR_MODULES_CANOPENNODE_CANOPENNODE_H_ +#define ZEPHYR_MODULES_CANOPENNODE_CANOPENNODE_H_ #include #include @@ -153,4 +152,4 @@ void canopen_leds_program_download(bool in_progress); * @} */ -#endif /* ZEPHYR_INCLUDE_CANOPEN_H_ */ +#endif /* ZEPHYR_MODULES_CANOPENNODE_CANOPENNODE_H_ */ diff --git a/samples/modules/canopennode/boards/frdm_k64f.conf b/samples/modules/canopennode/boards/frdm_k64f.conf index 1f419546e4d..06997dcbf73 100644 --- a/samples/modules/canopennode/boards/frdm_k64f.conf +++ b/samples/modules/canopennode/boards/frdm_k64f.conf @@ -1,2 +1,2 @@ CONFIG_MPU_ALLOW_FLASH_WRITE=y -CONFIG_CANOPEN_LEDS_BICOLOR=y +CONFIG_CANOPENNODE_LEDS_BICOLOR=y diff --git a/samples/modules/canopennode/prj.conf b/samples/modules/canopennode/prj.conf index c3621843dbe..eef763b968b 100644 --- a/samples/modules/canopennode/prj.conf +++ b/samples/modules/canopennode/prj.conf @@ -11,8 +11,8 @@ CONFIG_SETTINGS=y CONFIG_SETTINGS_NVS=y CONFIG_CANOPEN=y -CONFIG_CANOPEN_SYNC_THREAD=y -CONFIG_CANOPEN_STORAGE=y -CONFIG_CANOPEN_LEDS=y +CONFIG_CANOPENNODE_SYNC_THREAD=y +CONFIG_CANOPENNODE_STORAGE=y +CONFIG_CANOPENNODE_LEDS=y CONFIG_REBOOT=y diff --git a/samples/modules/canopennode/prj_no_storage.conf b/samples/modules/canopennode/prj_no_storage.conf index 00747308150..3468f28e246 100644 --- a/samples/modules/canopennode/prj_no_storage.conf +++ b/samples/modules/canopennode/prj_no_storage.conf @@ -5,7 +5,7 @@ CONFIG_CAN=y CONFIG_CAN_MAX_FILTER=13 CONFIG_CANOPEN=y -CONFIG_CANOPEN_SYNC_THREAD=y -CONFIG_CANOPEN_LEDS=y +CONFIG_CANOPENNODE_SYNC_THREAD=y +CONFIG_CANOPENNODE_LEDS=y CONFIG_REBOOT=y diff --git a/samples/modules/canopennode/src/main.c b/samples/modules/canopennode/src/main.c index 8f5cf6688e2..9586fa4970d 100644 --- a/samples/modules/canopennode/src/main.c +++ b/samples/modules/canopennode/src/main.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #define LOG_LEVEL CONFIG_CANOPEN_LOG_LEVEL #include @@ -206,9 +206,9 @@ void main(void) uint16_t timeout; uint32_t elapsed; int64_t timestamp; -#ifdef CONFIG_CANOPEN_STORAGE +#ifdef CONFIG_CANOPENNODE_STORAGE int ret; -#endif /* CONFIG_CANOPEN_STORAGE */ +#endif /* CONFIG_CANOPENNODE_STORAGE */ can.dev = device_get_binding(CAN_INTERFACE); if (!can.dev) { @@ -216,7 +216,7 @@ void main(void) return; } -#ifdef CONFIG_CANOPEN_STORAGE +#ifdef CONFIG_CANOPENNODE_STORAGE ret = settings_subsys_init(); if (ret) { LOG_ERR("failed to initialize settings subsystem (err = %d)", @@ -229,7 +229,7 @@ void main(void) LOG_ERR("failed to load settings (err = %d)", ret); return; } -#endif /* CONFIG_CANOPEN_STORAGE */ +#endif /* CONFIG_CANOPENNODE_STORAGE */ OD_powerOnCounter++; @@ -246,15 +246,15 @@ void main(void) LOG_INF("CANopen stack initialized"); -#ifdef CONFIG_CANOPEN_STORAGE +#ifdef CONFIG_CANOPENNODE_STORAGE canopen_storage_attach(CO->SDO[0], CO->em); -#endif /* CONFIG_CANOPEN_STORAGE */ +#endif /* CONFIG_CANOPENNODE_STORAGE */ config_leds(CO->NMT); CO_OD_configure(CO->SDO[0], OD_2102_buttonPressCounter, odf_2102, NULL, 0U, 0U); - if (IS_ENABLED(CONFIG_CANOPEN_PROGRAM_DOWNLOAD)) { + if (IS_ENABLED(CONFIG_CANOPENNODE_PROGRAM_DOWNLOAD)) { canopen_program_download_attach(CO->NMT, CO->SDO[0], CO->em); } @@ -275,13 +275,13 @@ void main(void) OD_buttonPressCounter = counter; CO_UNLOCK_OD(); -#ifdef CONFIG_CANOPEN_STORAGE +#ifdef CONFIG_CANOPENNODE_STORAGE ret = canopen_storage_save( CANOPEN_STORAGE_EEPROM); if (ret) { LOG_ERR("failed to save EEPROM"); } -#endif /* CONFIG_CANOPEN_STORAGE */ +#endif /* CONFIG_CANOPENNODE_STORAGE */ /* * Try to sleep for as long as the * stack requested and calculate the