AVR-LibC  2.3.0git
Standard C library for AVR-GCC
 

AVR-LibC Documen­tation

AVR-LibC Development Pages

Main Page

User Manual

Library Refe­rence

FAQ

Example Projects

File List

Index

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
12/*
13 * Send byte b to the LCD. rs is the RS signal (register select), 0
14 * selects instruction register, 1 selects the data register.
15 */
16void hd44780_outbyte(uint8_t b, uint8_t rs);
17
18/*
19 * Read one byte from the LCD controller. rs is the RS signal, 0
20 * selects busy flag (bit 7) and address counter, 1 selects the data
21 * register.
22 */
23uint8_t hd44780_inbyte(uint8_t rs);
24
25/*
26 * Wait for the busy flag to clear.
27 */
28void hd44780_wait_ready(bool islong);
29
30/*
31 * Initialize the LCD controller hardware.
32 */
33void hd44780_init(void);
34
35/*
36 * Prepare the LCD controller pins for powerdown.
37 */
38void hd44780_powerdown(void);
39
40
41/* Send a command to the LCD controller. */
42#define hd44780_outcmd(n) hd44780_outbyte((n), 0)
43
44/* Send a data byte to the LCD controller. */
45#define hd44780_outdata(n) hd44780_outbyte((n), 1)
46
47/* Read the address counter and busy flag from the LCD. */
48#define hd44780_incmd() hd44780_inbyte(0)
49
50/* Read the current data byte from the LCD. */
51#define hd44780_indata() hd44780_inbyte(1)
52
53
54/* Clear LCD display command. */
55#define HD44780_CLR \
56 0x01
57
58/* Home cursor command. */
59#define HD44780_HOME \
60 0x02
61
62/*
63 * Select the entry mode. inc determines whether the address counter
64 * auto-increments, shift selects an automatic display shift.
65 */
66#define HD44780_ENTMODE(inc, shift) \
67 (0x04 | ((inc)? 0x02: 0) | ((shift)? 1: 0))
68
69/*
70 * Selects disp[lay] on/off, cursor on/off, cursor blink[ing]
71 * on/off.
72 */
73#define HD44780_DISPCTL(disp, cursor, blink) \
74 (0x08 | ((disp)? 0x04: 0) | ((cursor)? 0x02: 0) | ((blink)? 1: 0))
75
76/*
77 * With shift = 1, shift display right or left.
78 * With shift = 0, move cursor right or left.
79 */
80#define HD44780_SHIFT(shift, right) \
81 (0x10 | ((shift)? 0x08: 0) | ((right)? 0x04: 0))
82
83/*
84 * Function set. if8bit selects an 8-bit data path, twoline arranges
85 * for a two-line display, font5x10 selects the 5x10 dot font (5x8
86 * dots if clear).
87 */
88#define HD44780_FNSET(if8bit, twoline, font5x10) \
89 (0x20 | ((if8bit)? 0x10: 0) | ((twoline)? 0x08: 0) | \
90 ((font5x10)? 0x04: 0))
91
92/*
93 * Set the next character generator address to addr.
94 */
95#define HD44780_CGADDR(addr) \
96 (0x40 | ((addr) & 0x3f))
97
98/*
99 * Set the next display address to addr.
100 */
101#define HD44780_DDADDR(addr) \
102 (0x80 | ((addr) & 0x7f))
103
unsigned char uint8_t
Definition: stdint.h:81