/* ------------------------------------- Normally only used for BOARD ELAVR32, using Port A for a LCD-Display ------------------------------------- */ // Datei: LCD.H // // Ansteuerung einer LCD-Anzeige // im 4 Bit Daten Mode // // Holger Klabunde // 11.10.2002 // Compiler AVR-GCC // 08.12.2005 // changed by Elmar Benninghaus // for own board elavr32 //Ausgänge für die Ansteuerung der LCD-Anzeige //PORTA AVR an Datenleitungen der LCD-Anzeige #ifndef ___LCD_H #define ___LCD_H #include "global.h" #include "utils.h" #ifdef FCPU1 #define LCDDELAYENABLE DELAY1us #endif #ifdef FCPU2 #define LCDDELAYENABLE DELAY500ns #endif #ifdef FCPU4 #define LCDDELAYENABLE DELAY250ns #endif #ifdef FCPU8 #define LCDDELAYENABLE DELAY250ns #endif #ifdef FCPU11 #define LCDDELAYENABLE DELAY271ns #endif #ifdef FCPU14 #define LCDDELAYENABLE DELAY271ns #endif #ifdef FCPU16 #define LCDDELAYENABLE DELAY250ns #endif //for ( black/green lcd with KS0070B controller (HD44780 compatible) //the initial reset after power-up is min 15 milliseconds. //The used max executiontime is 1.64 ms for Display Clear, and Return Home. //The normally max. executionstime for others like Write Data .... //is 46 Mikrosek. // //With an ext. clock of 14,7456 Mhz, the timings used from global.h //trying to reduce it what, upper meaned lcd really uses, additionally //a little tolerance. //With current timings we are able to use a setpos, and a complete write //of 16 chars to this position, 276 times per second. ( one row displ.) //138 times per second for 2xsetpos, and 2x16chars ( 2 row display ) // 69 times per second for 4xsetpos, and 4x16chars ( 4 row display ) // We can reduce this timings a little bit, reading the lcd for the // busy-flag, but normally the execution times, explained in the datasheets // are the really times, so it seems to be equal if we poll, or wait. //if you do not use the same signals as board elavr32 //you have to define followings before. #ifndef LCD_CS #define LCD_RS 2 //LCD Register Select #define LCD_CS 1 //LCD Chip Select #define LCD_RW 3 //LCD R/_W #define LCDCS_ON() { sbi(PORTA,LCD_CS); } #define LCDCS_OFF() { cbi(PORTA,LCD_CS); } #define LCDRS_ON() { sbi(PORTA,LCD_RS); } #define LCDRS_OFF() { cbi(PORTA,LCD_RS); } #define LCDWR_OFF() { sbi(PORTA,LCD_RW); } #define LCDWR_ON() { cbi(PORTA,LCD_RW); } #endif extern void LCDInit(void); extern void LCDWriteByte(unsigned char); extern void LCDWriteCmd(unsigned char); extern void LCDWrite(char *); extern void LCDWriteP(char *); extern void LCDCls(void); extern void LCDPos(unsigned char, unsigned char); extern void ShowHex(unsigned char by); #endif