diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze/button-fuze.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/button-fuze.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c index 9b6df70bd9..f5dca441d5 100644 --- a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c +++ b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c | |||
@@ -128,13 +128,14 @@ bool button_hold(void) | |||
128 | 128 | ||
129 | static short button_dbop(void) | 129 | static short button_dbop(void) |
130 | { | 130 | { |
131 | /* skip home reading if lcd_button_support was blocked, | 131 | /* skip home and power reading if lcd_button_support was blocked, |
132 | * since the dbop bit 15 is invalid then, and use the old value instead */ | 132 | * since the dbop bit 15 is invalid then, and use the old value instead */ |
133 | /* -20 (arbitary value) indicates valid home button read */ | 133 | /* -20 (arbitary value) indicates valid home&power button read */ |
134 | int old_home = -20; | 134 | int old_home_power = -20; |
135 | int delay = 0; | ||
136 | if(!lcd_button_support()) | 135 | if(!lcd_button_support()) |
137 | old_home = (_dbop_din & 1<<15); | 136 | { |
137 | old_home_power = (_dbop_din & (1<<15|1<<8)); | ||
138 | } | ||
138 | 139 | ||
139 | /* Wait for fifo to empty */ | 140 | /* Wait for fifo to empty */ |
140 | while ((DBOP_STAT & (1<<10)) == 0); | 141 | while ((DBOP_STAT & (1<<10)) == 0); |
@@ -145,10 +146,8 @@ static short button_dbop(void) | |||
145 | DBOP_TIMPOL_01 = 0xe167e167; | 146 | DBOP_TIMPOL_01 = 0xe167e167; |
146 | DBOP_TIMPOL_23 = 0xe167006e; | 147 | DBOP_TIMPOL_23 = 0xe167006e; |
147 | 148 | ||
148 | while(delay++ < 64); | ||
149 | |||
150 | DBOP_CTRL |= (1<<15); /* start read */ | 149 | DBOP_CTRL |= (1<<15); /* start read */ |
151 | ((DBOP_STAT & (1<<16)) == 0); /* wait for valid data */ | 150 | while((DBOP_STAT & (1<<16)) == 0); /* wait for valid data */ |
152 | 151 | ||
153 | _dbop_din = DBOP_DIN; /* now read */ | 152 | _dbop_din = DBOP_DIN; /* now read */ |
154 | 153 | ||
@@ -158,8 +157,12 @@ static short button_dbop(void) | |||
158 | DBOP_CTRL |= (1<<16); | 157 | DBOP_CTRL |= (1<<16); |
159 | DBOP_CTRL &= ~(1<<19); | 158 | DBOP_CTRL &= ~(1<<19); |
160 | 159 | ||
161 | if (old_home != -20) | 160 | /* write back old values if blocked */ |
162 | _dbop_din |= old_home; | 161 | if (old_home_power != -20) |
162 | { | ||
163 | _dbop_din |= old_home_power & 1<<15; | ||
164 | _dbop_din &= 0xfeff|(old_home_power & 1<<8); | ||
165 | } | ||
163 | return _dbop_din; | 166 | return _dbop_din; |
164 | } | 167 | } |
165 | 168 | ||