/******************************************************************************* * File: lcd.h * Title: LCD header file for use with 24C16.c * also needs: lcd.h * Compiler: AVR-GCC 3.3.1 * Version: 1.0 * last update: 30-03-2004 * Target: ATmega8 * Author: Christoph Redecker * Company: www.avrbeginners.net ******************************************************************************** * Electrical connection: * LCd data port <-> PortD * RS <- PortC.0 * RW <- PortC.1 * E <- PortC.2 *******************************************************************************/ #define LCD_RS 0 #define LCD_RW 1 #define LCD_E 2 #include #include #include /******************************************************************************* * LCD_putchar writes a character to the LCD display ram. It does not do ANY * busy flag checking, neither before nor after the write operation * LCD_getaddr reads the address counter including the busy flag * LCD_wait waits for the busy flag to be cleared after a curent operation * LCD_command writes command or address data (if bit 7 set) to the LCD. * LCD_init initialises the LCD with the given values (see function definition) * LCD_write prints a string on the LCD. No checking for non-terminated string is done! * LCD_puthex prints a hex view of a given value on the LCD. * Example: LCD_puthex(1) prints "0x01" on the LCD *******************************************************************************/ //Prototypes: void LCD_putchar(char data); char LCD_getaddr(void); void LCD_wait(void); void LCD_command(char command); void LCD_init(void); void LCD_write(char* dstring); void LCD_puthex(const char data); char hstring[16] = "0123456789ABCDEF"; //used by LCD_puthex void LCD_putchar(char data) { //PortD is output DDRD = 0xFF; //put data on bus PORTD = data; //RW low, E low PORTC &= ~((1<>4]); LCD_wait(); //print low nibble as hex LCD_putchar(hstring[data & 0x0F]); }