The STM32 bootloader entry function as well as the flash size and page size variables were only used by ThingSet items of the DFU group, which were removed with the switch to the ThingSet SDK. The unused code is removed together with mcu.h and the obsolete HW_LOG_LEVEL option. The USB-C dead battery pull-downs of the STM32G4 are already disabled by the Zephyr SoC initialization if USB device support is not enabled, so the register access in setup() is not necessary anymore. The DC/DC duty cycle step size depending on the SoC series is moved from the code to the new Kconfig option DCDC_DUTY_STEP_SIZE with the same defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
442 lines
12 KiB
Plaintext
442 lines
12 KiB
Plaintext
# Copyright (c) The Libre Solar Project Contributors
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
mainmenu "Libre Solar Charge Controller Firmware"
|
|
|
|
#
|
|
# Invisible (board-specific) Kconfig symbols
|
|
#
|
|
|
|
config CONTROL_FREQUENCY
|
|
int
|
|
default 10
|
|
help
|
|
Main control function frequency (Hz)
|
|
|
|
Frequencies higher than 10 Hz caused issues with MPPT control during lab test with
|
|
PV simulator. Might be different with actual solar panel.
|
|
|
|
config DCDC_DUTY_STEP_SIZE
|
|
int
|
|
default 3 if SOC_SERIES_STM32G4X
|
|
default 1
|
|
help
|
|
Duty cycle change per control step of the DC/DC MPPT algorithm in timer counts of the
|
|
half bridge.
|
|
|
|
Larger steps are used for faster microcontrollers, as their half-bridge timers have a
|
|
higher resolution.
|
|
|
|
config HS_MOSFET_FAIL_SAFE_PROTECTION
|
|
bool
|
|
default y
|
|
depends on $(dt_node_bool_prop,/pcb,ls-fuse)
|
|
help
|
|
If enabled, the DC/DC control function will detect if the high-side MOSFET has failed
|
|
short and trip the fuse by switching the low-side MOSFET continuously on. This will prevent
|
|
accidental overcharging of the battery.
|
|
|
|
Only available if the board has a fuse at the low-side terminal (ls-fuse property of the
|
|
pcb devicetree node).
|
|
|
|
#
|
|
# Visible (user-configurable) Kconfig symbols
|
|
#
|
|
|
|
menu "Charge Controller Setup"
|
|
|
|
choice
|
|
prompt "High-voltage terminal"
|
|
depends on $(dt_nodelabel_enabled,halfbridge)
|
|
help
|
|
Select the device connected to the high-voltage
|
|
side terminal of the DC/DC converter.
|
|
|
|
config HV_TERMINAL_SOLAR
|
|
bool "Solar panel"
|
|
|
|
config HV_TERMINAL_NANOGRID
|
|
bool "DC nanogrid"
|
|
|
|
config HV_TERMINAL_GENERATOR
|
|
bool "DC generator, e.g. wind turbine"
|
|
|
|
config HV_TERMINAL_BATTERY
|
|
bool "Battery, e.g. electric bicycle"
|
|
endchoice
|
|
|
|
|
|
choice
|
|
prompt "Low-voltage terminal"
|
|
help
|
|
Select the device connected to the low-voltage side
|
|
of the charge controller (usually battery terminal).
|
|
|
|
config LV_TERMINAL_BATTERY
|
|
depends on !HV_TERMINAL_BATTERY
|
|
bool "Battery 12V/24V"
|
|
|
|
config LV_TERMINAL_SOLAR
|
|
depends on HV_TERMINAL_BATTERY || HV_TERMINAL_NANOGRID
|
|
bool "Solar panel"
|
|
endchoice
|
|
|
|
|
|
choice
|
|
prompt "PWM terminal"
|
|
depends on $(dt_nodelabel_enabled,pwm_switch)
|
|
help
|
|
Select the device connected to the PWM switch (currently
|
|
only solar panel possible)
|
|
|
|
config PWM_TERMINAL_SOLAR
|
|
depends on LV_TERMINAL_BATTERY && !HV_TERMINAL_SOLAR
|
|
bool "Solar panel"
|
|
endchoice
|
|
|
|
|
|
menu "Battery default settings"
|
|
|
|
config BAT_CAPACITY_AH
|
|
int "Battery nominal capacity in Ah"
|
|
range 10 1000
|
|
default 50
|
|
help
|
|
Nominal battery capacity or sum of parallel cells capacity
|
|
|
|
choice
|
|
prompt "Battery type"
|
|
default BAT_TYPE_GEL
|
|
help
|
|
Select the type of the single cells inside the battery
|
|
to determine voltage set points. Total voltage set points
|
|
are multiplied with the selected number of cells.
|
|
|
|
config BAT_TYPE_CUSTOM
|
|
bool "Custom type"
|
|
|
|
config BAT_TYPE_FLOODED
|
|
bool "Flooded (wet) lead-acid"
|
|
|
|
config BAT_TYPE_GEL
|
|
bool "VRLA gel, maintainance-free"
|
|
|
|
config BAT_TYPE_AGM
|
|
bool "AGM, maintainance-free"
|
|
|
|
config BAT_TYPE_LFP
|
|
bool "LiFePO4 Li-ion, 3.3V nominal"
|
|
|
|
config BAT_TYPE_NMC
|
|
bool "NMC/Graphite Li-ion, 3.7V nominal, 4.2V max"
|
|
|
|
config BAT_TYPE_NMC_HV
|
|
bool "NMC/Graphite High Voltage Li-ion, 3.7V nominal, 4.35 max"
|
|
endchoice
|
|
|
|
# values must match enum BatType in bat_charger.h
|
|
config BAT_TYPE
|
|
int
|
|
default 0 if BAT_TYPE_CUSTOM
|
|
default 1 if BAT_TYPE_FLOODED
|
|
default 2 if BAT_TYPE_GEL
|
|
default 3 if BAT_TYPE_AGM
|
|
default 4 if BAT_TYPE_LFP
|
|
default 5 if BAT_TYPE_NMC
|
|
default 6 if BAT_TYPE_NMC_HV
|
|
|
|
config BAT_NUM_CELLS
|
|
int "Number of cells for single battery"
|
|
default 6 if BAT_TYPE_FLOODED || BAT_TYPE_GEL || BAT_TYPE_AGM
|
|
default 4 if BAT_TYPE_LFP
|
|
default 3 if BAT_TYPE_NMC || BAT_TYPE_NMC_HV
|
|
range 3 16
|
|
help
|
|
Typical choices:
|
|
- 6 for 12V lead-acid battery
|
|
- 4 for 12V LiFePO4 battery
|
|
- 3 for 12V NMC Li-ion battery
|
|
|
|
Remarks:
|
|
- If you choose settings for 12V system, 24V systems
|
|
(2 batteries in series) are recognized automatically
|
|
- Make sure the voltage of the used charge controller
|
|
is not exceeded.
|
|
|
|
menu "Custom cell-level settings"
|
|
depends on BAT_TYPE_CUSTOM
|
|
|
|
config CELL_ABS_MAX_VOLTAGE_MV
|
|
int "Absolute maximum voltage (mV)"
|
|
default 2450
|
|
help
|
|
Above this voltage the battery or loads might get damaged.
|
|
|
|
config CELL_TOPPING_VOLTAGE_MV
|
|
int "Topping voltage (mV)"
|
|
default 2400
|
|
help
|
|
Charger target voltage, switching from CC to CV at this voltage threshold.
|
|
|
|
config CELL_RECHARGE_VOLTAGE_MV
|
|
int "Recharge voltage (mV)"
|
|
default 2300
|
|
help
|
|
Start charging again if voltage of fully charged battery drops below this threshold.
|
|
|
|
config CELL_RECONNECT_VOLTAGE_MV
|
|
int "Load reconnect cell voltage (mV)"
|
|
default 2100
|
|
help
|
|
Re-enable the load only after charged beyond this value.
|
|
|
|
config CELL_DISCONNECT_VOLTAGE_MV
|
|
int "Load disconnect cell voltage (mV)"
|
|
default 1950
|
|
help
|
|
Load output is disabled if battery voltage is below this threshold.
|
|
|
|
config CELL_ABS_MIN_VOLTAGE_MV
|
|
int "Topping voltage (mV)"
|
|
default 1600
|
|
help
|
|
Below this voltage the battery is considered damaged.
|
|
|
|
config CELL_OCV_FULL_MV
|
|
int "OCV full cell (mV)"
|
|
default 2150
|
|
help
|
|
Voltages during idle (no charging/discharging current)
|
|
|
|
config CELL_OCV_EMPTY_MV
|
|
int "OCV empty cell (mV)"
|
|
default 1900
|
|
help
|
|
Voltages during idle (no charging/discharging current)
|
|
|
|
config CELL_FLOAT
|
|
bool "Enable float charging phase"
|
|
default y
|
|
|
|
config CELL_FLOAT_VOLTAGE_MV
|
|
int "Float charging cell voltage (mV)" if CELL_FLOAT
|
|
default 2300
|
|
help
|
|
Charger target voltage for float charging of lead-acid batteries
|
|
|
|
config CELL_FLOAT_RECHARGE_TIME
|
|
int "Float recharge time (s)" if CELL_FLOAT
|
|
default 1800
|
|
help
|
|
If the float voltage is not reached anymore (e.g. because of lack of solar
|
|
input power) for this period of time, the charger state machine goes back
|
|
into CC/bulk charging mode.
|
|
|
|
config CELL_EQUALIZATION
|
|
bool "Enable equalization phase"
|
|
default n
|
|
help
|
|
Enable for flooded batteries only.
|
|
|
|
config CELL_EQUALIZATION_VOLTAGE_MV
|
|
int "Equalization phase cell voltage (mV)" if CELL_EQUALIZATION
|
|
default 2450
|
|
help
|
|
Charger target voltage for equalization charging of lead-acid batteries
|
|
|
|
config CELL_EQUALIZATION_DURATION
|
|
int "Equalization duration (seconds)" if CELL_EQUALIZATION
|
|
default 3600
|
|
help
|
|
After this time, equalization charging is stopped.
|
|
|
|
config CELL_EQUALIZATION_TRIGGER_DAYS
|
|
int "Equalization time trigger (days)" if CELL_EQUALIZATION
|
|
default 60
|
|
help
|
|
After passing specified amount of days, an equalization charge is triggered.
|
|
|
|
config CELL_EQUALIZATION_TRIGGER_DEEP_CYCLES
|
|
int "Equalization deep cycle count trigger" if CELL_EQUALIZATION
|
|
default 10
|
|
help
|
|
After specified number of deep discharges, an equalization charge is triggered.
|
|
|
|
config CELL_TEMP_COMPENSATION_MV_K
|
|
int "Cell voltage temperature compenstaion (mV/K)"
|
|
range -5 0
|
|
default -3
|
|
help
|
|
Suggested value: -3 mV/K/cell for lead-acid batteries, 0 for Li-ion batteries
|
|
|
|
config CELL_INTERNAL_RESISTANCE_MOHM
|
|
int "Cell internal resistance (mOhm)"
|
|
range 1 30
|
|
default 5
|
|
|
|
endmenu # Custom cell-level settings
|
|
|
|
menu "Custom temperature settings"
|
|
depends on BAT_TYPE_CUSTOM
|
|
|
|
config BAT_CHARGE_TEMP_MAX
|
|
int "Maximum charge temperature (°C)"
|
|
range 0 60
|
|
default 50
|
|
|
|
config BAT_CHARGE_TEMP_MIN
|
|
int "Minimum charge temperature (°C)"
|
|
range -10 20
|
|
default 0
|
|
|
|
config BAT_DISCHARGE_TEMP_MAX
|
|
int "Maximum discharge temperature (°C)"
|
|
range 0 60
|
|
default 50
|
|
|
|
config BAT_DISCHARGE_TEMP_MIN
|
|
int "Minimum discharge temperature (°C)"
|
|
range -20 20
|
|
default -10
|
|
|
|
endmenu # Custom temperature settings
|
|
|
|
endmenu # Battery default settings
|
|
|
|
|
|
menu "Load output settings"
|
|
depends on $(dt_nodelabel_enabled,load_switch)
|
|
|
|
config LOAD_OC_RECOVERY_DELAY
|
|
int "Overcurrent recovery delay (s)"
|
|
default 300
|
|
|
|
config LOAD_LVD_RECOVERY_DELAY
|
|
int "Low-voltage disconnect recovery delay (s)"
|
|
default 300
|
|
help
|
|
Prevents toggling load output in case of heavy load and low state of charge.
|
|
|
|
endmenu # Load output settings
|
|
|
|
|
|
endmenu # Charge controller setup
|
|
|
|
|
|
menu "UEXT port"
|
|
|
|
DT_CHOSEN_Z_DISPLAY := zephyr,display
|
|
|
|
config UEXT_OLED_DISPLAY
|
|
bool "OLED display"
|
|
depends on $(dt_chosen_enabled,$(DT_CHOSEN_Z_DISPLAY))
|
|
default y if SHIELD_UEXT_OLED
|
|
select DISPLAY
|
|
select CHARACTER_FRAMEBUFFER
|
|
help
|
|
Show live data on a SSD1306 128x64 OLED display connected to the UEXT
|
|
port. The display is configured via the uext_oled shield:
|
|
|
|
west build -b <board> app -- -DSHIELD=uext_oled
|
|
|
|
The brightness can be changed via CONFIG_SSD1306_DEFAULT_CONTRAST.
|
|
|
|
config HEAP_MEM_POOL_ADD_SIZE_UEXT_OLED
|
|
int
|
|
default 1280 if UEXT_OLED_DISPLAY
|
|
default 0
|
|
help
|
|
Frame buffer allocated by the character framebuffer subsystem (1024 bytes) plus some
|
|
margin for the heap management overhead.
|
|
|
|
config CHARACTER_FRAMEBUFFER_USE_DEFAULT_FONTS
|
|
default n if UEXT_OLED_DISPLAY
|
|
|
|
endmenu # UEXT port
|
|
|
|
menu "Logging setup"
|
|
|
|
config CAN_LOG_LEVEL
|
|
int "Log level for the CAN module (if included)"
|
|
default 2
|
|
depends on LOG
|
|
help
|
|
Log level for the CAN module (if included). 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
|
|
|
|
config DATA_OBJECTS_LOG_LEVEL
|
|
int "Log level for the data objects module"
|
|
default 2
|
|
depends on LOG
|
|
help
|
|
Log level for the data nodes module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
|
|
|
|
config DATA_STORAGE_LOG_LEVEL
|
|
int "Log level for the data storage module"
|
|
default 2
|
|
depends on LOG
|
|
help
|
|
Log level for the data storage module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
|
|
|
|
config DCDC_LOG_LEVEL
|
|
int "Log level for the DCDC module (if included)"
|
|
default 2
|
|
depends on LOG
|
|
help
|
|
Log level for the DCDC module (if included). 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
|
|
|
|
config BAT_LOG_LEVEL
|
|
int "Log level for the battery module"
|
|
default 2
|
|
depends on LOG
|
|
help
|
|
Log level for the battery module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
|
|
|
|
config LOAD_LOG_LEVEL
|
|
int "Log level for the load output module (if included)"
|
|
default 2
|
|
depends on LOG
|
|
help
|
|
Log level for the load output module (if included). 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
|
|
|
|
config PWM_LOG_LEVEL
|
|
int "Log level for the PWM module (if included)"
|
|
default 2
|
|
depends on LOG
|
|
help
|
|
Log level for the PWM module (if included). 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
|
|
|
|
endmenu # Logging setup
|
|
|
|
menuconfig CUSTOMIZATION
|
|
bool "Firmware customization"
|
|
help
|
|
Activating this option allows to overwrite existing firmware functions
|
|
or add customizations independent of the main branch.
|
|
Custom implementations should be stored in the
|
|
src/custom subdirectory.
|
|
|
|
if CUSTOMIZATION
|
|
|
|
config CUSTOM_DATA_OBJECTS_FILE
|
|
bool "Use custom data nodes file"
|
|
default n
|
|
help
|
|
Use the file data_objects_custom.cpp instead of the default data_objects.cpp
|
|
for ThingSet configuration.
|
|
|
|
config CUSTOM_DCDC_CONTROLLER
|
|
bool "Custom implementation of DC/DC controller"
|
|
depends on $(dt_nodelabel_enabled,halfbridge)
|
|
default n
|
|
help
|
|
Use a custom implementation instead of the default perturb & observe
|
|
MPPT control.
|
|
|
|
endif
|
|
|
|
# include custom Kconfig if existing
|
|
orsource "../src/custom/Kconfig"
|
|
|
|
# include main Zephyr menu entries from Zephyr root directory
|
|
source "Kconfig.zephyr"
|