From 49ef59bc62495eae904a11a017f747e839fdf886 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Tue, 26 Feb 2013 21:17:35 +0100 Subject: Turn off calypso BTS app by pressing power button shortly --- src/target/firmware/apps/trx/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/target/firmware/apps/trx/main.c b/src/target/firmware/apps/trx/main.c index b0170b92..dfca4337 100644 --- a/src/target/firmware/apps/trx/main.c +++ b/src/target/firmware/apps/trx/main.c @@ -41,6 +41,25 @@ #include +#include +#include +static int sercomm_uart; +static void flush_uart(void) +{ + unsigned i; + for (i = 0; i < 500; i++) { + uart_poll(sercomm_uart); + delay_ms(1); + } +} + + +static void device_poweroff(void) +{ + flush_uart(); + twl3025_power_off(); +} + static void key_handler(enum key_codes code, enum key_states state) @@ -49,6 +68,10 @@ key_handler(enum key_codes code, enum key_states state) return; switch (code) { + case KEY_POWER: + puts("Powering off due to keypress.\n"); + device_poweroff(); + break; default: break; } @@ -63,6 +86,7 @@ int main(void) /* Init board */ board_init(1); + sercomm_uart = sercomm_get_uart(); /* Register keypad handler */ keypad_set_handler(&key_handler); -- cgit v1.2.3