$treeview $search $mathjax $extrastylesheet
avr-libc  2.0.0
$projectbrief
$projectbrief
$searchbox

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

hd44780.h

00001 /*
00002  * ----------------------------------------------------------------------------
00003  * "THE BEER-WARE LICENSE" (Revision 42):
00004  * <joerg@FreeBSD.ORG> wrote this file.  As long as you retain this notice you
00005  * can do whatever you want with this stuff. If we meet some day, and you think
00006  * this stuff is worth it, you can buy me a beer in return.        Joerg Wunsch
00007  * ----------------------------------------------------------------------------
00008  *
00009  * HD44780 LCD display driver
00010  *
00011  * $Id$
00012  */
00013 
00014 /*
00015  * Send byte b to the LCD.  rs is the RS signal (register select), 0
00016  * selects instruction register, 1 selects the data register.
00017  */
00018 void    hd44780_outbyte(uint8_t b, uint8_t rs);
00019 
00020 /*
00021  * Read one byte from the LCD controller.  rs is the RS signal, 0
00022  * selects busy flag (bit 7) and address counter, 1 selects the data
00023  * register.
00024  */
00025 uint8_t hd44780_inbyte(uint8_t rs);
00026 
00027 /*
00028  * Wait for the busy flag to clear.
00029  */
00030 void    hd44780_wait_ready(bool islong);
00031 
00032 /*
00033  * Initialize the LCD controller hardware.
00034  */
00035 void    hd44780_init(void);
00036 
00037 /*
00038  * Prepare the LCD controller pins for powerdown.
00039  */
00040 void    hd44780_powerdown(void);
00041 
00042 
00043 /* Send a command to the LCD controller. */
00044 #define hd44780_outcmd(n)   hd44780_outbyte((n), 0)
00045 
00046 /* Send a data byte to the LCD controller. */
00047 #define hd44780_outdata(n)  hd44780_outbyte((n), 1)
00048 
00049 /* Read the address counter and busy flag from the LCD. */
00050 #define hd44780_incmd()     hd44780_inbyte(0)
00051 
00052 /* Read the current data byte from the LCD. */
00053 #define hd44780_indata()    hd44780_inbyte(1)
00054 
00055 
00056 /* Clear LCD display command. */
00057 #define HD44780_CLR \
00058     0x01
00059 
00060 /* Home cursor command. */
00061 #define HD44780_HOME \
00062     0x02
00063 
00064 /*
00065  * Select the entry mode.  inc determines whether the address counter
00066  * auto-increments, shift selects an automatic display shift.
00067  */
00068 #define HD44780_ENTMODE(inc, shift) \
00069     (0x04 | ((inc)? 0x02: 0) | ((shift)? 1: 0))
00070 
00071 /*
00072  * Selects disp[lay] on/off, cursor on/off, cursor blink[ing]
00073  * on/off.
00074  */
00075 #define HD44780_DISPCTL(disp, cursor, blink) \
00076     (0x08 | ((disp)? 0x04: 0) | ((cursor)? 0x02: 0) | ((blink)? 1: 0))
00077 
00078 /*
00079  * With shift = 1, shift display right or left.
00080  * With shift = 0, move cursor right or left.
00081  */
00082 #define HD44780_SHIFT(shift, right) \
00083     (0x10 | ((shift)? 0x08: 0) | ((right)? 0x04: 0))
00084 
00085 /*
00086  * Function set.  if8bit selects an 8-bit data path, twoline arranges
00087  * for a two-line display, font5x10 selects the 5x10 dot font (5x8
00088  * dots if clear).
00089  */
00090 #define HD44780_FNSET(if8bit, twoline, font5x10) \
00091     (0x20 | ((if8bit)? 0x10: 0) | ((twoline)? 0x08: 0) | \
00092         ((font5x10)? 0x04: 0))
00093 
00094 /*
00095  * Set the next character generator address to addr.
00096  */
00097 #define HD44780_CGADDR(addr) \
00098     (0x40 | ((addr) & 0x3f))
00099 
00100 /*
00101  * Set the next display address to addr.
00102  */
00103 #define HD44780_DDADDR(addr) \
00104     (0x80 | ((addr) & 0x7f))
00105 
 All Data Structures Files Functions Variables Typedefs Enumerations Defines