Reduce smbus speed to 50 KHz

This commit is contained in:
Jeremy Soller 2019-11-10 20:25:15 -07:00
parent 7b30477009
commit 285e9bc437
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 9 additions and 6 deletions

View File

@ -56,7 +56,7 @@ void ac_adapter() {
static struct Gpio __code ACIN_N = GPIO(B, 6); static struct Gpio __code ACIN_N = GPIO(B, 6);
static struct Gpio __code LED_ACIN = GPIO(C, 7); static struct Gpio __code LED_ACIN = GPIO(C, 7);
static bool last = false; static bool last = true;
// Check if the adapter line goes low // Check if the adapter line goes low
bool new = gpio_get(&ACIN_N); bool new = gpio_get(&ACIN_N);
@ -68,9 +68,12 @@ void ac_adapter() {
printf("Power adapter "); printf("Power adapter ");
if (new) { if (new) {
printf("unplugged\n"); printf("unplugged\n");
battery_charger_disable();
} else { } else {
printf("plugged in\n"); printf("plugged in\n");
battery_charger_enable();
} }
battery_debug();
} }
last = new; last = new;
@ -122,7 +125,7 @@ void power_button() {
// Enable battery charger - also provides correct power levels for // Enable battery charger - also provides correct power levels for
// system boot sourced from the AC adapter // system boot sourced from the AC adapter
//battery_charger_enable(); // battery_charger_enable();
// Make sure VCCDSW is stable for at least 10 ms (tPCH02) // Make sure VCCDSW is stable for at least 10 ms (tPCH02)
delay_ms(10 + 5); delay_ms(10 + 5);
@ -252,7 +255,7 @@ void power_button() {
delay_ms(1); delay_ms(1);
// Disable battery charger // Disable battery charger
//battery_charger_disable(); // battery_charger_disable();
} }
printf("LED_PWR: %d\n", power); printf("LED_PWR: %d\n", power);
@ -266,7 +269,7 @@ void power_button() {
printf("ALL_SYS_PWRGD: %d\n", gpio_get(&ALL_SYS_PWRGD)); printf("ALL_SYS_PWRGD: %d\n", gpio_get(&ALL_SYS_PWRGD));
printf("BUF_PLT_RST_N: %d\n", gpio_get(&BUF_PLT_RST_N)); printf("BUF_PLT_RST_N: %d\n", gpio_get(&BUF_PLT_RST_N));
//battery_debug(); // battery_debug();
} }
last = new; last = new;

View File

@ -9,8 +9,8 @@ void smbus_init(void) {
SMB45P3USL = 0x5C; SMB45P3USL = 0x5C;
SMB45P3USH = 0x01; SMB45P3USH = 0x01;
// Clock to 400 KHz // Clock to 50 KHz
SCLKTSA = 3; SCLKTSA = 1;
// Enable host interface // Enable host interface
HOCTL2A = 1 << 0; HOCTL2A = 1 << 0;