summaryrefslogtreecommitdiff
path: root/board/nyan/battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/nyan/battery.c')
-rw-r--r--board/nyan/battery.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/board/nyan/battery.c b/board/nyan/battery.c
index 6bd445fdf4..7ebfd594da 100644
--- a/board/nyan/battery.c
+++ b/board/nyan/battery.c
@@ -30,6 +30,39 @@ struct battery_device {
int support_cut_off;
};
+/*
+ * Used for the case that battery cannot be detected, such as the pre-charge
+ * case. In this case, we need to provide the battery with the enough voltage
+ * (usually the highest voltage among batteries, but the smallest precharge
+ * current). This should be as conservative as possible.
+ */
+static struct battery_info info_precharge = {
+ /*
+ * Design voltage
+ * max = 8.4V
+ * normal = 7.4V
+ * min = 6.0V
+ */
+ .voltage_max = 12600, /* the max voltage among batteries */
+ .voltage_normal = 11100,
+ .voltage_min = 9000,
+
+ /* Pre-charge current: I <= 0.01C */
+ .precharge_current = 64, /* mA, the min current among batteries */
+
+ /*
+ * Operational temperature range
+ * 0 <= T_charge <= 50 deg C
+ * -20 <= T_discharge <= 60 deg C
+ */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 50,
+ .discharging_min_c = 0,
+ .discharging_max_c = 60,
+};
+
static struct battery_info info_2s = {
/*
* Design voltage
@@ -204,16 +237,16 @@ const struct battery_info *battery_get_info(void)
if (battery_manufacturer_name(manuf, sizeof(manuf))) {
CPRINTF("[%T Failed to get MANUF name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_device_name(device, sizeof(device))) {
CPRINTF("[%T Failed to get DEVICE name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_design_voltage((int *)&design_mv)) {
CPRINTF("[%T Failed to get DESIGN_VOLTAGE]\n");
- return NULL;
+ return &info_precharge;
}
for (i = 0; i < ARRAY_SIZE(support_batteries); ++i) {
@@ -228,7 +261,9 @@ const struct battery_info *battery_get_info(void)
}
}
- return NULL;
+ CPRINTF("[%T un-recognized battery Manuf:%s, Device=%s]\n",
+ manuf, device);
+ return &info_precharge;
}
int battery_command_cut_off(struct host_cmd_handler_args *args)