summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <ichgeh@l--putt.de>2011-06-22 23:50:44 +0200
committerStefan Richter <ichgeh@l--putt.de>2011-06-22 23:50:44 +0200
commit0a9fab9abe80fe61e9c068e78c517c45d669935f (patch)
treed31f44d07bb3bb8e19fb4fca9be21e4e882fc02f
parentcb406b286c33793539ceedee2bcf97d4779c0ff9 (diff)
HACK: Cut power on release of power buttonlputt/testing
-rw-r--r--nuttx/arch/arm/src/calypso/calypso_keypad.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/nuttx/arch/arm/src/calypso/calypso_keypad.c b/nuttx/arch/arm/src/calypso/calypso_keypad.c
index c164baffe6..4a63a70cc3 100644
--- a/nuttx/arch/arm/src/calypso/calypso_keypad.c
+++ b/nuttx/arch/arm/src/calypso/calypso_keypad.c
@@ -51,6 +51,33 @@
/****************************************************************************
+ * Power control
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <nuttx/spi.h>
+
+int poweroff(void)
+{
+ uint16_t tx;
+ struct spi_dev_s *spi = up_spiinitialize(0);
+
+ printf("cutting power...\n\n");
+ usleep(10000);
+
+ SPI_SETBITS(spi, 16);
+
+ tx = (1 << 6) | (1 << 1);
+ SPI_SNDBLOCK(spi, &tx, 1);
+
+ tx = (1 << 6) | (30 << 1);
+ SPI_SNDBLOCK(spi, &tx, 1);
+
+ return 0;
+}
+
+
+/****************************************************************************
* HW access
****************************************************************************/
@@ -135,6 +162,9 @@ static int pwr_btn_dec(uint32_t *state, uint8_t reg, char *buf, size_t *len)
} else {
/* Check for released power button. */
if(*state & 0x80000000) {
+ /* XXX: just cut power, pending better solution */
+ poweroff();
+
buf[0] = 'Z';
*len = 1;