summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c
index 965006ce61..b7ce7330c0 100644
--- a/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c
+++ b/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c
@@ -26,10 +26,10 @@
#include "powermgmt.h"
-unsigned short _dbop_din = 0;
+static unsigned short _dbop_din = 0xFFFF;
/* in the lcd driver */
-extern bool lcd_button_support(void);
+extern unsigned short int lcd_dbop_input(void);
static bool hold_button = false;
#ifndef BOOTLOADER
@@ -52,26 +52,6 @@ bool button_hold(void)
return hold_button;
}
-static void button_read_dbop(void)
-{
- /* Set up dbop for input */
- DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */
- DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */
- DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */
- DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
-
- DBOP_CTRL |= (1<<15); /* start read */
- while (!(DBOP_STAT & (1<<16))); /* wait for valid data */
-
- _dbop_din = DBOP_DIN; /* Read dbop data*/
-
- /* Reset dbop for output */
- DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
- DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
- DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
- DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */
-}
-
/*
* Get button pressed from hardware
*/
@@ -79,13 +59,27 @@ int button_read_device(void)
{
int btn = BUTTON_NONE;
+ _dbop_din = lcd_dbop_input();
+
+ /* hold button handling */
+ hold_button = ((_dbop_din & (1<<12)) == 0);
+#ifndef BOOTLOADER
+ /* light handling */
+ if (hold_button != hold_button_old)
+ {
+ hold_button_old = hold_button;
+ backlight_hold_changed(hold_button);
+ }
+#endif /* BOOTLOADER */
+ if (hold_button) {
+ return 0;
+ }
+
/* direct GPIO connections */
if (GPIOA_PIN(3))
btn |= BUTTON_POWER;
- if(lcd_button_support())
- button_read_dbop();
-
+ /* DBOP buttons */
if(!(_dbop_din & (1<<2)))
btn |= BUTTON_LEFT;
if(!(_dbop_din & (1<<3)))
@@ -96,15 +90,12 @@ int button_read_device(void)
btn |= BUTTON_UP;
if(!(_dbop_din & (1<<6)))
btn |= BUTTON_RIGHT;
-
-#ifndef BOOTLOADER
- /* light handling */
- if (hold_button != hold_button_old)
- {
- hold_button_old = hold_button;
- backlight_hold_changed(hold_button);
- }
-#endif /* BOOTLOADER */
+ if(!(_dbop_din & (1<<13)))
+ btn |= BUTTON_VOL_UP;
+ if(!(_dbop_din & (1<<14)))
+ btn |= BUTTON_VOL_DOWN;
+ if(!(_dbop_din & (1<<15)))
+ btn |= BUTTON_REC;
return btn;
}