VLSI Solution Oy VLSI Solution Oy Evaluation MP3 Player Source Code Documentation

Main Page | Class List | File List | Class Members | File Members | Related Pages

lcd.c

Go to the documentation of this file.
00001 #include "board.h" 00002 #include "lcd.h" 00003 #include "lcdfonts.c" 00004 00011 code const unsigned char lcd_hexchars[17] = "0123456789abcdef"; 00012 00013 00017 void LcdPutChar(char c) { 00018 WaitOutDelay(); 00019 LCD_RS = LCD_DATA_MODE; 00020 LCD_ENABLE = 1; /* Rising edge */ 00021 LCD_DATABUS = c; 00022 LCD_ENABLE = 1; /* Keep high...*/ 00023 LCD_ENABLE = 0; /* Falling edge */ 00024 InitiateDelay(44); 00025 } 00026 00027 00028 00029 00033 void LcdPutCommand(char cmd){ 00034 WaitOutDelay(); 00035 LCD_RS = LCD_COMMAND_MODE; 00036 LCD_ENABLE = 1; /* Rising edge */ 00037 LCD_DATABUS = cmd; 00038 LCD_ENABLE = 0; /* Falling edge */ 00039 } 00040 00041 00042 00043 void LcdSelectFont(ROM_CHAR_PTR font){ 00044 static ROM_CHAR_PTR loadedFont = 0; 00045 if (loadedFont != font){ 00046 loadedFont=font; 00047 00048 LcdLocateCG(); 00049 LcdPutConstantString(font); 00050 LcdLocateHome(); 00051 00052 } 00053 } 00054 00056 void LcdReset(){ 00057 00058 00059 LCD_ENABLE = 0; 00060 InitiateDelay(0); /* Initialize the delay system */ 00061 00062 LcdPutCommand(56); /* 8 data bits, 2 lines */ 00063 InitiateDelay(39); 00064 00065 WaitOutDelay(); 00066 LcdPutCommand(56); /* Command 2 times "just in case" */ 00067 InitiateDelay(39); 00068 00069 WaitOutDelay(); 00070 LcdPutCommand(12); /* Panel on, no cursor */ 00071 InitiateDelay(39); 00072 00073 WaitOutDelay(); 00074 LcdPutCommand(1); /* Clear screen */ 00075 InitiateDelay(1530); /* Start a 1.53 ms delay */ 00076 00077 LcdSelectFont(lcdFont_barchars); 00078 00079 } 00080 00081 00082 00089 void LcdPutString (char *str) { 00090 while (*str) { 00091 LcdPutChar (*str++); 00092 } 00093 } 00094 00095 00096 00102 void LcdPutConstantString(char code *str){ 00103 while (*str) 00104 { 00105 LcdPutChar (*str++); 00106 } 00107 } 00108 00109 00110 00111 void LcdFadeIn(){ 00112 unsigned char c,d; 00113 for (c=0; c<254; c++){ 00114 for (d=252; d; d-=2){ 00115 if (d>c){ 00116 LcdPutCommand (8); 00117 InitiateDelay(40); 00118 }else{ 00119 LcdPutCommand (12); 00120 InitiateDelay(40); 00121 } 00122 } 00123 } 00124 LcdPutCommand(12); 00125 InitiateDelay(40); 00126 } 00127 00128 void LcdFadeOut(){ 00129 unsigned char c,d; 00130 for (c=0; c<254; c++){ 00131 for (d=252; d; d-=2){ 00132 if (d<c){ 00133 LcdPutCommand (8); 00134 InitiateDelay(40); 00135 }else{ 00136 LcdPutCommand (12); 00137 InitiateDelay(40); 00138 } 00139 } 00140 } 00141 LcdPutCommand(8); 00142 InitiateDelay(40); 00143 } 00144 00145 00147 void LcdSplashScreen(){ 00148 00149 LcdReset(); 00150 00151 LcdSelectFont(lcdFont_vlsichars); 00152 00153 LcdLocateHome(); 00154 00155 LcdPutChar(0); 00156 LcdPutConstantString("\1\2\3 Sol"); 00157 LcdLocateLine2(); 00158 LcdPutConstantString("ution Oy"); 00159 00160 00161 LcdFadeIn(); 00162 LcdFadeOut(); 00163 00164 } 00165 00166 00168 void LcdPutHex16 (unsigned int value){ 00169 LcdPutChar(lcd_hexchars[value>>12]); 00170 LcdPutChar(lcd_hexchars[(value>>8)&0xf]); 00171 LcdPutChar(lcd_hexchars[(value>>4)&0xf]); 00172 LcdPutChar(lcd_hexchars[(value)&0xf]); 00173 } 00174 00175 00177 void LcdPutHex8 (unsigned char value){ 00178 00179 LcdPutChar(lcd_hexchars[(value>>4)&0xf]); 00180 LcdPutChar(lcd_hexchars[(value)&0xf]); 00181 } 00182 00183 00185 unsigned char LcdPrintGenericResult (unsigned char errorlevel){ 00186 if (!errorlevel){ 00187 LcdPutConstantString ("OK "); 00188 }else{ 00189 LcdPutConstantString ("Error "); 00190 LcdPutChar(lcd_hexchars[(errorlevel>>4)&0xf]); 00191 LcdPutChar(lcd_hexchars[(errorlevel)&0xf]); 00192 ConsoleWrite ("\rSystem error "); 00193 ConsolePutHex8 (errorlevel); 00194 ConsoleWrite (": \""); 00195 00196 switch (errorlevel){ 00197 case 0x01: ConsoleWrite ("No storage"); break; 00198 case 0x02: ConsoleWrite ("Storage powerup"); break; 00199 case 0x03: ConsoleWrite ("Storage init"); break; 00200 case 0x04: ConsoleWrite ("No storage ID"); break; 00201 case 0x05: ConsoleWrite ("Datablock header"); break; 00202 case 0x06: ConsoleWrite ("Storage Data reply failed"); break; 00203 case 0x07: ConsoleWrite ("Generic Storage Command"); break; 00204 case 0x08: ConsoleWrite ("Sector 0 not in recognized format"); break; 00205 case 0x09: ConsoleWrite ("No active partition"); break; 00206 case 0x0a: ConsoleWrite ("Filesystem load"); break; 00207 case 0x0b: ConsoleWrite ("No root directory"); break; 00208 case 0x0c: ConsoleWrite ("File not found"); break; 00209 00210 }; 00211 ConsoleWrite("\" failure.\r"); 00212 00213 00214 Delay(500); 00215 } 00216 return errorlevel; 00217 } 00218 00219 00221 void LcdPutUInt(unsigned long value){ 00222 xdata unsigned char valueString[10]; 00223 char c; 00224 for (c=0; c<10; c++){ 00225 valueString[c]=value % 10; 00226 value = value / 10; 00227 } 00228 c=9; 00229 while ((valueString[c]==0) && (c!=0)) 00230 c--; 00231 for (;c!=0;c--) 00232 LcdPutChar('0'+valueString[c]); 00233 LcdPutChar('0'+valueString[0]); 00234 00235 } 00236 00237 00238 00239

All software copyright 2000-2004 VLSI Solution OY. Redistribution of these software modules are limited to promotional use only and only with the VS1011 / VS1002 / VS1003 MP3-Evakit evaluation boards. Free or commercial use of these software modules in MP3 players is ok if the product includes MP3 decoder chip(s) from VLSI. You can request the complete (compilable) package from mp3@vlsi.fi