Main Page | Data Structures | File List | Data Fields | Globals

ATAVRBFLY_FILES/LCD_driver.c File Reference


Detailed Description

Atmel Corporation

Revision
1.2
Date
Wednesday, January 26, 2005 10:43:44 UTC

Definition in file LCD_driver.c.

#include "iom169.h"
#include "LCD_driver.h"
#include "types.h"

Include dependency graph for LCD_driver.c:

Include dependency graph

Go to the source code of this file.

Functions

void LCD_AllSegments (char show)
void LCD_Init (void)
__interrupt void LCD_SOF_interrupt (void)
void LCD_WriteDigit (char c, char digit)

Variables

BOOL gAutoPressJoystick
unsigned char gButtonTimeout
char gColon = 0
char gFlashTimer = 0
char gLCD_Start_Scroll_Timer = 0
char gLCD_Update_Required = FALSE
signed char gScroll
char gScrollMode
char gTextBuffer [TEXTBUFFER_SIZE]
__flash unsigned int LCD_character_table []
char LCD_Data [LCD_REGISTER_COUNT]


Function Documentation

void LCD_AllSegments char  show  ) 
 

Definition at line 230 of file LCD_driver.c.

References LCD_Data, and LCD_REGISTER_COUNT.

Referenced by LCD_Init().

00231 { 00232 unsigned char i; 00233 00234 if (show) 00235 show = 0xFF; 00236 00237 // Set/clear all bits in all LCD registers 00238 for (i=0; i < LCD_REGISTER_COUNT; i++) 00239 *(LCD_Data + i) = show; 00240 }

void LCD_Init void   ) 
 

Definition at line 134 of file LCD_driver.c.

References FALSE, gLCD_Update_Required, LCD_AllSegments(), LCD_CONTRAST_LEVEL, and LCD_INITIAL_CONTRAST.

Referenced by Initialization().

00135 { 00136 LCD_AllSegments(FALSE); // Clear segment buffer. 00137 00138 LCD_CONTRAST_LEVEL(LCD_INITIAL_CONTRAST); //Set the LCD contrast level 00139 00140 // Select asynchronous clock source, enable all COM pins and enable all 00141 // segment pins. 00142 LCDCRB = (1<<LCDCS) | (3<<LCDMUX0) | (7<<LCDPM0); 00143 00144 // Set LCD prescaler to give a framerate of 32,0 Hz 00145 LCDFRR = (0<<LCDPS0) | (7<<LCDCD0); 00146 00147 LCDCRA = (1<<LCDEN) | (1<<LCDAB); // Enable LCD and set low power waveform 00148 00149 //Enable LCD start of frame interrupt 00150 LCDCRA |= (1<<LCDIE); 00151 00152 gLCD_Update_Required = FALSE; 00153 00154 00155 }

Here is the call graph for this function:

__interrupt void LCD_SOF_interrupt void   ) 
 

Definition at line 255 of file LCD_driver.c.

References __interrupt, FALSE, gButtonTimeout, gColon, gFlashTimer, gLCD_Start_Scroll_Timer, gLCD_Update_Required, gScroll, gScrollMode, gTextBuffer, LCD_Data, LCD_FLASH_SEED, LCD_REGISTER_COUNT, LCD_TIMER_SEED, LCD_WriteDigit(), pLCDREG, and TRUE.

