Make default battery type configurable via Kconfig

This commit is contained in:
Martin Jäger
2020-05-06 12:53:26 +02:00
parent d2dd50fe99
commit 1252a1ffa1
4 changed files with 25 additions and 7 deletions
+10
View File
@@ -109,6 +109,16 @@ choice
endchoice
# values must match enum BatType in bat_charger.h
config BAT_DEFAULT_TYPE
int
default 1 if BAT_DEFAULT_TYPE_FLOODED
default 2 if BAT_DEFAULT_TYPE_GEL
default 3 if BAT_DEFAULT_TYPE_AGM
default 4 if BAT_DEFAULT_TYPE_LFP
default 5 if BAT_DEFAULT_TYPE_NMC
default 6 if BAT_DEFAULT_TYPE_NMC_HV
config BAT_DEFAULT_NUM_CELLS
int "Default number of battery cells"
default 6
+1 -1
View File
@@ -16,7 +16,7 @@
extern DeviceStatus dev_stat;
extern LoadOutput load;
void battery_conf_init(BatConf *bat, BatType type, int num_cells, float nominal_capacity)
void battery_conf_init(BatConf *bat, int type, int num_cells, float nominal_capacity)
{
bat->nominal_capacity = nominal_capacity;
+12 -2
View File
@@ -19,9 +19,13 @@
#include "power_port.h"
/** Battery cell types
/**
* Battery cell types
*/
enum BatType {
/*
* IMPORTANT: make sure to adjust also boards/Kconfig if enum is changed here!
*/
BAT_TYPE_NONE = 0, ///< Safe standard settings
BAT_TYPE_FLOODED, ///< Old flooded (wet) lead-acid batteries
BAT_TYPE_GEL, ///< VRLA gel batteries (maintainance-free)
@@ -342,8 +346,14 @@ enum ChargerState {
*
* Configures battery based on settings defined in config.h and initializes
* bat_user with same values
*
* @param bat Battery configuration that should be initialized
* @param type Battery type, one of enum BatType (declared as int instead of enum BatType because
* configuration via Kconfig symbol cannot handle enums)
* @param num_cells Number of cells (e.g. 6 for 12V lead-acid battery)
* @param nominal_capacity Nominal capacity (Ah)
*/
void battery_conf_init(BatConf *bat, BatType type, int num_cells, float nominal_capacity);
void battery_conf_init(BatConf *bat, int type, int num_cells, float nominal_capacity);
/** Checks battery user settings for plausibility
*/
+2 -4
View File
@@ -35,10 +35,8 @@ void main(void)
setup();
battery_conf_init(&bat_conf,
BAT_TYPE_GEL, // temporary!!
CONFIG_BAT_DEFAULT_NUM_CELLS,
CONFIG_BAT_DEFAULT_CAPACITY_AH);
battery_conf_init(&bat_conf, CONFIG_BAT_DEFAULT_TYPE,
CONFIG_BAT_DEFAULT_NUM_CELLS, CONFIG_BAT_DEFAULT_CAPACITY_AH);
battery_conf_overwrite(&bat_conf, &bat_conf_user); // initialize conf_user with same values
// read custom configuration from EEPROM