diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2009-09-05 18:56:59 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2009-09-05 18:56:59 +0000 |
commit | 533c29b2f25ad836e4f704e75f22b66ab093119c (patch) | |
tree | 71370c34c915765cde7d7762d5effa514a2445de /firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c | |
parent | 4034e0b47fbc91cb530e9621cc6be243c071597c (diff) | |
download | rockbox-533c29b2f25ad836e4f704e75f22b66ab093119c.tar.gz rockbox-533c29b2f25ad836e4f704e75f22b66ab093119c.zip |
Sansa c200v2: update DBOP button reading mechanism, this enables readout of the volume buttons, rec and hold button.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22635 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c | 59 |
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 @@ | |||
26 | #include "powermgmt.h" | 26 | #include "powermgmt.h" |
27 | 27 | ||
28 | 28 | ||
29 | unsigned short _dbop_din = 0; | 29 | static unsigned short _dbop_din = 0xFFFF; |
30 | 30 | ||
31 | /* in the lcd driver */ | 31 | /* in the lcd driver */ |
32 | extern bool lcd_button_support(void); | 32 | extern unsigned short int lcd_dbop_input(void); |
33 | 33 | ||
34 | static bool hold_button = false; | 34 | static bool hold_button = false; |
35 | #ifndef BOOTLOADER | 35 | #ifndef BOOTLOADER |
@@ -52,26 +52,6 @@ bool button_hold(void) | |||
52 | return hold_button; | 52 | return hold_button; |
53 | } | 53 | } |
54 | 54 | ||
55 | static void button_read_dbop(void) | ||
56 | { | ||
57 | /* Set up dbop for input */ | ||
58 | DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */ | ||
59 | DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */ | ||
60 | DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */ | ||
61 | DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */ | ||
62 | |||
63 | DBOP_CTRL |= (1<<15); /* start read */ | ||
64 | while (!(DBOP_STAT & (1<<16))); /* wait for valid data */ | ||
65 | |||
66 | _dbop_din = DBOP_DIN; /* Read dbop data*/ | ||
67 | |||
68 | /* Reset dbop for output */ | ||
69 | DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */ | ||
70 | DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */ | ||
71 | DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */ | ||
72 | DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */ | ||
73 | } | ||
74 | |||
75 | /* | 55 | /* |
76 | * Get button pressed from hardware | 56 | * Get button pressed from hardware |
77 | */ | 57 | */ |
@@ -79,13 +59,27 @@ int button_read_device(void) | |||
79 | { | 59 | { |
80 | int btn = BUTTON_NONE; | 60 | int btn = BUTTON_NONE; |
81 | 61 | ||
62 | _dbop_din = lcd_dbop_input(); | ||
63 | |||
64 | /* hold button handling */ | ||
65 | hold_button = ((_dbop_din & (1<<12)) == 0); | ||
66 | #ifndef BOOTLOADER | ||
67 | /* light handling */ | ||
68 | if (hold_button != hold_button_old) | ||
69 | { | ||
70 | hold_button_old = hold_button; | ||
71 | backlight_hold_changed(hold_button); | ||
72 | } | ||
73 | #endif /* BOOTLOADER */ | ||
74 | if (hold_button) { | ||
75 | return 0; | ||
76 | } | ||
77 | |||
82 | /* direct GPIO connections */ | 78 | /* direct GPIO connections */ |
83 | if (GPIOA_PIN(3)) | 79 | if (GPIOA_PIN(3)) |
84 | btn |= BUTTON_POWER; | 80 | btn |= BUTTON_POWER; |
85 | 81 | ||
86 | if(lcd_button_support()) | 82 | /* DBOP buttons */ |
87 | button_read_dbop(); | ||
88 | |||
89 | if(!(_dbop_din & (1<<2))) | 83 | if(!(_dbop_din & (1<<2))) |
90 | btn |= BUTTON_LEFT; | 84 | btn |= BUTTON_LEFT; |
91 | if(!(_dbop_din & (1<<3))) | 85 | if(!(_dbop_din & (1<<3))) |
@@ -96,15 +90,12 @@ int button_read_device(void) | |||
96 | btn |= BUTTON_UP; | 90 | btn |= BUTTON_UP; |
97 | if(!(_dbop_din & (1<<6))) | 91 | if(!(_dbop_din & (1<<6))) |
98 | btn |= BUTTON_RIGHT; | 92 | btn |= BUTTON_RIGHT; |
99 | 93 | if(!(_dbop_din & (1<<13))) | |
100 | #ifndef BOOTLOADER | 94 | btn |= BUTTON_VOL_UP; |
101 | /* light handling */ | 95 | if(!(_dbop_din & (1<<14))) |
102 | if (hold_button != hold_button_old) | 96 | btn |= BUTTON_VOL_DOWN; |
103 | { | 97 | if(!(_dbop_din & (1<<15))) |
104 | hold_button_old = hold_button; | 98 | btn |= BUTTON_REC; |
105 | backlight_hold_changed(hold_button); | ||
106 | } | ||
107 | #endif /* BOOTLOADER */ | ||
108 | 99 | ||
109 | return btn; | 100 | return btn; |
110 | } | 101 | } |