main.c

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00024 //  Include files
00025 #include "defines.h"
00026 #include "LCD_driver.h"
00027 #include <inavr.h>
00028 
00029 
00034 void LCD_timerDelay( unsigned char delay )
00035 {
00036   __disable_interrupt();
00037   LCD_timer = delay;                          //Plant LCD_timer seed to generate delay - delay*(1/[LCD frame rate])
00038   LCD_status.updateComplete = FALSE;          //Clear updateComplete to be able to test if LCD interrupt has been served
00039   LCD_status.updateRequired = TRUE;           //Request update of the LCD to let the LCD ISR clear set updateComplete
00040   __enable_interrupt();
00041   while( !LCD_status.updateComplete );        //Don't update the LCD_displayData into LCD has been updated
00042 }
00043 
00044 
00047 #define DELAY1 64
00048 #define DELAY2 5
00049 
00050 void main(void)
00051 {
00052     unsigned char counter;
00053     unsigned char testString[] = "STK502";
00054     LCD_Init();                 // initialize the LCD
00055 
00056     __enable_interrupt();
00057 
00058     for(;;)                    //endless main loop
00059     {
00060 //----------------------------------------------------------
00061 // Display a single character from the testString at a time
00062 //----------------------------------------------------------
00063       for (counter = 0; counter < 6; counter++ )
00064       {
00065         while( !LCD_status.updateComplete );        //Don't update the LCD_displayData into LCD has been updated
00066         LCD_status.updateRequired = FALSE;          //Block the updating of the LCD while accessing LCD_displayData
00067 
00068         LCD_WriteDigit( *(testString + counter), counter+2 ); //Write new data to LCD_displayData
00069 
00070         LCD_status.updateComplete = FALSE;          //Clear LCD_updateComplete flag to indicate that LCDdisplayData
00071                                                     // has been updated, but LCD has not been updated yet.
00072         LCD_status.updateRequired = TRUE;           //Request update of the LCD (release LCD update blocking).
00073       }
00074        while( !LCD_status.updateComplete );         //Make sure that the LCD_displayData has been latched
00075 
00076 //----------------------------------------------------------
00077 // Flash the two Colons on the LCD
00078 //----------------------------------------------------------
00079       LCD_status.updateRequired = FALSE;          //Block the updating of the LCD while accessing LCD_displayData
00080       LCD_SET_COLON(TRUE);                        //Display the colons in the LCD
00081       LCD_timerDelay( DELAY1 );                   //Call LCD interrupt controlled delay
00082 
00083       LCD_status.updateRequired = FALSE;          //Block the updating of the LCD while accessing LCD_displayData
00084       LCD_SET_COLON(FALSE);                       //Hide the colons in the LCD
00085       LCD_timerDelay( DELAY1 );                   //Call LCD interrupt controlled delay
00086 
00087 //----------------------------------------------------------
00088 // Vary the contrast level between min and max and min, and back to norm
00089 //----------------------------------------------------------
00090       for(counter = 0x00; counter < 0x0F; counter++)  //Increase LCD contrast to max, in smallest steps
00091       {
00092         LCD_CONTRAST_LEVEL(counter);
00093         LCD_timerDelay( DELAY2 );                   //Call LCD interrupt controlled delay
00094       }
00095       for(counter = 0x0F; counter != 0x00; counter--)  //Decrease LCD contrast to min, in smallest steps
00096       {
00097         LCD_CONTRAST_LEVEL(counter);
00098         LCD_timerDelay( DELAY2 );                   //Call LCD interrupt controlled delay
00099       }
00100       LCD_CONTRAST_LEVEL( LCD_INITIAL_CONTRAST );   //Contrast level back to initial level
00101 
00102 //----------------------------------------------------------
00103 // Clear all LCD digits in within one LCD opdate
00104 //----------------------------------------------------------
00105       while( !LCD_status.updateComplete );          //Wait for last LCD update to complete
00106       LCD_status.updateRequired = FALSE;            //Disable further LCD updating
00107       for (counter = 2; counter < 8; counter++ )
00108       {
00109             LCD_WriteDigit( '-', counter );         //Update LCD_displayData buffer
00110       }
00111       LCD_status.updateRequired = TRUE;             //Enable LCD opdating
00112       while( !LCD_status.updateComplete );          //Make sure that the LCD_displayData has been latched...
00113      }
00114 }
00115 
00116 /* Doxygen documentation mainpage ********************************************/

Generated on Fri Feb 17 12:31:57 2006 for AVR065: LCD Driver for the STK502 by  doxygen 1.4.5