-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpi_hd44780.h
96 lines (80 loc) · 1.53 KB
/
rpi_hd44780.h
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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <bcm2835.h> // http://www.open.com.au/mikem/bcm2835/index.html
/*
*
*/
#define CNULL_TERM (char *) NULL
/*
* PIN mappings for HD44780
* http://www.open.com.au/mikem/bcm2835/group__constants.html#ga63c029bd6500167152db4e57736d0939
*/
#define H_RS RPI_GPIO_P1_26 // CE1
#define H_E RPI_GPIO_P1_24 // CE0
#define H_D4 RPI_GPIO_P1_22 // #25
#define H_D5 RPI_GPIO_P1_18 // #24
#define H_D6 RPI_GPIO_P1_16 // #23
#define H_D7 RPI_GPIO_P1_12 // #18
/*
* Cursor addresses
*/
#define LINE1_START 0x80
#define LINE2_START 0xC0
#define LINE3_START 0x94
#define LINE4_START 0xD4
/*
* Timing
*/
#define P_NARROW 200 // Min delay 120
#define P_WIDE 5500 // Pulse width
#define P_15MS 15500 // >15ms
/*
*
*/
int HD_PINS[6] = {
H_RS, H_E, H_D4,
H_D5, H_D6, H_D7
};
/*
*
*/
int HD_DATAPINS[4] = {
H_D4, H_D5, H_D6, H_D7
};
/*
* Set GPIO pins to OUTPUT
*/
int lcd_set_gpio_pins ( void );
/*
* Initialize screen
*/
int lcd_init ( void );
/*
* Clear screen command
*/
void lcd_clear_screen ( void );
/*
* Set cursor to memory addr
*/
void lcd_set_cursor ( unsigned char u8_line );
/*
* Send single char
*/
void lcd_send_char ( const char u8_char );
/*
* Send character string
*/
int lcd_send_string ( const char *str );
/*
* Send byte
*/
void lcd_send_byte ( const unsigned char u8_byte, int mode );
/*
* Send half a byte
*/
void lcd_send_nibble ( const unsigned char u8_byte, int mode );
/*
* Pulse E for command data
*/
void lcd_epulse ( int narrow );