summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd.c')
-rw-r--r--firmware/drivers/lcd.c22
1 files changed, 13 insertions, 9 deletions
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}