diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/button.c | 5 | ||||
-rw-r--r-- | firmware/drivers/lcd.c | 22 |
2 files changed, 16 insertions, 11 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 06c24e0e45..66c7e978fb 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -258,10 +258,11 @@ void button_set_flip(bool flip) | |||
258 | { | 258 | { |
259 | if (flip != flipped) /* not the curent setting */ | 259 | if (flip != flipped) /* not the curent setting */ |
260 | { | 260 | { |
261 | cli(); /* avoid race condition with the button_tick() */ | 261 | /* avoid race condition with the button_tick() */ |
262 | int oldlevel = set_irq_level(15); | ||
262 | lastbtn = button_flip(lastbtn); | 263 | lastbtn = button_flip(lastbtn); |
263 | flipped = flip; | 264 | flipped = flip; |
264 | sti(); | 265 | set_irq_level(oldlevel); |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 5c2c514f10..950f8b5057 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c | |||
@@ -188,14 +188,16 @@ void lcd_write_data(unsigned char* p_bytes, int count) | |||
188 | { | 188 | { |
189 | do | 189 | do |
190 | { | 190 | { |
191 | unsigned byte; | 191 | unsigned int byte; |
192 | unsigned sda1; /* precalculated SC=low,SD=1 */ | 192 | unsigned int sda1; /* precalculated SC=low,SD=1 */ |
193 | unsigned clk0sda0; /* precalculated SC and SD low */ | 193 | unsigned int clk0sda0; /* precalculated SC and SD low */ |
194 | unsigned int oldlevel; | ||
194 | 195 | ||
195 | byte = *p_bytes++ << 24; /* fetch to MSB position */ | 196 | byte = *p_bytes++ << 24; /* fetch to MSB position */ |
196 | 197 | ||
197 | cli(); /* make port modifications atomic, in case an IRQ uses PBDRL */ | 198 | /* make port modifications atomic, in case an IRQ uses PBDRL */ |
198 | /* (currently not the case, so this could be optimized away) */ | 199 | /* (currently not the case, so this could be optimized away) */ |
200 | oldlevel = set_irq_level(15); | ||
199 | 201 | ||
200 | /* precalculate the values for later bit toggling, init data write */ | 202 | /* precalculate the values for later bit toggling, init data write */ |
201 | asm ( | 203 | asm ( |
@@ -285,7 +287,7 @@ void lcd_write_data(unsigned char* p_bytes, int count) | |||
285 | : "r0" | 287 | : "r0" |
286 | ); | 288 | ); |
287 | 289 | ||
288 | sti(); | 290 | set_irq_level(oldlevel); |
289 | 291 | ||
290 | } while (--count); /* tail loop is faster */ | 292 | } while (--count); /* tail loop is faster */ |
291 | } | 293 | } |
@@ -298,13 +300,15 @@ void lcd_write_data(unsigned char* p_bytes, int count) | |||
298 | { | 300 | { |
299 | unsigned byte; | 301 | unsigned byte; |
300 | unsigned sda1; /* precalculated SC=low,SD=1 */ | 302 | unsigned sda1; /* precalculated SC=low,SD=1 */ |
303 | unsigned int oldlevel; | ||
301 | 304 | ||
302 | /* take inverse data, so I can use the NEGC instruction below, it is | 305 | /* take inverse data, so I can use the NEGC instruction below, it is |
303 | the only carry add/sub which does not destroy a source register */ | 306 | the only carry add/sub which does not destroy a source register */ |
304 | byte = ~(*p_bytes++ << 24); /* fetch to MSB position */ | 307 | byte = ~(*p_bytes++ << 24); /* fetch to MSB position */ |
305 | 308 | ||
306 | cli(); /* make port modifications atomic, in case an IRQ uses PBDRL */ | 309 | /* make port modifications atomic, in case an IRQ uses PBDRL */ |
307 | /* (currently not the case, so this could be optimized away) */ | 310 | /* (currently not the case, so this could be optimized away) */ |
311 | oldlevel = set_irq_level(15); | ||
308 | 312 | ||
309 | /* precalculate the values for later bit toggling, init data write */ | 313 | /* precalculate the values for later bit toggling, init data write */ |
310 | asm ( | 314 | asm ( |
@@ -386,7 +390,7 @@ void lcd_write_data(unsigned char* p_bytes, int count) | |||
386 | "r0" | 390 | "r0" |
387 | ); | 391 | ); |
388 | 392 | ||
389 | sti(); /* end of atomic port modifications */ | 393 | set_irq_level(oldlevel); |
390 | 394 | ||
391 | } while (--count); /* tail loop is faster */ | 395 | } while (--count); /* tail loop is faster */ |
392 | } | 396 | } |