From a59b3eb91936ed71871ba2c95ebebb8b16fd84db Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 18 Jul 2006 18:16:38 +0000 Subject: [PATCH] simplification of lcd driver code - based on patch #5474 by Rani Hod git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10235 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/coldfire/iaudio/x5/lcd-x5.c | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/firmware/target/coldfire/iaudio/x5/lcd-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-x5.c index 9b4a54fdd6..75ec2462be 100755 --- a/firmware/target/coldfire/iaudio/x5/lcd-x5.c +++ b/firmware/target/coldfire/iaudio/x5/lcd-x5.c @@ -32,6 +32,9 @@ static bool display_on=false; /* is the display turned on? */ +#define LCD_CMD *(volatile unsigned short *)0xf0008000 +#define LCD_DATA *(volatile unsigned short *)0xf0008002 + /* register defines for the Renesas HD66773R */ #define R_HORIZ_RAM_ADDR_POS 0x16 #define R_VERT_RAM_ADDR_POS 0x17 @@ -91,17 +94,17 @@ const short high8to9[] ICONST_ATTR = { /* called very frequently - inline! */ inline void lcd_write_reg(int reg, int val) { - *(volatile unsigned short *)0xf0008000 = (reg >> 8) << 1; - *(volatile unsigned short *)0xf0008000 = (reg & 0xff) << 1; - *(volatile unsigned short *)0xf0008002 = (val >> 8) << 1; - *(volatile unsigned short *)0xf0008002 = (val & 0xff) << 1; + LCD_CMD = (reg >> 8) << 1; + LCD_CMD = (reg & 0xff) << 1; + LCD_DATA = (val >> 8) << 1; + LCD_DATA = (val & 0xff) << 1; } /* called very frequently - inline! */ inline void lcd_begin_write_gram(void) { - *(volatile unsigned short *)0xf0008000 = (R_WRITE_DATA_2_GRAM >> 8) << 1; - *(volatile unsigned short *)0xf0008000 = (R_WRITE_DATA_2_GRAM & 0xff) << 1; + LCD_CMD = (R_WRITE_DATA_2_GRAM >> 8) << 1; + LCD_CMD = (R_WRITE_DATA_2_GRAM & 0xff) << 1; } /* called very frequently - inline! */ @@ -119,16 +122,16 @@ inline void lcd_write_data(const unsigned short* p_bytes, int count) count >>= 1; while(count--) { tmp = *ptr++; - *(volatile unsigned short *)0xf0008002 = high8to9[tmp >> 24]; - *(volatile unsigned short *)0xf0008002 = tmp>>15; - *(volatile unsigned short *)0xf0008002 = high8to9[(tmp >> 8)&255]; - *(volatile unsigned short *)0xf0008002 = tmp<<1; + LCD_DATA = high8to9[tmp >> 24]; + LCD_DATA = tmp>>15; + LCD_DATA = high8to9[(tmp >> 8)&255]; + LCD_DATA = tmp<<1; } if(extra) { /* the final "spare" pixel */ unsigned short read = *(unsigned short *)ptr; - *(volatile unsigned short *)0xf0008002 = high8to9[read >> 8]; - *(volatile unsigned short *)0xf0008002 = read<<1; + LCD_DATA = high8to9[read >> 8]; + LCD_DATA = read<<1; } }