aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMoritz Fischer <moritz.fischer@ettus.com>2015-09-08 15:54:35 -0700
committerMartin Braun <martin.braun@ettus.com>2015-10-22 09:31:30 -0700
commit37aa412b1fd72478de5d3de4715680c7651e413b (patch)
tree00b168c254297e5a5bbbcf0d9a467fbd59176ed7 /firmware
parentf4f2b42c03bfb17880debd588459a49ca359c141 (diff)
downloaduhd-37aa412b1fd72478de5d3de4715680c7651e413b.tar.gz
uhd-37aa412b1fd72478de5d3de4715680c7651e413b.tar.bz2
uhd-37aa412b1fd72478de5d3de4715680c7651e413b.zip
firmware: e3xx: Add panic button functionality.
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Diffstat (limited to 'firmware')
-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;