summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-03-04 15:38:32 +0800
committerChromeBot <chrome-bot@google.com>2013-03-04 16:44:48 -0800
commit1866d471f496a4b6905332199f870cc45b7f2515 (patch)
treeed7ca309ef26c8e0cc7fcf09f5e1186002a84684 /board
parent6249a400696f270e7c9216db8e2998d7331f4613 (diff)
downloadchrome-ec-1866d471f496a4b6905332199f870cc45b7f2515.tar.gz
spring: battery LED breath yellow on battery assist
When in battery assit mode, show breathing yellow on battery LED slowly to indicate battery is actually discharging. BUG=chrome-os-partner:17561 TEST=Manual BRANCH=none Change-Id: I688470d8870b181bf2dd20b5ebcbd6e2d861c5b0 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/44514 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/spring/board.c72
1 files changed, 63 insertions, 9 deletions
diff --git a/board/spring/board.c b/board/spring/board.c
index da74c966ee..d7e7224bd2 100644
--- a/board/spring/board.c
+++ b/board/spring/board.c
@@ -31,10 +31,20 @@
#define HARD_RESET_TIMEOUT_MS 5
/* We use yellow LED instead of blue LED. Re-map colors here. */
+#define LED_COLOR_NONE LP5562_COLOR_NONE
#define LED_COLOR_GREEN LP5562_COLOR_GREEN
#define LED_COLOR_YELLOW LP5562_COLOR_BLUE
#define LED_COLOR_RED LP5562_COLOR_RED
+/* LED breathing program */
+uint8_t breathing_prog[] = {0x41, 0xff, /* 0x80 -> 0x0 */
+ 0x41, 0x7f, /* 0x0 -> 0x80 */
+ 0x7f, 0x00, /* Wait ~4s */
+ 0x7f, 0x00,
+ 0x7f, 0x00,
+ 0x7f, 0x00,
+ 0x00, 0x00}; /* Repeat */
+
/* GPIO interrupt handlers prototypes */
#ifndef CONFIG_TASK_GAIAPOWER
#define gaia_power_event NULL
@@ -299,11 +309,38 @@ int board_get_ac(void)
adc_read_channel(ADC_CH_USB_VBUS_SNS) >= 4300;
}
+int board_led_breathing(int enabled)
+{
+ int ret = 0;
+
+ if (!enabled) {
+ return lp5562_engine_control(LP5562_ENG_HOLD,
+ LP5562_ENG_HOLD,
+ LP5562_ENG_HOLD);
+ }
+
+ ret |= lp5562_engine_load(LP5562_ENG_SEL_1,
+ breathing_prog,
+ sizeof(breathing_prog));
+ ret |= lp5562_set_engine(LP5562_ENG_SEL_NONE,
+ LP5562_ENG_SEL_NONE,
+ LP5562_ENG_SEL_1);
+ ret |= lp5562_engine_control(LP5562_ENG_RUN,
+ LP5562_ENG_HOLD,
+ LP5562_ENG_HOLD);
+
+ return ret;
+}
+
int board_battery_led(enum charging_state state)
{
int current;
int desired_current;
- uint32_t color = LED_COLOR_RED;
+ static uint32_t color = LED_COLOR_RED;
+ static int breathing;
+ int new_color = LED_COLOR_RED;
+ int new_breathing = 0;
+ int ret = 0;
/*
* LED power is controlled by accessory detection. We only
@@ -311,30 +348,47 @@ int board_battery_led(enum charging_state state)
*/
switch (state) {
case ST_IDLE:
- color = LED_COLOR_GREEN;
+ new_color = LED_COLOR_GREEN;
+ break;
+ case ST_DISCHARGING:
+ new_color = LED_COLOR_NONE;
break;
- case ST_DISCHARGING: /* Battery assist */
case ST_PRE_CHARGING:
- color = LED_COLOR_YELLOW;
+ new_color = LED_COLOR_YELLOW;
break;
case ST_CHARGING:
if (battery_current(&current) ||
battery_desired_current(&desired_current)) {
/* Cannot talk to the battery. Set LED to red. */
- color = LED_COLOR_RED;
+ new_color = LED_COLOR_RED;
+ break;
+ }
+
+ if (current < 0 && desired_current > 0) { /* Battery assist */
+ new_breathing = 1;
+ new_color = LED_COLOR_NONE;
break;
}
+
if (current && desired_current)
- color = LED_COLOR_YELLOW;
+ new_color = LED_COLOR_YELLOW;
else
- color = LED_COLOR_GREEN;
+ new_color = LED_COLOR_GREEN;
break;
case ST_CHARGING_ERROR:
- color = LED_COLOR_RED;
+ new_color = LED_COLOR_RED;
break;
}
- return lp5562_set_color(color);
+ if (new_breathing != breathing) {
+ ret |= board_led_breathing(new_breathing);
+ breathing = new_breathing;
+ }
+ if (new_color != color) {
+ ret |= lp5562_set_color(new_color);
+ color = new_color;
+ }
+ return ret;
}
/*****************************************************************************/