00256 { 00257 static char LCD_timer = LCD_TIMER_SEED; 00258 char c; 00259 char c_flash; 00260 char flash; 00261 00262 char EOL; 00263 unsigned char i; 00264 00265 00266 static char timeout_count; 00267 00268 00269 /**************** Button timeout for the button.c, START ****************/ 00270 if(!gButtonTimeout) 00271 { 00272 timeout_count++; 00273 00274 if(timeout_count > 3) 00275 { 00276 gButtonTimeout = TRUE; 00277 timeout_count = 0; 00278 } 00279 } 00280 /**************** Button timeout for the button.c, END ******************/ 00281 00282 /**************** Auto press joystick for the main.c, START *************/ 00283 /*if(gAutoPressJoystick == AUTO) 00284 { 00285 auto_joystick_count++; 00286 00287 if(auto_joystick_count > 16) 00288 { 00289 gAutoPressJoystick = TRUE; 00290 auto_joystick_count = 15; 00291 } 00292 } 00293 else 00294 auto_joystick_count = 0; 00295 */ 00296 /**************** Auto press joystick for the main.c, END ***************/ 00297 00298 LCD_timer--; // Decreased every LCD frame 00299 00300 if (gScrollMode) 00301 { 00302 // If we are in scroll mode, and the timer has expired, 00303 // we will update the LCD 00304 if (LCD_timer == 0) 00305 { 00306 if (gLCD_Start_Scroll_Timer == 0) 00307 { 00308 gLCD_Update_Required = TRUE; 00309 } 00310 else 00311 gLCD_Start_Scroll_Timer--; 00312 } 00313 } 00314 else 00315 { // if not scrolling, 00316 // disble LCD start of frame interrupt 00317 // cbi(LCDCRA, LCDIE); //DEBUG 00318 gScroll = 0; 00319 } 00320 00321 00322 EOL = FALSE; 00323 if (gLCD_Update_Required == TRUE) 00324 { 00325 // Duty cycle of flashing characters 00326 if (gFlashTimer < (LCD_FLASH_SEED >> 1)) 00327 flash = 0; 00328 else 00329 flash = 1; 00330 00331 // Repeat for the six LCD characters 00332 for (i = 0; i < 6; i++) 00333 { 00334 if ((gScroll+i) >= 0 && (!EOL)) 00335 { 00336 // We have some visible characters 00337 c = gTextBuffer[i + gScroll]; 00338 c_flash = c & 0x80 ? 1 : 0; 00339 c = c & 0x7F; 00340 00341 if (c == '\0') 00342 EOL = i+1; // End of character data 00343 } 00344 else 00345 c = ' '; 00346 00347 // Check if this character is flashing 00348 00349 if (c_flash && flash) 00350 LCD_WriteDigit(' ', i); 00351 else 00352 LCD_WriteDigit(c, i); 00353 } 00354 00355 // Copy the segment buffer to the real segments 00356 for (i = 0; i < LCD_REGISTER_COUNT; i++) 00357 *(pLCDREG + i) = *(LCD_Data+i); 00358 00359 // Handle colon 00360 if (gColon) 00361 *(pLCDREG + 8) = 0x01; 00362 else 00363 *(pLCDREG + 8) = 0x00; 00364 00365 // If the text scrolled off the display, 00366 // we have to start over again. 00367 if (EOL == 1) 00368 gScroll = -6; 00369 else 00370 gScroll++; 00371 00372 // No need to update anymore 00373 gLCD_Update_Required = FALSE; 00374 } 00375 00376 00377 // LCD_timer is used when scrolling text 00378 if (LCD_timer == 0) 00379 { 00380 /* if ((gScroll <= 0) || EOL) 00381 LCD_timer = LCD_TIMER_SEED/2; 00382 else*/ 00383 LCD_timer = LCD_TIMER_SEED; 00384 } 00385 00386 // gFlashTimer is used when flashing characters 00387 if (gFlashTimer == LCD_FLASH_SEED) 00388 gFlashTimer= 0; 00389 else 00390 gFlashTimer++; 00391 00392 }

Here is the call graph for this function:

void LCD_WriteDigit char  c,
char  digit
 

Definition at line 174 of file LCD_driver.c.

References LCD_character_table, LCD_Data, and mask.

Referenced by LCD_SOF_interrupt().

00175 { 00176 00177 unsigned int seg = 0x0000; // Holds the segment pattern 00178 char mask, nibble; 00179 char *ptr; 00180 char i; 00181 00182 00183 if (digit > 5) // Skip if digit is illegal 00184 return; 00185 00186 //Lookup character table for segmet data 00187 if ((c >= '*') && (c <= 'z')) 00188 { 00189 // c is a letter 00190 if (c >= 'a') // Convert to upper case 00191 c &= ~0x20; // if necessarry 00192 00193 c -= '*'; 00194 00195 seg = LCD_character_table[c]; 00196 } 00197 00198 // Adjust mask according to LCD segment mapping 00199 if (digit & 0x01) 00200 mask = 0x0F; // Digit 1, 3, 5 00201 else 00202 mask = 0xF0; // Digit 0, 2, 4 00203 00204 ptr = LCD_Data + (digit >> 1); // digit = {0,0,1,1,2,2} 00205 00206 for (i = 0; i < 4; i++) 00207 { 00208 nibble = seg & 0x000F; 00209 seg >>= 4; 00210 if (digit & 0x01) 00211 nibble <<= 4; 00212 *ptr = (*ptr & mask) | nibble; 00213 ptr += 5; 00214 } 00215 }


Variable Documentation

BOOL gAutoPressJoystick
 

Definition at line 32 of file LCD_driver.c.

unsigned char gButtonTimeout
 

Definition at line 30 of file LCD_driver.c.

Referenced by LCD_SOF_interrupt(), and PinChangeInterrupt().

char gColon = 0
 

Definition at line 58 of file LCD_driver.c.

Referenced by LCD_Colon(), and LCD_SOF_interrupt().

char gFlashTimer = 0
 

Definition at line 55 of file LCD_driver.c.

Referenced by LCD_FlashReset(), and LCD_SOF_interrupt().

char gLCD_Start_Scroll_Timer = 0
 

Definition at line 51 of file LCD_driver.c.

Referenced by LCD_puts(), LCD_puts_f(), and LCD_SOF_interrupt().

char gLCD_Update_Required = FALSE
 

Definition at line 35 of file LCD_driver.c.

Referenced by LCD_Init(), LCD_puts(), LCD_puts_f(), LCD_SOF_interrupt(), and LCD_UpdateRequired().

signed char gScroll
 

Definition at line 47 of file LCD_driver.c.

Referenced by LCD_puts(), LCD_puts_f(), LCD_SOF_interrupt(), and LCD_UpdateRequired().

char gScrollMode
 

Definition at line 48 of file LCD_driver.c.

Referenced by LCD_puts(), LCD_puts_f(), LCD_SOF_interrupt(), and LCD_UpdateRequired().

char gTextBuffer[TEXTBUFFER_SIZE]
 

Definition at line 42 of file LCD_driver.c.

Referenced by LCD_Clear(), LCD_putc(), LCD_puts(), LCD_puts_f(), and LCD_SOF_interrupt().

__flash unsigned int LCD_character_table[]
 

Definition at line 63 of file LCD_driver.c.

Referenced by LCD_WriteDigit().

char LCD_Data[LCD_REGISTER_COUNT]
 

Definition at line 38 of file LCD_driver.c.

Referenced by LCD_AllSegments(), LCD_SOF_interrupt(), and LCD_WriteDigit().


Generated on Tue Nov 1 16:21:39 2005 for AVR323 Interfacing GSM modems by doxygen 1.3.7