AVR-LibC  2.2.0
Standard C library for AVR-GCC
 

AVR-LibC Documentation

Logo

AVR-LibC Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

File List

Loading...
Searching...
No Matches
hd44780.h
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
7 * ----------------------------------------------------------------------------
8 *
9 * HD44780 LCD display driver
10 *
11 * $Id$
12 */
13
14/*
15 * Send byte b to the LCD. rs is the RS signal (register select), 0
16 * selects instruction register, 1 selects the data register.
17 */
18void hd44780_outbyte(uint8_t b, uint8_t rs);
19
20/*
21 * Read one byte from the LCD controller. rs is the RS signal, 0
22 * selects busy flag (bit 7) and address counter, 1 selects the data
23 * register.
24 */
25uint8_t hd44780_inbyte(uint8_t rs);
26
27/*
28 * Wait for the busy flag to clear.
29 */
30void hd44780_wait_ready(bool islong);
31
32/*
33 * Initialize the LCD controller hardware.
34 */
35void hd44780_init(void);
36
37/*
38 * Prepare the LCD controller pins for powerdown.
39 */
40void hd44780_powerdown(void);
41
42
43/* Send a command to the LCD controller. */
44#define hd44780_outcmd(n) hd44780_outbyte((n), 0)
45
46/* Send a data byte to the LCD controller. */
47#define hd44780_outdata(n) hd44780_outbyte((n), 1)
48
49/* Read the address counter and busy flag from the LCD. */
50#define hd44780_incmd() hd44780_inbyte(0)
51
52/* Read the current data byte from the LCD. */
53#define hd44780_indata() hd44780_inbyte(1)
54
55
56/* Clear LCD display command. */
57#define HD44780_CLR \
58 0x01
59
60/* Home cursor command. */
61#define HD44780_HOME \
62 0x02
63
64/*
65 * Select the entry mode. inc determines whether the address counter
66 * auto-increments, shift selects an automatic display shift.
67 */
68#define HD44780_ENTMODE(inc, shift) \
69 (0x04 | ((inc)? 0x02: 0) | ((shift)? 1: 0))
70
71/*
72 * Selects disp[lay] on/off, cursor on/off, cursor blink[ing]
73 * on/off.
74 */
75#define HD44780_DISPCTL(disp, cursor, blink) \
76 (0x08 | ((disp)? 0x04: 0) | ((cursor)? 0x02: 0) | ((blink)? 1: 0))
77
78/*
79 * With shift = 1, shift display right or left.
80 * With shift = 0, move cursor right or left.
81 */
82#define HD44780_SHIFT(shift, right) \
83 (0x10 | ((shift)? 0x08: 0) | ((right)? 0x04: 0))
84
85/*
86 * Function set. if8bit selects an 8-bit data path, twoline arranges
87 * for a two-line display, font5x10 selects the 5x10 dot font (5x8
88 * dots if clear).
89 */
90#define HD44780_FNSET(if8bit, twoline, font5x10) \
91 (0x20 | ((if8bit)? 0x10: 0) | ((twoline)? 0x08: 0) | \
92 ((font5x10)? 0x04: 0))
93
94/*
95 * Set the next character generator address to addr.
96 */
97#define HD44780_CGADDR(addr) \
98 (0x40 | ((addr) & 0x3f))
99
100/*
101 * Set the next display address to addr.
102 */
103#define HD44780_DDADDR(addr) \
104 (0x80 | ((addr) & 0x7f))
105
unsigned char uint8_t
Definition: stdint.h:83