Sync changed between system76 boards

This commit is contained in:
Jeremy Soller 2020-04-05 08:47:24 -06:00
parent 825677bfb5
commit d901907942
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
5 changed files with 57 additions and 37 deletions

View File

@ -402,14 +402,14 @@ void power_event(void) {
}
}
static uint32_t last_time = 0;
uint32_t time = time_get();
if (power_state == POWER_STATE_S0) {
// CPU on, green light
gpio_set(&LED_PWR, true);
gpio_set(&LED_ACIN, false);
} else if (power_state == POWER_STATE_S3 || power_state == POWER_STATE_DS3) {
// Suspended, flashing green light
static uint32_t last_time = 0;
uint32_t time = time_get();
if (
(time < last_time) // overflow
||
@ -424,9 +424,16 @@ void power_event(void) {
gpio_set(&LED_PWR, false);
gpio_set(&LED_ACIN, true);
} else {
// CPU off and AC adapter unplugged, no light
// CPU off and AC adapter unplugged, flashing orange light
gpio_set(&LED_PWR, false);
gpio_set(&LED_ACIN, false);
if (
(time < last_time) // overflow
||
(time >= (last_time + 1000)) // timeout
) {
gpio_set(&LED_ACIN, !gpio_get(&LED_ACIN));
last_time = time;
}
}
#endif // DEEP_SX
}

View File

@ -2,6 +2,9 @@
#include <common/macro.h>
#include <ec/dac.h>
#define KBLED_DAC 5
#define KBLED_DACDAT DACDAT5
static uint8_t __code levels[] = {
0x00,
0x80,
@ -12,15 +15,15 @@ static uint8_t __code levels[] = {
};
void kbled_init(void) {
// Enable DAC5, used for KBLIGHT_ADJ
DACPDREG &= ~(1 << 5);
// Set DAC5 to 0V
DACDAT5 = 0;
// Enable DAC used for KBLIGHT_ADJ
DACPDREG &= ~(1 << KBLED_DAC);
// Set DAC to 0V
KBLED_DACDAT = 0;
}
uint8_t kbled_get(void) {
uint8_t level;
uint8_t raw = DACDAT5;
uint8_t raw = KBLED_DACDAT;
for (level = 0; level < ARRAY_SIZE(levels); level++) {
if (raw <= levels[level]) {
return level;
@ -34,5 +37,5 @@ void kbled_set(uint8_t level) {
if (level < ARRAY_SIZE(levels)) {
raw = levels[level];
}
DACDAT5 = raw;
KBLED_DACDAT = raw;
}

View File

@ -399,14 +399,14 @@ void power_event(void) {
}
}
static uint32_t last_time = 0;
uint32_t time = time_get();
if (power_state == POWER_STATE_S0) {
// CPU on, green light
gpio_set(&LED_PWR, true);
gpio_set(&LED_ACIN, false);
} else if (power_state == POWER_STATE_S3 || power_state == POWER_STATE_DS3) {
// Suspended, flashing green light
static uint32_t last_time = 0;
uint32_t time = time_get();
if (
(time < last_time) // overflow
||
@ -421,9 +421,16 @@ void power_event(void) {
gpio_set(&LED_PWR, false);
gpio_set(&LED_ACIN, true);
} else {
// CPU off and AC adapter unplugged, no light
// CPU off and AC adapter unplugged, flashing orange light
gpio_set(&LED_PWR, false);
gpio_set(&LED_ACIN, false);
if (
(time < last_time) // overflow
||
(time >= (last_time + 1000)) // timeout
) {
gpio_set(&LED_ACIN, !gpio_get(&LED_ACIN));
last_time = time;
}
}
#endif // DEEP_SX
}

View File

@ -2,6 +2,9 @@
#include <common/macro.h>
#include <ec/dac.h>
#define KBLED_DAC 2
#define KBLED_DACDAT DACDAT2
static uint8_t __code levels[] = {
0x00,
0x80,
@ -12,15 +15,15 @@ static uint8_t __code levels[] = {
};
void kbled_init(void) {
// Enable DAC2, used for KBLIGHT_ADJ
DACPDREG &= ~(1 << 2);
// Set DAC2 to 0V
DACDAT2 = 0;
// Enable DAC used for KBLIGHT_ADJ
DACPDREG &= ~(1 << KBLED_DAC);
// Set DAC to 0V
KBLED_DACDAT = 0;
}
uint8_t kbled_get(void) {
uint8_t level;
uint8_t raw = DACDAT2;
uint8_t raw = KBLED_DACDAT;
for (level = 0; level < ARRAY_SIZE(levels); level++) {
if (raw <= levels[level]) {
return level;
@ -34,5 +37,5 @@ void kbled_set(uint8_t level) {
if (level < ARRAY_SIZE(levels)) {
raw = levels[level];
}
DACDAT2 = raw;
KBLED_DACDAT = raw;
}