summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2011-12-14 21:04:04 +0000
committerRafaël Carré <rafael.carre@gmail.com>2011-12-14 21:04:04 +0000
commit273fbadb5537743829f9830de5247626a11aedca (patch)
tree850fe2271b3de1e19fba220bbc776107f396c48f
parentb366d63f035eda1cf7e4882463ea4a521b19fd85 (diff)
downloadrockbox-273fbadb5537743829f9830de5247626a11aedca.tar.gz
rockbox-273fbadb5537743829f9830de5247626a11aedca.zip
Clipv2: fix buttons broken by me in r31235
output pins were not correct xor pin readout with initial value (reversed between the 2 clips) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31255 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/button-clip.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/firmware/target/arm/as3525/button-clip.c b/firmware/target/arm/as3525/button-clip.c
index b6679ca359..04be8450fd 100644
--- a/firmware/target/arm/as3525/button-clip.c
+++ b/firmware/target/arm/as3525/button-clip.c
@@ -30,13 +30,13 @@
30#if defined(SANSA_CLIP) 30#if defined(SANSA_CLIP)
31# define OUT_PIN GPIOC_PIN 31# define OUT_PIN GPIOC_PIN
32# define OUT_DIR GPIOC_DIR 32# define OUT_DIR GPIOC_DIR
33# define OUT_INITIAL 0 33# define INITIAL 0
34# define IN_PIN GPIOB_PIN 34# define IN_PIN GPIOB_PIN
35# define IN_DIR GPIOB_DIR 35# define IN_DIR GPIOB_DIR
36#elif defined(SANSA_CLIPV2) 36#elif defined(SANSA_CLIPV2)
37# define OUT_PIN GPIOD_PIN 37# define OUT_PIN GPIOD_PIN
38# define OUT_DIR GPIOD_DIR 38# define OUT_DIR GPIOD_DIR
39# define OUT_INITIAL 1 39# define INITIAL 1
40# define IN_PIN GPIOD_PIN 40# define IN_PIN GPIOD_PIN
41# define IN_DIR GPIOD_DIR 41# define IN_DIR GPIOD_DIR
42#endif 42#endif
@@ -45,7 +45,7 @@ static const int rows[3] = {
45#if defined(SANSA_CLIP) 45#if defined(SANSA_CLIP)
46 4, 5, 6 46 4, 5, 6
47#elif defined(SANSA_CLIPV2) 47#elif defined(SANSA_CLIPV2)
48 5, 6, 4 48 3, 4, 5
49#endif 49#endif
50}; 50};
51 51
@@ -55,7 +55,7 @@ void button_init_device(void)
55 IN_DIR &= ~((1<<2) | (1<<1) | (1<<0)); 55 IN_DIR &= ~((1<<2) | (1<<1) | (1<<0));
56 56
57 for (int i = 0; i < 3; i++) { 57 for (int i = 0; i < 3; i++) {
58 OUT_PIN(rows[i]) = OUT_INITIAL << rows[i]; 58 OUT_PIN(rows[i]) = INITIAL << rows[i];
59 OUT_DIR |= 1 << rows[i]; 59 OUT_DIR |= 1 << rows[i];
60 } 60 }
61 61
@@ -95,16 +95,16 @@ int button_read_device(void)
95 }; 95 };
96 96
97 for (int i = 0; i<3; i++) 97 for (int i = 0; i<3; i++)
98 if (IN_PIN(i)) 98 if (IN_PIN(i) ^ (INITIAL << i))
99 buttons |= matrix[row][i]; 99 buttons |= matrix[row][i];
100 else 100 else
101 buttons &= ~matrix[row][i]; 101 buttons &= ~matrix[row][i];
102 102
103 /* prepare next row */ 103 /* prepare next row */
104 OUT_PIN(rows[row]) = 0 << rows[row]; 104 OUT_PIN(rows[row]) = INITIAL << rows[row];
105 row++; 105 row++;
106 row %= 3; 106 row %= 3;
107 OUT_PIN(rows[row]) = 1 << rows[row]; 107 OUT_PIN(rows[row]) = (!INITIAL) << rows[row];
108 108
109 return buttons; 109 return buttons;
110} 110}