Sync changed between system76 boards

This commit is contained in:
Jeremy Soller
2020-04-05 08:47:24 -06:00
parent 825677bfb5
commit d901907942
5 changed files with 57 additions and 37 deletions

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;
}

View File

@@ -33,25 +33,25 @@ void kbscan_init(void) {
#define DEBOUNCE_DELAY 20
static uint8_t kbscan_get_row(int i) {
// Set current line as output
if (i < 8) {
KSOLGOEN = 1 << i;
KSOHGOEN = 0;
} else if (i < 16) {
KSOLGOEN = 0;
KSOHGOEN = 1 << (i - 8);
} else if (i == 16) {
KSOLGOEN = 0;
KSOHGOEN = 0;
} else if (i == 17) {
KSOLGOEN = 0;
KSOHGOEN = 0;
}
// Set current line as output
if (i < 8) {
KSOLGOEN = 1 << i;
KSOHGOEN = 0;
} else if (i < 16) {
KSOLGOEN = 0;
KSOHGOEN = 1 << (i - 8);
} else if (i == 16) {
KSOLGOEN = 0;
KSOHGOEN = 0;
} else if (i == 17) {
KSOLGOEN = 0;
KSOHGOEN = 0;
}
// TODO: figure out optimal delay
delay_ticks(10);
// TODO: figure out optimal delay
delay_ticks(10);
return ~KSI;
return ~KSI;
}
static inline bool popcount_more_than_one(uint8_t rowdata) {