Battery Management System¶
For the BMS are currently two applications available:
- Firmware (folder:
/bms_app) - Selftest (folder:
/bms_selftest)
Software Sources (CMake)¶
The sources for new software are compiled when the configuration is active, e.g.,
app/bms_app/CMakeLists.txt:
add_subdirectory_ifdef(CONFIG_XYZ_MODULE m_xyz)
or
file(GLOB_RECURSE sources "sources/*.cpp" "main.cpp")
Software folder conventions¶
In the bms main firmware application, the sources are located in the folder sources/.
Headers are located in the folder include/.
The header folder is in the include path for compilation, as well as the library and zephy paths.
The structure of the BMS firmware is grouped in the following folders:
analog_thread-> thread definition for all ADC sampling (power, temp, etc.)bms_fsm-> for FSM control logiccyphal-> communication classes (Cyphal receive handler, publishers)hardware_interfaces-> for abstraction classes of the hardwarehelper-> other functionalityusage_monitor-> class for statistics
Software Configuration¶
The application can be static configured by a Kconfig system. The main Kconfig comes from the zephy build
tool and includes other configurations, e.g. the application local kconfig at app/bms_app/Kconfig.
menuconfig XYZ_MODULE
bool "XYZ module"
select XYZ_INPUT
help "The XYZ module measures the A subsystem and publishes the results to the XYZ channel."
mod = XYZ
mod-str = xyz
rsource "../Kconfig.template.module"
The compilation specific settings of these kconfig options is done by a .conf file.
It is included in the applications CMakeLists.txt (e.g. set(CONF_FILE conf/common.conf))
Logging¶
The zephyr logging is configured for different groups/modules and used with individual severity levels.
module = XYZ_MODULE
module-str = xyz_module
source "subsys/logging/Kconfig.template.log_config"
If a module log level is set to WARNING (e.g. in common.conf: CONFIG_XYZ_MODULE_LOG_LEVEL_WRN=y), only ERROR and WARNING log will be generated.
#include <zephyr/logging/log.h>
// register once in the app (any .c/cpp), then _DECLARE to use the same group
LOG_MODULE_REGISTER(xyz, CONFIG_XYZ_MODULE_LOG_LEVEL);
...
LOG_DBG("debug message: %d", err);
LOG_INF("info message: %d", err);
LOG_WRN("warning message: %d", err);
LOG_ERR("error message: %d", err);