-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtm_stm32f4_hd44780.h
executable file
·279 lines (249 loc) · 6.61 KB
/
tm_stm32f4_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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/**
* @author Tilen Majerle
* @email [email protected]
* @website http://stm32f4-discovery.com
* @link http://stm32f4-discovery.com/2014/06/library-16-interfacing-hd44780-lcd-controller-with-stm32f4/
* @version v1.2
* @ide Keil uVision
* @license GNU GPL v3
* @brief HD44780 LCD driver library for STM32F4xx
*
@verbatim
----------------------------------------------------------------------
Copyright (C) Tilen Majerle, 2015
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------
@endverbatim
*/
#ifndef TM_HD44780_H
#define TM_HD44780_H 120
/**
* @addtogroup TM_STM32F4xx_Libraries
* @{
*/
/**
* @defgroup TM_HD44780
* @brief HD44780 LCD driver library for STM32F4xx - http://stm32f4-discovery.com/2014/06/library-16-interfacing-hd44780-lcd-controller-with-stm32f4/
* @{
*
* It also supports all HD44780 compatible LCD drivers.
*
* \par Default pinout
*
@verbatim
LCD STM32F4XX DESCRIPTION
GND GND Ground
VCC +5V Power supply for LCD
V0 Potentiometer Contrast voltage. Connect to potentiometer
RS PB2 Register select, can be overwritten in your project's defines.h file
RW GND Read/write
E PB7 Enable pin, can be overwritten in your project's defines.h file
D0 - Data 0 - doesn't care
D1 - Data 1 - doesn't care
D2 - Data 2 - doesn't care
D3 - Data 3 - doesn't care
D4 PC12 Data 4, can be overwritten in your project's defines.h file
D5 PC13 Data 5, can be overwritten in your project's defines.h file
D6 PB12 Data 6, can be overwritten in your project's defines.h file
D7 PB13 Data 7, can be overwritten in your project's defines.h file
A +3V3 Back light positive power
K GND Ground for back light
@endverbatim
*
* If you want to change pinout, do this in your defines.h file with lines below and set your own settings:
*
@verbatim
//RS - Register select pin
#define HD44780_RS_PORT GPIOB
#define HD44780_RS_PIN GPIO_PIN_2
//E - Enable pin
#define HD44780_E_PORT GPIOB
#define HD44780_E_PIN GPIO_PIN_7
//D4 - Data 4 pin
#define HD44780_D4_PORT GPIOC
#define HD44780_D4_PIN GPIO_PIN_12
//D5 - Data 5 pin
#define HD44780_D5_PORT GPIOC
#define HD44780_D5_PIN GPIO_PIN_13
//D6 - Data 6 pin
#define HD44780_D6_PORT GPIOB
#define HD44780_D6_PIN GPIO_PIN_12
//D7 - Data 7 pin
#define HD44780_D7_PORT GPIOB
#define HD44780_D7_PIN GPIO_PIN_13
@endverbatim
*
* \par Changelog
*
@verbatim
Version 1.2
- March 11, 2015
- Added support for my new GPIO library
Version 1.1
- November 08, 2014
- D6 and D7 default pins changed from PC14,15 to PB12,13, because RTC crystal is on PC14,15
Version 1.0
- First release
@endverbatim
*
* \par Dependencies
*
@verbatim
- STM32F4xx
- STM32F4xx RCC
- defines.h
@endverbatim
*/
#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_gpio.h"
#include "defines.h"
#include "tm_stm32f4_delay.h"
#include "tm_stm32f4_gpio.h"
/**
* @defgroup TM_HD44780_Macros
* @brief Library defines
* @{
*/
/* 4 bit mode */
/* Control pins, can be overwritten */
/* RS - Register select pin */
#ifndef HD44780_RS_PIN
#define HD44780_RS_PORT GPIOB
#define HD44780_RS_PIN GPIO_PIN_8
#endif
/* E - Enable pin */
#ifndef HD44780_E_PIN
#define HD44780_E_PORT GPIOE
#define HD44780_E_PIN GPIO_PIN_5
#endif
/* Data pins */
/* D4 - Data 4 pin */
#ifndef HD44780_D4_PIN
#define HD44780_D4_PORT GPIOE
#define HD44780_D4_PIN GPIO_PIN_4
#endif
/* D5 - Data 5 pin */
#ifndef HD44780_D5_PIN
#define HD44780_D5_PORT GPIOE
#define HD44780_D5_PIN GPIO_PIN_6
#endif
/* D6 - Data 6 pin */
#ifndef HD44780_D6_PIN
#define HD44780_D6_PORT GPIOE
#define HD44780_D6_PIN GPIO_PIN_2
#endif
/* D7 - Data 7 pin */
#ifndef HD44780_D7_PIN
#define HD44780_D7_PORT GPIOC
#define HD44780_D7_PIN GPIO_PIN_13
#endif
/**
* @}
*/
/**
* @defgroup TM_HD44780_Functions
* @brief Library Functions
* @{
*/
/**
* @brief Initializes HD44780 LCD
* @brief cols: width of lcd
* @param rows: height of lcd
* @retval None
*/
void TM_HD44780_Init(uint8_t cols, uint8_t rows);
/**
* @brief Turn display on
* @param None
* @retval None
*/
void TM_HD44780_DisplayOn(void);
/**
* @brief Turn display off
* @param None
* @retval None
*/
void TM_HD44780_DisplayOff(void);
/**
* @brief Clears entire LCD
* @param None
* @retval None
*/
void TM_HD44780_Clear(void);
/**
* @brief Puts string on lcd
* @param x location
* @param y location
* @param *str: pointer to string to display
* @retval None
*/
void TM_HD44780_Puts(uint8_t x, uint8_t y, char* str);
/**
* @brief Enables cursor blink
* @param None
* @retval None
*/
void TM_HD44780_BlinkOn(void);
/**
* @brief Disables cursor blink
* @param None
* @retval None
*/
void TM_HD44780_BlinkOff(void);
/**
* @brief Shows cursor
* @param None
* @retval None
*/
void TM_HD44780_CursorOn(void);
/**
* @brief Hides cursor
* @param None
* @retval None
*/
void TM_HD44780_CursorOff(void);
/**
* @brief Scrolls display to the left
* @param None
* @retval None
*/
void TM_HD44780_ScrollLeft(void);
/**
* @brief Scrolls display to the right
* @param None
* @retval None
*/
void TM_HD44780_ScrollRight(void);
/**
* @brief Creates custom character
* @param location: Location where to save character on LCD. LCD supports up to 8 custom characters, so locations are 0 - 7
* @param *data: Pointer to 8-bytes of data for one character
* @retval None
*/
void TM_HD44780_CreateChar(uint8_t location, uint8_t* data);
/**
* @brief Puts custom created character on LCD
* @param location: Location on LCD where character is stored, 0 - 7
* @retval None
*/
void TM_HD44780_PutCustom(uint8_t x, uint8_t y, uint8_t location);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif