summaryrefslogtreecommitdiff
path: root/nuttx/configs/skp16c26/src/up_buttons.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-02-20 00:59:18 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-02-20 00:59:18 +0000
commit514a82fa266dbaffe22caf7013aa89b76d70de0a (patch)
tree96bd4c27aa46c55ca7f4e37749b7cdbe6aff164b /nuttx/configs/skp16c26/src/up_buttons.c
parent01f422d3de8c1d02b4183b9bbbbf91eb0d42a58f (diff)
downloadpx4-nuttx-514a82fa266dbaffe22caf7013aa89b76d70de0a.tar.gz
px4-nuttx-514a82fa266dbaffe22caf7013aa89b76d70de0a.tar.bz2
px4-nuttx-514a82fa266dbaffe22caf7013aa89b76d70de0a.zip
Add support for M16C buttons and LEDs
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1519 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/skp16c26/src/up_buttons.c')
-rw-r--r--nuttx/configs/skp16c26/src/up_buttons.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/nuttx/configs/skp16c26/src/up_buttons.c b/nuttx/configs/skp16c26/src/up_buttons.c
index 5785532bc..64d9d7345 100644
--- a/nuttx/configs/skp16c26/src/up_buttons.c
+++ b/nuttx/configs/skp16c26/src/up_buttons.c
@@ -48,6 +48,14 @@
* Definitions
****************************************************************************/
+/* The SKP62C26 has 3 buttons control by bits 1, 2, and 3 in port 8. */
+
+#define SW1_BIT (1 << 3) /* Bit 3, port 8 */
+#define SW2_BIT (1 << 2) /* Bit 2, port 8 */
+#define SW3_BIT (1 << 1) /* Bit 1, port 8 */
+
+#define SW_PRESSED(p,b) (((p) & (b)) == 0)
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -67,6 +75,11 @@
#ifdef CONFIG_ARCH_BUTTONS
void up_buttoninit(void)
{
+ ubyte regval;
+
+ regval = getreg8(M16C_PD8);
+ regval |= (SW1_BIT | SW2_BIT | SW3_BIT);
+ putreg8(regval, M16C_PD8);
}
/****************************************************************************
@@ -75,5 +88,24 @@ void up_buttoninit(void)
ubyte up_buttons(void)
{
+ ubyte swset = 0;
+ ubyte regval = getreg8(M16C_P8);
+
+ if (SW_PRESSED(regval, SW1_BIT))
+ {
+ swset |= SW1_PRESSED;
+ }
+
+ if (SW_PRESSED(regval, SW2_BIT))
+ {
+ swset |= SW2_PRESSED;
+ }
+
+ if (SW_PRESSED(regval, SW3_BIT))
+ {
+ swset |= SW3_PRESSED;
+ }
+
+ return swset;
}
#endif /* CONFIG_ARCH_BUTTONS */