diff --git a/.gitignore b/.gitignore index 57be60e..d4b04be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ .pio .clang_complete .gcc-flags.json -.vscode/browse.vc.db* -.vscode +.vscode/* +!.vscode/c_cpp_properties.json .west html memory.map diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..f9456e1 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "Zephyr", + "browse": { + "path": [ + "${workspaceFolder}/src" + ], + "limitSymbolsToIncludedHeaders": true + }, + "compileCommands": "${workspaceFolder}/zephyr/build/compile_commands.json", + "cStandard": "c99", + "cppStandard": "c++14", + "forcedInclude": [ + "${workspaceFolder}/zephyr/build/zephyr/include/generated/autoconf.h" + ] + } + ], + "version": 4 +} diff --git a/src/data_objects.cpp b/src/data_objects.cpp index 40209fe..ad82008 100644 --- a/src/data_objects.cpp +++ b/src/data_objects.cpp @@ -11,8 +11,6 @@ #include #include -#include -LOG_MODULE_REGISTER(data_objects, CONFIG_DATA_OBJECTS_LOG_LEVEL); #ifdef CONFIG_SOC_FAMILY_STM32 #include @@ -28,6 +26,8 @@ LOG_MODULE_REGISTER(data_objects, CONFIG_DATA_OBJECTS_LOG_LEVEL); #include "thingset.h" #include "helper.h" +LOG_MODULE_REGISTER(data_objects, CONFIG_DATA_OBJECTS_LOG_LEVEL); + // can be used to configure custom data objects in separate file instead // (e.g. data_objects_custom.cpp) #ifndef CONFIG_CUSTOM_DATA_OBJECTS_FILE diff --git a/src/data_storage.cpp b/src/data_storage.cpp index 49aa2aa..fe4d97d 100644 --- a/src/data_storage.cpp +++ b/src/data_storage.cpp @@ -18,10 +18,10 @@ #ifdef CONFIG_SOC_FAMILY_STM32 #include -#include -LOG_MODULE_REGISTER(nvs, CONFIG_DATA_STORAGE_LOG_LEVEL); #include +LOG_MODULE_REGISTER(nvs, CONFIG_DATA_STORAGE_LOG_LEVEL); + K_MUTEX_DEFINE(data_buf_lock); // Buffer used by store and restore functions (must be word-aligned for hardware CRC calculation) diff --git a/src/dcdc.cpp b/src/dcdc.cpp index 57d3110..afd69ef 100644 --- a/src/dcdc.cpp +++ b/src/dcdc.cpp @@ -11,9 +11,6 @@ #include #include -#include -LOG_MODULE_REGISTER(dcdc, CONFIG_DCDC_LOG_LEVEL); - #include // for fabs function #include // for min/max function #include @@ -24,6 +21,8 @@ LOG_MODULE_REGISTER(dcdc, CONFIG_DCDC_LOG_LEVEL); #include "data_storage.h" #include "setup.h" +LOG_MODULE_REGISTER(dcdc, CONFIG_DCDC_LOG_LEVEL); + extern DeviceStatus dev_stat; #if BOARD_HAS_DCDC diff --git a/src/hardware.cpp b/src/hardware.cpp index 26e5d7d..465ea5f 100644 --- a/src/hardware.cpp +++ b/src/hardware.cpp @@ -8,6 +8,7 @@ #include "mcu.h" #include "load.h" +#include "helper.h" #include "half_bridge.h" #include "leds.h" #include "setup.h" @@ -21,7 +22,6 @@ #include #include -#include LOG_MODULE_REGISTER(hardware, CONFIG_HW_LOG_LEVEL); void start_stm32_bootloader() diff --git a/src/helper.h b/src/helper.h index 6c7c0e0..66bda2e 100644 --- a/src/helper.h +++ b/src/helper.h @@ -17,6 +17,28 @@ #include #include +#ifdef __INTELLISENSE__ +/* + * VS Code intellisense can't cope with all the Zephyr macro layers for logging, so provide it + * with something more simple and make it silent. + */ + +#define LOG_DBG(...) printf(__VA_ARGS__) + +#define LOG_INF(...) printf(__VA_ARGS__) + +#define LOG_WRN(...) printf(__VA_ARGS__) + +#define LOG_ERR(...) printf(__VA_ARGS__) + +#define LOG_MODULE_REGISTER(...) + +#else + +#include + +#endif /* VSCODE_INTELLISENSE_HACK */ + #include #ifdef __cplusplus diff --git a/src/pwm_switch.cpp b/src/pwm_switch.cpp index c9d6447..45f4dfa 100644 --- a/src/pwm_switch.cpp +++ b/src/pwm_switch.cpp @@ -8,9 +8,6 @@ #include -#include -LOG_MODULE_REGISTER(pwm_switch, CONFIG_PWM_LOG_LEVEL); - #include #include @@ -19,6 +16,8 @@ LOG_MODULE_REGISTER(pwm_switch, CONFIG_PWM_LOG_LEVEL); #include "helper.h" #include "setup.h" +LOG_MODULE_REGISTER(pwm_switch, CONFIG_PWM_LOG_LEVEL); + #if BOARD_HAS_PWM_PORT #define PWM_CURRENT_MAX (DT_PROP(DT_CHILD(DT_PATH(outputs), pwm_switch), current_max)) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index fe650c9..394edbf 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -473,5 +473,9 @@ endif # include custom Kconfig if existing orsource "../src/custom/Kconfig" +#if 0 +#orsource "modules/thingset/zephyr/Kconfig.thingset" +#endif + # include main Zephyr menu entries from Zephyr root directory source "Kconfig.zephyr"