aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Fischer <moritz.fischer@ettus.com>2015-09-08 15:54:35 -0700
committerMoritz Fischer <moritz.fischer@ettus.com>2016-01-26 18:19:07 +0100
commit9b8fdb018289219b46974d7a376acb043e1f99c0 (patch)
tree8505ae7aa179a19d88590446333310bb0b48ae0d
parent106405aace27889a4012a918846432d8f70df37b (diff)
downloaduhd-9b8fdb018289219b46974d7a376acb043e1f99c0.tar.gz
uhd-9b8fdb018289219b46974d7a376acb043e1f99c0.tar.bz2
uhd-9b8fdb018289219b46974d7a376acb043e1f99c0.zip
firmware: e3xx: Add panic button functionality.
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
-rw-r--r--firmware/e300/battery/pmu.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/firmware/e300/battery/pmu.c b/firmware/e300/battery/pmu.c
index afd5036fa..59ba171a3 100644
--- a/firmware/e300/battery/pmu.c
+++ b/firmware/e300/battery/pmu.c
@@ -58,11 +58,14 @@ static io_pin_t AVR_IRQ = IO_PD(5);
static io_pin_t PS_POR = IO_PD(6);
static io_pin_t PS_SRST = IO_PD(7);
static io_pin_t OVERTEMP = IO_PC(2);
+static io_pin_t PANICn = IO_PC(1);
static uint16_t last_full_charge;
static uint16_t charge_on_last_unplug;
static bool battery_present_last;
+static bool panic_last;
+
static const uint8_t PMU_BLINK_ERROR_DELAY_MS = 250;
static const uint8_t PMU_BLINK_ERROR_TICKS_PER_BLINK = 10;
@@ -224,6 +227,10 @@ int8_t pmu_init(void)
state = OFF;
+ /* make panic button an input */
+ io_input_pin(PANICn);
+ panic_last = io_test_pin(PANICn);
+
/* make the LED outputs */
io_output_pin(CHARGE);
io_output_pin(POWER_LED);
@@ -525,6 +532,7 @@ void pmu_handle_events(void)
bool is_charging = false;
bool is_full = false;
bool overtemp = io_test_pin(OVERTEMP);
+ bool panic = io_test_pin(PANICn);
/* check if someone plugged the battery late,
* if so init gauge */
@@ -537,6 +545,10 @@ void pmu_handle_events(void)
}
battery_present_last = battery_present;
+ if (panic != panic_last)
+ pmu_power_down();
+ panic_last = panic;
+
if (overtemp) {
fpga_set_gauge_status(BIT(6));
pmu_error = PMU_ERROR_GLOBAL_TEMP;