Refactor lid switch, disable power button when lid closed and AC disconnected

This commit is contained in:
Jeremy Soller
2020-02-04 13:33:39 -07:00
parent 2388892649
commit d2591be256
14 changed files with 178 additions and 135 deletions

View File

@@ -2,6 +2,7 @@
#include <arch/time.h>
#include <board/battery.h>
#include <board/gpio.h>
#include <board/lid.h>
#include <board/power.h>
#include <board/pmc.h>
#include <board/pnp.h>
@@ -207,6 +208,10 @@ void power_event(void) {
// Read power switch state
static bool ps_last = true;
bool ps_new = gpio_get(&PWR_SW_N);
// Disable power button if lid is closed and AC is disconnected
if (!lid_state && ac_last) {
ps_new = true;
}
if (!ps_new && ps_last) {
// Ensure press is not spurious
delay_ms(10);