diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index b9d53e7788..804bda0c81 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1981,3 +1981,14 @@ int google_chromeec_set_lightbar_rgb(unsigned int led, int red, int green, return google_chromeec_command(&cmd); } + +/* + * Check if the battery is critically low and not currently charging. + * + * Return true if battery is below threshold and AC is not present. + */ +bool google_chromeec_is_critically_low_on_battery(void) +{ + return google_chromeec_is_below_critical_threshold() && + !google_chromeec_is_charger_present(); +} diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index e5a4b0647d..075694bd4a 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -562,4 +562,11 @@ int google_chromeec_read_batt_state_of_charge(uint32_t *state); int google_chromeec_set_lightbar_rgb(unsigned int led, int red, int green, int blue); +/* + * Check if the battery is critically low and AC is not present. + * + * Return true if battery is below threshold and AC is not present. + */ +bool google_chromeec_is_critically_low_on_battery(void); + #endif /* _EC_GOOGLE_CHROMEEC_EC_H */