/* Tommy Thorn 1999 based on code by Brajer Vlado */ /* This LCD is wired as follows: PA0-PA3: bit 4-7 on the LCD (data bits in 4-bit mode) PA4: E PA5: RS RW isn't connected to a port but to forced low (write mode) as we don't read anyway. */ /* The reason for using the conditional is that the argument `x' will always be a constant, thus reduced at compile time. Using sbi/cbi is much more efficient and succint that using outp/inp */ #define LCD_E(x) ({if (x) sbi(PORTA,4); else cbi(PORTA,4);}) #define LCD_RS(x) ({if (x) sbi(PORTA,5); else cbi(PORTA,5);}) #define LCD_RW(x) /* Nothing */ #define LCD_DATA(d) outp(((d)&0xF)|(inp(PORTA)&0xF0),PORTA) #define LCD_INIT() outp(0x3F,DDRA); LCD_RS(0); LCD_RW(0) #define us #define ms * 1000 #define LCD_CTL_DISPON 4 #define LCD_CTL_CURSOR 2 #define LCD_CTL_BLINK 1 #include #include #include typedef unsigned char byte; extern unsigned char lcd_pos; void lcd_delay(unsigned int p); void toggle_E(); void lcd_cls(); void lcd_home(); void lcd_control(byte control); void lcd_goto(byte mesto); void lcd_putch(byte data); void lcd_putstr(byte *data); void printbin(byte x); void printhex(byte i); void print2(unsigned int x); void print3(unsigned int x); void print5(unsigned int x); void print10(unsigned long x); void lcd_init(void); int printf(const char *format, ...);