Definition in file stk504_lcd.c.
#include "stk504_lcd.h"
#include "defines.h"
#include <iom3290.h>
#include <inavr.h>
Include dependency graph for stk504_lcd.c:

Go to the source code of this file.
Functions | |
| void | LCD_AllSegments (unsigned char input) |
| Fills the Whole display buffer with one's or zero's. | |
| void | LCD_BarSeg (unsigned char value) |
| Write a hex value to the 8 bar segments on the display. | |
| void | LCD_init (void) |
| Initializes the ATmega3290 to use the STK504 Display. | |
| void | LCD_PutChar (unsigned char c, unsigned char digit) |
| Diplays a character on the 14-segment digits. | |
| void | LCD_PutDigit (unsigned char c, unsigned char digit) |
| Write a hex value to one of the 7-segment digits on the display Digit 0 has a special case as it can only display '-' and '1'. Digit[1..4] can display [0..9][A..F] See LCD_digit_table[] for some special symbols that can also be displayed. | |
| void | LCD_SetSeg (unsigned char symbol, unsigned char input) |
| Turns ON or OFF a segment in the LCD display buffer. | |
| void | LCD_Update (void) |
| Moves display buffer content to LCDDR[0..19]. Allows forced update to the phyhsical LCDDR registers, instead of setting updateRequired and waiting for the interrupt to update the LCD registers. | |
| __interrupt void | LCD_vect_interrupt (void) |
| LCD Interrupt Routine to latch the LCD_displayData and Set LCD_status.updateComplete. | |
Variables | |
| __flash unsigned int | LCD_character_table [] |
| Look-up tables for 14-segment characters. | |
| __flash unsigned char | LCD_digit_table [] |
| Look-up tables for 7-segment characters. | |
| unsigned char | LCD_displayData [LCD_REGISTER_COUNT] |
| LCD display buffer (for double buffering). | |
| _LCD_status | LCD_status = {0x01} |
| LCD_status = {0, 0, 0, 0, 0, 0, FALSE, TRUE};. | |
| unsigned char | LCD_timer = LCD_TIMER_SEED |
|
|
Fills the Whole display buffer with one's or zero's.
Definition at line 282 of file stk504_lcd.c. References LCD_displayData. Referenced by LCD_init(). 00286 { 00287 unsigned char i; 00288 unsigned char *ptr; 00289 00290 if( input ) // If input == TRUE 00291 input = 0xFF; // set segments to 0xFF. 00292 // (else set segments to 0x00) 00293 ptr = LCD_displayData; 00294 i = 20; 00295 do // Fill the display buffer. 00296 { 00297 *ptr++ = input; // Set/clear the bits in all LCD registers. 00298 } while ( --i ); 00299 }
|
|
|
Write a hex value to the 8 bar segments on the display.
Definition at line 343 of file stk504_lcd.c. References LCD_displayData. Referenced by main(). 00347 { 00348 unsigned char mask, i, n, m; 00349 unsigned char *ptr; 00350 mask = 0x80; 00351 00352 ptr = LCD_displayData + 18; // Point to the first relevant LCDDR; i = {0,0,1,1,2,2} 00353 00354 for(n=0; n<4 ; n++) 00355 { 00356 i=0; 00357 for(m=0; m<2; m++) 00358 { 00359 i |= ( value & mask ); 00360 i >>= 1; 00361 value <<= 1; // Shift next bits into position 00362 } 00363 // At this point high variable i high nibble contain | 0 | sn | sn+1 | 0 | starting with LSBs 00364 *ptr = i | (*ptr & 0x9F); // 0x9F is mask to erase old bit values in 00365 ptr -= 5; // next segment register. 00366 } 00367 }
|
|
|
Initializes the ATmega3290 to use the STK504 Display.
Definition at line 399 of file stk504_lcd.c. References FALSE, LCD_AllSegments(), LCD_CONTRAST_LEVEL, and LCD_INITIAL_CONTRAST. Referenced by main(). 00402 { 00403 00404 LCD_AllSegments( FALSE ); // Clear segment buffer. 00405 PRR &= ~(1<<PRLCD); // Make sure LCD isn't disabled in power reduction register 00406 LCDCRA = (1<<LCDEN); // Enable LCD. 00407 00408 LCD_CONTRAST_LEVEL(LCD_INITIAL_CONTRAST); //Set the LCD contrast level. 00409 00410 // Select asynchronous clock source, enable all COM pins and enable all segment pins. 00411 LCDCRB = (1<<LCDCS) | (1<<LCDMUX1) | (1<<LCDMUX0) | (1<<LCDPM3)| (1<<LCDPM2) | (1<<LCDPM1)| (1<<LCDPM0); 00412 LCDFRR = (1<<LCDPS0); // Set LCD prescaler to CLK(lcd)/64 = 64Hz. 00413 00414 LCDCRA |= (1<<LCDIE); //Enable LCD_Start_frame interrupt. 00415 00416 }
Here is the call graph for this function: ![]() |
|
||||||||||||
|
Diplays a character on the 14-segment digits.
Definition at line 134 of file stk504_lcd.c. References LCD_character_table, and LCD_displayData. Referenced by main(). 00139 { 00140 unsigned int seg, segMask; 00141 unsigned char i; 00142 unsigned char mask, nibble, nibbleMask; 00143 unsigned char *ptr; 00144 00145 if ( digit == 0 || digit >=8) 00146 { 00147 return; //digit is out og range. 00148 } 00149 00150 //Lookup character table for segment data. 00151 if ( (c >= '*') && (c <= 'z') ) 00152 { 00153 if ( c >= 'a' ) c &= ~0x20; // c is in character_table. Convert to upper if necessarry. 00154 c -= '*'; 00155 if ( c > 0x35 ) 00156 { 00157 return; // c points outside array. 00158 } 00159 else 00160 { 00161 seg = LCD_character_table[c]; 00162 } 00163 } 00164 else 00165 { 00166 return; //ASCII code out of range. 00167 } 00168 00169 // Adjust mask according to digit 00170 segMask = 0x4008; // masking out two bits not part of the segment. 00171 00172 i = digit-1; //i used as pointer offset. 00173 if ( i >= 8 ) //Test if LCD digit is out of range. 00174 return; 00175 i >>= 1; 00176 ptr = LCD_displayData + i; // Point to the first relevant LCDDR; i = {0,0,1,1,2,2} 00177 00178 i = 4; //i used as loop counter. 00179 do 00180 { 00181 nibble = seg & 0x000F; 00182 nibbleMask = segMask & 0x000F; 00183 00184 seg >>= 4; 00185 segMask >>= 4; 00186 00187 if ( digit & 0x01 ) 00188 { 00189 mask = 0xF0 | nibbleMask; 00190 } 00191 else 00192 { 00193 nibble <<= 4; 00194 mask = 0x0F | ( nibbleMask <<4 ); 00195 } 00196 *ptr = (*ptr & mask) | nibble; //Write new bit values. 00197 ptr += 5; 00198 } while ( --i ); 00199 }
|
|
||||||||||||
|
Write a hex value to one of the 7-segment digits on the display Digit 0 has a special case as it can only display '-' and '1'. Digit[1..4] can display [0..9][A..F] See LCD_digit_table[] for some special symbols that can also be displayed.
Definition at line 207 of file stk504_lcd.c. References BC8, G8, LCD_digit_table, LCD_displayData, and LCD_SetSeg(). 00215 { 00216 unsigned char i, j, seg; 00217 unsigned char mask, lastnibblemask, lookupdata; 00218 unsigned char *ptr; 00219 00220 //special case for digit = 0 00221 if (digit == 0) 00222 { 00223 LCD_SetSeg( G8, 0 ); 00224 LCD_SetSeg( BC8, 0 ); 00225 if ( c == '-' ) 00226 { 00227 LCD_SetSeg( G8, 1 ); 00228 } 00229 else 00230 { 00231 if ( c == '1' ) 00232 { 00233 LCD_SetSeg ( BC8, 1 ); 00234 } 00235 } 00236 return; 00237 } 00238 00239 if ( (c >= '*') && (c <= 'F') && (digit <= 4)) 00240 { 00241 c -= '*'; 00242 lookupdata = LCD_digit_table[c]; // c is in character_table. 00243 } 00244 else 00245 { 00246 return; // ASCII code out of range. 00247 } 00248 00249 ptr = LCD_displayData + 19; // Point to the first relevant LCDDR; 19, 14, 9, 4 00250 00251 for (j=0; j<4 ;j++) // Read out the 4 half-nibbles from lookupdata. 00252 { 00253 mask = 0xC0; 00254 lastnibblemask = 0x40; 00255 seg = ( lookupdata & mask ); // Variable lookupdata contains: 00256 // msb| A | B | F | G | E | C | D | |lsb (7seg) 00257 00258 //Shift half-nibble and masks into correct location. 00259 for (i = digit-1; i>0; i--) 00260 { 00261 seg >>= 2; 00262 mask >>= 2; 00263 lastnibblemask >>= 2; 00264 } 00265 if (j == 3) //need special mask for the last half nibble since it contains only one valid bit. 00266 { 00267 mask = mask & ~lastnibblemask; 00268 } 00269 00270 *ptr = (*ptr & ~mask) | seg; //Write new bit values. 00271 ptr -= 5; 00272 lookupdata <<= 2; //Prepare for next two bits. 00273 } 00274 }
Here is the call graph for this function: ![]() |
|
||||||||||||
|
Turns ON or OFF a segment in the LCD display buffer.
Definition at line 308 of file stk504_lcd.c. References LCD_displayData. Referenced by LCD_PutDigit(), and main(). 00313 { 00314 unsigned char offset; 00315 unsigned char setbit; 00316 unsigned char *ptr; 00317 00318 // Symbol format = bbbnnnnn where b is bit[0..7] and n is offset[0..19] 00319 // Valid symbols are defined in stk504_lcd.h 00320 setbit = (symbol >> 5); 00321 offset = (symbol & 0x1F); 00322 if ( offset >= 20 ) 00323 { 00324 return; //data out of range of the LCD registers 00325 } 00326 ptr = LCD_displayData + offset; // Point to the relevant LCDDR 00327 if ( input ) 00328 { 00329 *ptr = (*ptr) | ( 1 << setbit); // Set bit 00330 } 00331 else 00332 { 00333 *ptr = (*ptr) & ~( 1 << setbit); // Clear bit 00334 } 00335 }
|
|
|
Moves display buffer content to LCDDR[0..19]. Allows forced update to the phyhsical LCDDR registers, instead of setting updateRequired and waiting for the interrupt to update the LCD registers.
Definition at line 375 of file stk504_lcd.c. References LCD_displayData, and pLCDREG. 00380 { 00381 unsigned char *src, *dest; 00382 unsigned char i; 00383 00384 i = 20; 00385 dest = &pLCDREG; 00386 src = LCD_displayData; 00387 do 00388 { 00389 *dest++ = *src++; 00390 } while ( --i ); 00391 }
|
|
|
LCD Interrupt Routine to latch the LCD_displayData and Set LCD_status.updateComplete.
Definition at line 425 of file stk504_lcd.c. References FALSE, LCD_displayData, LCD_timer, LCD_TIMER_SEED, pLCDREG, TRUE, _LCD_status::updateComplete, and _LCD_status::updateRequired. 00428 { 00429 unsigned char i; 00430 unsigned char *src, *dest; 00431 00432 LCD_timer--; 00433 if( LCD_timer == 0 ) 00434 { 00435 if( LCD_status.updateRequired == TRUE ) 00436 { 00437 // PINB = 0x40; 00438 00439 LCD_timer = LCD_TIMER_SEED; 00440 LCD_status.updateComplete = TRUE; // Set the ucLCD_ScrollReady to true. 00441 LCD_status.updateRequired = FALSE; // No furter update necessary until 00442 // another function changes buffer contents. 00443 // Latch display data buffer to I/O segment registers. 00444 i = 20; 00445 dest = &pLCDREG; 00446 src = LCD_displayData; 00447 do 00448 { 00449 *dest++ = *src++; 00450 } while ( --i ); 00451 } 00452 else 00453 { 00454 LCD_timer = 1; //If LCD timer allows update of the LCD, but update is blocked 00455 // by LCD_status.updateRequired == FALSE the LCD_timer is preloaded 00456 // with smallest timer seed to ensure fastest LCD update. 00457 LCD_status.updateComplete = FALSE; //Block for further access to the LCD_displayData until 00458 // LCD update has been performed. 00459 } 00460 } 00461 }
|
|
|
Look-up tables for 14-segment characters.
Definition at line 36 of file stk504_lcd.c. Referenced by LCD_PutChar(). |
|
|
Look-up tables for 7-segment characters.
Definition at line 95 of file stk504_lcd.c. Referenced by LCD_PutDigit(). |
|
|
LCD display buffer (for double buffering).
Definition at line 33 of file stk504_lcd.c. Referenced by LCD_AllSegments(), LCD_BarSeg(), LCD_PutChar(), LCD_PutDigit(), LCD_SetSeg(), LCD_Update(), and LCD_vect_interrupt(). |
|
|
LCD_status = {0, 0, 0, 0, 0, 0, FALSE, TRUE};.
Definition at line 31 of file stk504_lcd.c. Referenced by LCD_timerDelay(), and main(). |
|
|
Definition at line 32 of file stk504_lcd.c. Referenced by LCD_timerDelay(), and LCD_vect_interrupt(). |
1.4.5