oryp6: fix battery LEDs

This commit is contained in:
Jeremy Soller 2020-06-24 09:16:14 -06:00
parent 4a291fb3a3
commit 0ba1276f96
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
3 changed files with 7 additions and 8 deletions

View File

@ -65,20 +65,19 @@ void board_event(void) {
} }
if (main_cycle == 0) { if (main_cycle == 0) {
// Battery charging LED is inverted on the oryp6 if (!acin) {
if (acin) {
// Discharging (no AC adapter) // Discharging (no AC adapter)
gpio_set(&LED_BAT_CHG_N, true); gpio_set(&LED_BAT_CHG, false);
gpio_set(&LED_BAT_FULL, false); gpio_set(&LED_BAT_FULL, false);
} else if (battery_current == 0) { } else if (battery_current == 0) {
// Fully charged // Fully charged
// TODO: turn off charger // TODO: turn off charger
gpio_set(&LED_BAT_CHG_N, true); gpio_set(&LED_BAT_CHG, false);
gpio_set(&LED_BAT_FULL, true); gpio_set(&LED_BAT_FULL, true);
} else { } else {
// Charging // Charging
// TODO: detect no battery connected // TODO: detect no battery connected
gpio_set(&LED_BAT_CHG_N, false); gpio_set(&LED_BAT_CHG, true);
gpio_set(&LED_BAT_FULL, false); gpio_set(&LED_BAT_FULL, false);
} }

View File

@ -14,7 +14,7 @@ struct Gpio __code EC_EN = GPIO(B, 6); // renamed to SUSBC_EN
struct Gpio __code EC_RSMRST_N = GPIO(E, 5); struct Gpio __code EC_RSMRST_N = GPIO(E, 5);
struct Gpio __code GC6_FB_EN = GPIO(J, 7); struct Gpio __code GC6_FB_EN = GPIO(J, 7);
struct Gpio __code LED_ACIN = GPIO(C, 7); struct Gpio __code LED_ACIN = GPIO(C, 7);
struct Gpio __code LED_BAT_CHG_N = GPIO(H, 5); struct Gpio __code LED_BAT_CHG = GPIO(H, 5);
struct Gpio __code LED_BAT_FULL = GPIO(J, 0); struct Gpio __code LED_BAT_FULL = GPIO(J, 0);
struct Gpio __code LED_PWR = GPIO(D, 0); struct Gpio __code LED_PWR = GPIO(D, 0);
struct Gpio __code LID_SW_N = GPIO(B, 1); struct Gpio __code LID_SW_N = GPIO(B, 1);
@ -49,7 +49,7 @@ void gpio_init() {
GPDRE = 0x08; GPDRE = 0x08;
GPDRF = 0x40; GPDRF = 0x40;
GPDRG = 0x40; GPDRG = 0x40;
GPDRH = 0x20; GPDRH = 0x00;
GPDRI = 0x20; GPDRI = 0x20;
GPDRJ = 0x02; GPDRJ = 0x02;

View File

@ -26,7 +26,7 @@ extern struct Gpio __code EC_RSMRST_N;
extern struct Gpio __code GC6_FB_EN; extern struct Gpio __code GC6_FB_EN;
extern struct Gpio __code LED_ACIN; extern struct Gpio __code LED_ACIN;
extern struct Gpio __code LED_AIRPLANE_N; extern struct Gpio __code LED_AIRPLANE_N;
extern struct Gpio __code LED_BAT_CHG_N; extern struct Gpio __code LED_BAT_CHG;
extern struct Gpio __code LED_BAT_FULL; extern struct Gpio __code LED_BAT_FULL;
extern struct Gpio __code LED_PWR; extern struct Gpio __code LED_PWR;
extern struct Gpio __code LID_SW_N; extern struct Gpio __code LID_SW_N;