00001
00024
00025 #include "Main.h"
00026 #include "LCD_driver.h"
00027
00028
00029 union _LCD_status LCD_status = {0x01};
00030 unsigned char LCD_timer = LCD_TIMER_SEED;
00031
00032 unsigned char LCD_displayData[LCD_REGISTER_COUNT];
00033
00034
00035 __flash unsigned int LCD_character_table[] =
00036 {
00037 0x0A51,
00038 0x2A80,
00039 0x0000,
00040 0x0A00,
00041 0x0A51,
00042 0x0000,
00043 0x5559,
00044 0x0118,
00045 0x1e11,
00046 0x1b11,
00047 0x0b50,
00048 0x1b41,
00049 0x1f41,
00050 0x0111,
00051 0x1f51,
00052 0x1b51,
00053 0x0000,
00054 0x0000,
00055 0x0000,
00056 0x0000,
00057 0x0000,
00058 0x0000,
00059 0x0000,
00060 0x0f51,
00061 0x3991,
00062 0x1441,
00063 0x3191,
00064 0x1e41,
00065 0x0e41,
00066 0x1d41,
00067 0x0f50,
00068 0x2080,
00069 0x1510,
00070 0x8648,
00071 0x1440,
00072 0x0578,
00073 0x8570,
00074 0x1551,
00075 0x0e51,
00076 0x9551,
00077 0x8e51,
00078 0x9021,
00079 0x2081,
00080 0x1550,
00081 0x4448,
00082 0xc550,
00083 0xc028,
00084 0x2028,
00085 0x5009,
00086 0x0000,
00087 0x0000,
00088 0x0000,
00089 0x0000,
00090 0x0000
00091 };
00092
00093
00096 void LCD_Init (void)
00097 {
00098 LCD_AllSegments( FALSE );
00099 LCDCRA = (1<<LCDEN);
00100
00101 LCD_CONTRAST_LEVEL(LCD_INITIAL_CONTRAST);
00102
00103
00104 LCDCRB = (1<<LCDCS) | (1<<LCDMUX1) | (1<<LCDMUX0) | (1<<LCDPM2) | (1<<LCDPM1)| (1<<LCDPM0);
00105 LCDFRR = (1<<LCDPS0);
00106
00107 LCDCRA |= (1<<LCDIE);
00108 }
00109
00110
00116 void LCD_WriteDigit( unsigned char c, unsigned char digit )
00117 {
00118
00119 unsigned int seg;
00120 unsigned char i;
00121 unsigned char mask, nibble;
00122 unsigned char *ptr;
00123
00124
00125 seg = 0x0000;
00126 if ( (c >= '*') && (c <= 'z') )
00127 {
00128
00129
00130 if ( c >= 'a' ) c &= ~0x20;
00131 c -= '*';
00132 seg = LCD_character_table[c];
00133 }
00134
00135
00136 mask = 0x0F;
00137 if ( digit & 0x01 )
00138 {
00139 }
00140 else
00141 {
00142 mask = 0xF0;
00143 }
00144
00145 i = digit-2;
00146 if ( i >= 6 )
00147 return;
00148 i >>= 1;
00149 ptr = LCD_displayData + i;
00150
00151 i = 4;
00152 do
00153 {
00154 nibble = seg & 0x000F;
00155 seg >>= 4;
00156 if ( digit & 0x01 )
00157 nibble <<= 4;
00158 *ptr = (*ptr & mask) | nibble;
00159 ptr += 5;
00160 } while ( --i );
00161 }
00162
00163
00167 void LCD_AllSegments( unsigned char input )
00168 {
00169 unsigned char i;
00170 unsigned char *ptr;
00171
00172 if( input )
00173 input = 0xFF;
00174
00175
00176 ptr = LCD_displayData;
00177 i = 20;
00178 do
00179 {
00180 *ptr++ = input;
00181 } while ( --i );
00182 }
00183
00184
00187 #pragma vector = LCD_SOF_vect
00188 __interrupt void LCD_SOF_interrupt( void )
00189 {
00190 unsigned char i;
00191 unsigned char *src, *dest;
00192
00193 LCD_timer--;
00194 if( LCD_timer == 0 )
00195 {
00196 if( LCD_status.updateRequired == TRUE )
00197 {
00198 LCD_timer = LCD_TIMER_SEED;
00199 LCD_status.updateComplete = TRUE;
00200 LCD_status.blinkLCD = ~LCD_status.blinkLCD;
00201
00202
00203 i = 20;
00204 dest = &pLCDREG;
00205 src = LCD_displayData;
00206 do
00207 {
00208 *dest++ = *src++;
00209 } while ( --i );
00210 }
00211 else
00212 {
00213 LCD_timer = 1;
00214
00215
00216 LCD_status.updateComplete = FALSE;
00217
00218 }
00219 }
00220 }