diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c index 4848d9e7d9..3ae4975b22 100644 --- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c +++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c | |||
@@ -32,9 +32,11 @@ static bool hold_button = false; | |||
32 | void button_init_device(void) | 32 | void button_init_device(void) |
33 | { /* activate the wheel */ | 33 | { /* activate the wheel */ |
34 | volatile int i; | 34 | volatile int i; |
35 | GPIOB_DIR |= 1<<4; | 35 | GPIOA_DIR &= ~(1<<6|1<<7); |
36 | GPIOC_DIR = 0; | ||
37 | GPIOB_DIR |= (1<<4)|(1<<3)|(1<<0); | ||
36 | for(i = 20; i; i--) nop; | 38 | for(i = 20; i; i--) nop; |
37 | GPIOB_PIN(4) = 0x10; | 39 | GPIOB_PIN(4) = 1<<4; |
38 | } | 40 | } |
39 | 41 | ||
40 | unsigned read_GPIOA_67(void) | 42 | unsigned read_GPIOA_67(void) |
@@ -74,29 +76,23 @@ int button_read_device(void) | |||
74 | volatile int delay; | 76 | volatile int delay; |
75 | static bool hold_button_old = false; | 77 | static bool hold_button_old = false; |
76 | static long power_counter = 0; | 78 | static long power_counter = 0; |
77 | unsigned gpiod = GPIOD_DATA; | ||
78 | unsigned gpioa_dir = GPIOA_DIR; | ||
79 | unsigned gpiod6; | 79 | unsigned gpiod6; |
80 | |||
80 | get_scrollwheel(); | 81 | get_scrollwheel(); |
81 | for(delay = 500; delay; delay--) nop; | 82 | |
82 | CCU_IO &= ~(1<<12); | 83 | CCU_IO &= ~(1<<12); |
83 | for(delay=8;delay;delay--) nop; | 84 | for(delay=8;delay;delay--) nop; |
84 | GPIOB_DIR |= 1<<3; | 85 | |
85 | GPIOB_PIN(3) = 1<<3; | 86 | GPIOB_PIN(3) = 1<<3; |
86 | GPIOC_DIR = 0; | 87 | GPIOB_PIN(0) = 1<<0; |
87 | GPIOB_DIR &= ~(1<<1); | 88 | |
88 | GPIOB_DIR |= 1<<0; | ||
89 | GPIOB_PIN(0) = 1; | ||
90 | for(delay = 500; delay; delay--) | 89 | for(delay = 500; delay; delay--) |
91 | nop; | 90 | nop; |
92 | gpiod6 = GPIOD_PIN(6); | 91 | gpiod6 = GPIOD_PIN(6); |
93 | GPIOB_PIN(0) = 0; | 92 | GPIOB_PIN(0) = 0; |
94 | for(delay = 240; delay; delay--) | 93 | for(delay = 240; delay; delay--) |
95 | nop; | 94 | nop; |
96 | GPIOD_DIR = 0xff; | 95 | |
97 | GPIOA_DIR &= ~(1<<6|1<<7); | ||
98 | GPIOD_DATA = 0; | ||
99 | GPIOD_DIR = 0; | ||
100 | if (GPIOC_PIN(1) & 1<<1) | 96 | if (GPIOC_PIN(1) & 1<<1) |
101 | btn |= BUTTON_DOWN; | 97 | btn |= BUTTON_DOWN; |
102 | if (GPIOC_PIN(2) & 1<<2) | 98 | if (GPIOC_PIN(2) & 1<<2) |
@@ -123,11 +119,8 @@ int button_read_device(void) | |||
123 | } | 119 | } |
124 | } | 120 | } |
125 | 121 | ||
126 | GPIOD_DIR = 0xff; | ||
127 | GPIOD_DATA = gpiod; | ||
128 | GPIOA_DIR = gpioa_dir; | ||
129 | GPIOD_DIR = 0; | ||
130 | CCU_IO |= 1<<12; | 122 | CCU_IO |= 1<<12; |
123 | |||
131 | #ifdef HAS_BUTTON_HOLD | 124 | #ifdef HAS_BUTTON_HOLD |
132 | #ifndef BOOTLOADER | 125 | #ifndef BOOTLOADER |
133 | /* light handling */ | 126 | /* light handling */ |