/* * Title: LCD_Routines * * Author: Blake C. Sutton * * Description: This is a set of functions used to initialize and write to the * LCD screen in 4-bit mode. The LCD uses Port B in the following port format: * * Lower nibble (Port B 0 to 3) represents the data sent (upper nibble on LCD). * * Bits 6, 5, and 4 represent RS RW, and E, respectively. * * This can also be used to test your LCD to verify that you didn't burn it... * which if you are Blake can be a very useful thing :D * */ #ifndef __LCD_ROUTINES__ #define __LCD_ROUTINES__ #include "Delay_Routines.h" /* 8-bit unsigned integer used for passing LCD bytes * without parameter overhead */ volatile uint8_t lcd_byte; /* 8-bit unsigned inteteger used for passing LCD output bytes * Without parameter overhead. Consists of nibble + RS + RW + E bits. */ volatile uint8_t lcd_nibble; /* Writes one nibble of raw information to LCD, * once it has been properly encoded by write_data_byte * or write_control_byte. * * Parameter: lcd_nibble (global variable, 8-bit unsigned integer) */ void write_nibble(void); /* Writes one control byte (clear screen, next line, etc.) in 4-bit mode. * This should not be used for data -- use write_data_byte. * * Parameter: lcd_byte (global variable, 8-bit int) */ void write_control_byte(void); /* Writes one byte of data (one ASCII char) to the LCD in 4-bit mode. * Thus the upper nibble is written, then * the lower nibble. * * Parameter: lcd_byte (global variable, 8-bit int) */ void write_data_byte(void) ; /* Clears LCD screen and returns cursor to home */ void clear_home(void); /* Internal Function -- do not call this, call init_LCD() */ void init_lcd_ports_and_timer(void) ; /* Initialize LCD for 4-bit mode, 2-line mode. * When this routine returns, LCD is ready to display * characters. */ void init_LCD(void); /* * Writes out the parameter string to the LCD. * LCD must be initialized first. */ void write_string(char input[]); /* Function that takes in an 8 bit value and displays it on the LCD * according to the options -- ghetto printf. * * display_options is a string, as follows: * decimal -- display as base 10 integer NOT YET IMPLEMENTED * hex -- display as base 16 (hexadecimal) number (0xNN) * binary -- display as binary (XXXXXXXX ) * char -- display as ASCII char (a, b, c, etc.) */ void print_byte(uint8_t value, char display_options[] ); #endif