1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/* $NetBSD: hd44780var.h,v 1.8 2015/09/06 06:01:00 dholland Exp $ */
/*
* Copyright (c) 2002 Dennis I. Chernoivanov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEV_IC_HD44780VAR_H_
#define _DEV_IC_HD44780VAR_H_
#include <sys/ioccom.h>
/* IOCTL definitions */
#define HLCD_DISPCTL _IOW('h', 1, struct hd44780_dispctl)
#define HLCD_RESET _IO('h', 2)
#define HLCD_CLEAR _IO('h', 3)
#define HLCD_CURSOR_LEFT _IO('h', 4)
#define HLCD_CURSOR_RIGHT _IO('h', 5)
#define HLCD_GET_CURSOR_POS _IOR('h', 6, struct hd44780_io)
#define HLCD_SET_CURSOR_POS _IOW('h', 7, struct hd44780_io)
#define HLCD_GETC _IOR('h', 8, struct hd44780_io)
#define HLCD_PUTC _IOW('h', 9, struct hd44780_io)
#define HLCD_SHIFT_LEFT _IO('h', 10)
#define HLCD_SHIFT_RIGHT _IO('h', 11)
#define HLCD_HOME _IO('h', 12)
#define HLCD_WRITE _IOWR('h', 13, struct hd44780_io)
#define HLCD_READ _IOWR('h', 14, struct hd44780_io)
#define HLCD_REDRAW _IOW('h', 15, struct hd44780_io)
#define HLCD_WRITE_INST _IOW('h', 16, struct hd44780_io)
#define HLCD_WRITE_DATA _IOW('h', 17, struct hd44780_io)
#define HLCD_GET_INFO _IOR('h', 18, struct hd44780_info)
#define HLCD_GET_CHIPNO _IOR('h', 19, uint8_t)
#define HLCD_SET_CHIPNO _IOW('h', 20, uint8_t)
struct hd44780_dispctl {
uint8_t chip;
uint8_t display_on:1,
blink_on:1,
cursor_on:1;
};
struct hd44780_io {
uint8_t chip;
uint8_t dat;
uint8_t len;
uint8_t buf[HD_MAX_CHARS];
};
struct hd44780_info {
uint8_t lines;
uint8_t phys_rows;
uint8_t virt_rows;
uint8_t is_wide:1,
is_bigfont:1,
kp_present:1;
};
#ifdef _KERNEL
struct hlcd_screen {
int hlcd_curon;
int hlcd_curx;
int hlcd_cury;
uint8_t *image; /* characters of screen */
struct hd44780_chip *hlcd_sc;
};
/* HLCD driver structure */
struct hd44780_chip {
#define HD_8BIT 0x01 /* 8-bit if set, 4-bit otherwise */
#define HD_MULTILINE 0x02 /* 2 lines if set, 1 otherwise */
#define HD_BIGFONT 0x04 /* 5x10 if set, 5x8 otherwise */
#define HD_KEYPAD 0x08 /* if set, keypad is connected */
#define HD_UP 0x10 /* if set, lcd has been initialized */
#define HD_TIMEDOUT 0x20 /* lcd has recently stopped talking */
#define HD_MULTICHIP 0x40 /* two HD44780 controllers (4-line) */
uint8_t sc_flags;
uint8_t sc_cols; /* visible columns */
uint8_t sc_vcols; /* virtual columns (normally 40) */
uint8_t sc_dev_ok;
uint8_t sc_curchip;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioir; /* instruction register */
bus_space_handle_t sc_iodr; /* data register */
device_t sc_dev; /* Pointer to parent device */
struct hlcd_screen sc_screen; /* currently displayed screen copy */
struct hlcd_screen *sc_curscr; /* active screen */
struct callout redraw; /* wsdisplay refresh/redraw timer */
/* Generic write/read byte entries. */
void (* sc_writereg)(struct hd44780_chip *, uint32_t, uint32_t,
uint8_t);
uint8_t (* sc_readreg)(struct hd44780_chip *, uint32_t, uint32_t);
};
#define hd44780_ir_write(sc, en, dat) \
do { \
hd44780_busy_wait(sc, (en)); \
(sc)->sc_writereg((sc), (en), 0, (dat)); \
} while(0)
#define hd44780_ir_read(sc, en) \
(sc)->sc_readreg((sc), (en), 0)
#define hd44780_dr_write(sc, en, dat) \
(sc)->sc_writereg((sc), (en), 1, (dat))
#define hd44780_dr_read(sc, en) \
(sc)->sc_readreg((sc), (en), 1)
void hd44780_attach_subr(struct hd44780_chip *);
void hd44780_busy_wait(struct hd44780_chip *, uint32_t);
int hd44780_init(struct hd44780_chip *);
int hd44780_chipinit(struct hd44780_chip *, uint32_t);
int hd44780_ioctl_subr(struct hd44780_chip *, u_long, void *);
void hd44780_ddram_redraw(struct hd44780_chip *, uint32_t, struct hd44780_io *);
#define HD_DDRAM_READ 0x0
#define HD_DDRAM_WRITE 0x1
int hd44780_ddram_io(struct hd44780_chip *, uint32_t, struct hd44780_io *,
uint8_t);
#if defined(HD44780_STD_WIDE) || defined(HD44780_STD_SHORT)
void hd44780_writereg(struct hd44780_chip *, uint32_t, uint32_t, uint8_t);
uint8_t hd44780_readreg(struct hd44780_chip *, uint32_t, uint32_t);
#endif
#endif /* _KERNEL */
#endif /* _DEV_IC_HD44780VAR_H_ */
|