1 /*-------------------------------------------------------------------------
2 lcd.c - lcd routines for the DS80C390 (tested on TINI)
4 Written By - Johan Knol, johan.knol@iduna.nl
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
23 -------------------------------------------------------------------------*/
29 #define LCD_COLLUMNS 20
32 /* set the dd ram addresses for the rows
33 this one is for a 20x4 LCD
35 static unsigned char lcdLinesStart[LCD_ROWS]={0, 0x40, 0x14, 0x54};
37 /* Commercial TINI stick connector boards don't support rw
38 control for the lcd-display.
39 My own board does, and it makes it much faster.
44 __xdata __at (0x380002) static unsigned char lcdIwr;
45 __xdata __at (0x38000a) static unsigned char lcdDwr;
49 __xdata __at (0x380003) static unsigned char lcdIrd;
50 __xdata __at (0x38000b) static unsigned char lcdDrd;
52 #define LcdWait { while (lcdIrd&0x80) ; }
57 #define LcdWait { ClockMicroSecondsDelay(100) ; }
59 #endif // ifdef LCD_RW
63 ClockMilliSecondsDelay(16); // >15 ms
66 ClockMilliSecondsDelay(5); // >4.1 ms
69 ClockMicroSecondsDelay(101); // >100 us
72 ClockMicroSecondsDelay(101); // >100 us
74 lcdIwr=0x38; // interface 8 bit
75 ClockMicroSecondsDelay(41); // >40 us
77 lcdIwr=0x0c; // display on
78 ClockMicroSecondsDelay(41); // >40 us
84 lcdIwr=0x0c; // display on
89 lcdIwr=0x08; // display off
105 void LcdScrollOff() {
109 void LcdCharDefine() {
114 lcdIwr=0x01; // display clear
115 ClockMilliSecondsDelay(6); // > 5ms
119 lcdIwr=0x80; // set dd ram address 0
123 void LcdGoto(unsigned int collumnRow) { // msb=collumn, lsb=row
125 lcdLinesStart[collumnRow&0xff] + (collumnRow>>8);
129 void LcdPutChar(char c) {
134 void LcdPutString (char *string) {
136 while (c=*string++) {
141 void LcdLPutString (unsigned int collumnRow, char *string) {
143 LcdPutString(string);
146 // let's hope that no one ever printf's more than the display width,
147 // however they will :), so to be sure
148 static char lcdPrintfBuffer[LCD_COLLUMNS*4];
150 void LcdPrintf (const char *format, ...) __reentrant {
153 va_start (arg, format);
154 vsprintf (lcdPrintfBuffer, format, arg);
155 puts (lcdPrintfBuffer);
156 LcdPutString(lcdPrintfBuffer);
161 void LcdLPrintf (unsigned int collumnRow, const char *format, ...) __reentrant {
166 // we can not just call LcdPrintf since we have no idea what is on the stack,
167 // so we have to do it all over again
168 va_start (arg, format);
169 vsprintf (lcdPrintfBuffer, format, arg);
171 LcdPutString(lcdPrintfBuffer);