summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-02-26 21:17:35 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2013-02-26 21:17:35 +0100
commit49ef59bc62495eae904a11a017f747e839fdf886 (patch)
tree0d9eb2ccc839961b0c2ba6ad2bc8c7116fa55dec
parent229560765039b1dab64fb8fc212ca59ef65914d2 (diff)
Turn off calypso BTS app by pressing power button shortly
-rw-r--r--src/target/firmware/apps/trx/main.c24
1 files changed, 24 insertions, 0 deletions
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 <fb/framebuffer.h>
+#include <uart.h>
+#include <delay.h>
+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);