blob: 0a4b02b73d49c532b6085bf6e6cf5320ac296b8f (
plain)
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
|
/** @defgroup lcd_defines LCD Defines
*
* @ingroup STM32L1xx_defines
*
* @brief Defined Constants and Types for the STM32L1xx LCD Controller
*
* @version 1.0.0
*
* @author @htmlonly © @endhtmlonly 2014
* Nikolay Merinov <nikolay.merinov@member.fsf.org>
*
* @date 2 March 2014
*
* LGPL License Terms @ref lgpl_license
* */
/*
* This file is part of the libopencm3 project.
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**@{*/
#ifndef LIBOPENCM3_LCD_H
#define LIBOPENCM3_LCD_H
#include <libopencm3/stm32/memorymap.h>
#include <libopencm3/cm3/common.h>
/* --- LCD registers ------------------------------------------------------ */
/****************************************************************************/
/** @defgroup lcd_reg_base LCD register base addresses
@ingroup lcd_defines
*/
/* @{ */
/* Control register */
#define LCD_CR MMIO32(LCD_BASE + 0x00)
/* Frame control register */
#define LCD_FCR MMIO32(LCD_BASE + 0x04)
/* Status register */
#define LCD_SR MMIO32(LCD_BASE + 0x08)
/* Clear register */
#define LCD_CLR MMIO32(LCD_BASE + 0x0C)
/* @} */
/* --- LCD display memory ------------------------------------------------- */
/* Base address of display memory */
#define LCD_RAM_BASE (LCD_BASE + 0x14)
/* COM0 memory */
#define LCD_RAM_COM0 MMIO64(LCD_RAM_BASE + 0x00)
/* COM1 memory */
#define LCD_RAM_COM1 MMIO64(LCD_RAM_BASE + 0x08)
/* COM2 memory */
#define LCD_RAM_COM2 MMIO64(LCD_RAM_BASE + 0x10)
/* COM3 memory */
#define LCD_RAM_COM3 MMIO64(LCD_RAM_BASE + 0x18)
/* COM4 memory */
#define LCD_RAM_COM4 MMIO64(LCD_RAM_BASE + 0x20)
/* COM5 memory */
#define LCD_RAM_COM5 MMIO64(LCD_RAM_BASE + 0x28)
/* COM6 memory */
#define LCD_RAM_COM6 MMIO64(LCD_RAM_BASE + 0x30)
/* COM7 memory */
#define LCD_RAM_COM7 MMIO64(LCD_RAM_BASE + 0x38)
/* --- LCD_CR values ------------------------------------------------------ */
#define LCD_CR_LCDEN (1 << 0)
#define LCD_CR_VSEL (1 << 1)
#define LCD_CR_DUTY_SHIFT 2
#define LCD_CR_DUTY_MASK 0x7
#define LCD_CR_DUTY_STATIC 0x0
#define LCD_CR_DUTY_1_2 0x1
#define LCD_CR_DUTY_1_3 0x2
#define LCD_CR_DUTY_1_4 0x3
#define LCD_CR_DUTY_1_8 0x4
#define LCD_CR_BIAS_SHIFT 5
#define LCD_CR_BIAS_MASK 0x3
#define LCD_CR_BIAS_1_4 0x0
#define LCD_CR_BIAS_1_2 0x1
#define LCD_CR_BIAS_1_3 0x2
#define LCD_CR_MUX_SEG (1 << 7)
/* --- LCD_FCR values ------------------------------------------------------ */
#define LCD_FCR_HD (1 << 0)
#define LCD_FCR_SOFIE (1 << 1)
#define LCD_FCR_UDDIE (1 << 3)
#define LCD_FCR_PON_SHIFT 4
#define LCD_FCR_PON_MASK 0x7
#define LCD_FCR_PON_0 0x0
#define LCD_FCR_PON_1 0x1
#define LCD_FCR_PON_2 0x2
#define LCD_FCR_PON_3 0x3
#define LCD_FCR_PON_4 0x4
#define LCD_FCR_PON_5 0x5
#define LCD_FCR_PON_6 0x6
#define LCD_FCR_PON_7 0x7
#define LCD_FCR_DEAD_SHIFT 7
#define LCD_FCR_DEAD_MASK 0x7
#define LCD_FCR_DEAD_NONE 0x0
#define LCD_FCR_DEAD_1_PHASE 0x1
#define LCD_FCR_DEAD_2_PHASE 0x2
#define LCD_FCR_DEAD_3_PHASE 0x3
#define LCD_FCR_DEAD_4_PHASE 0x4
#define LCD_FCR_DEAD_5_PHASE 0x5
#define LCD_FCR_DEAD_6_PHASE 0x6
#define LCD_FCR_DEAD_7_PHASE 0x7
#define LCD_FCR_CC_SHIFT 10
#define LCD_FCR_CC_MASK 0x7
#define LCD_FCR_CC_0 0x0
#define LCD_FCR_CC_1 0x1
#define LCD_FCR_CC_2 0x2
#define LCD_FCR_CC_3 0x3
#define LCD_FCR_CC_4 0x4
#define LCD_FCR_CC_5 0x5
#define LCD_FCR_CC_6 0x6
#define LCD_FCR_CC_7 0x7
#define LCD_FCR_BLINKF_SHIFT 13
#define LCD_FCR_BLINKF_MASK 0x7
#define LCD_FCR_BLINKF_8 0x0
#define LCD_FCR_BLINKF_16 0x1
#define LCD_FCR_BLINKF_32 0x2
#define LCD_FCR_BLINKF_64 0x3
#define LCD_FCR_BLINKF_128 0x4
#define LCD_FCR_BLINKF_256 0x5
#define LCD_FCR_BLINKF_512 0x6
#define LCD_FCR_BLINKF_1024 0x7
#define LCD_FCR_BLINK_SHIFT 16
#define LCD_FCR_BLINK_MASK 0x3
#define LCD_FCR_BLINK_DISABLE 0x0
#define LCD_FCR_BLINK_SEG0_COM0_ENABLE 0x1
#define LCD_FCR_BLINK_SEG0_ENABLE 0x2
#define LCD_FCR_BLINK_ALL_ENABLE 0x3
#define LCD_FCR_DIV_SHIFT 18
#define LCD_FCR_DIV_MASK 0xF
#define LCD_FCR_DIV_16 0x0
#define LCD_FCR_DIV_17 0x1
#define LCD_FCR_DIV_18 0x2
#define LCD_FCR_DIV_19 0x3
#define LCD_FCR_DIV_20 0x4
#define LCD_FCR_DIV_21 0x5
#define LCD_FCR_DIV_22 0x6
#define LCD_FCR_DIV_23 0x7
#define LCD_FCR_DIV_24 0x8
#define LCD_FCR_DIV_25 0x9
#define LCD_FCR_DIV_26 0xA
#define LCD_FCR_DIV_27 0xB
#define LCD_FCR_DIV_28 0xC
#define LCD_FCR_DIV_29 0xD
#define LCD_FCR_DIV_30 0xE
#define LCD_FCR_DIV_31 0xF
#define LCD_FCR_PS_SHIFT 22
#define LCD_FCR_PS_MASK 0xF
#define LCD_FCR_PS_1 0x0
#define LCD_FCR_PS_2 0x1
#define LCD_FCR_PS_4 0x2
#define LCD_FCR_PS_8 0x3
#define LCD_FCR_PS_16 0x4
#define LCD_FCR_PS_32 0x5
#define LCD_FCR_PS_64 0x6
#define LCD_FCR_PS_128 0x7
#define LCD_FCR_PS_256 0x8
#define LCD_FCR_PS_512 0x9
#define LCD_FCR_PS_1024 0xA
#define LCD_FCR_PS_2048 0xB
#define LCD_FCR_PS_4096 0xC
#define LCD_FCR_PS_8192 0xD
#define LCD_FCR_PS_16384 0xE
#define LCD_FCR_PS_32768 0xF
/* --- LCD_SR values ------------------------------------------------------ */
#define LCD_SR_ENS (1 << 0)
#define LCD_SR_SOF (1 << 1)
#define LCD_SR_UDR (1 << 2)
#define LCD_SR_UDD (1 << 3)
#define LCD_SR_RDY (1 << 4)
#define LCD_SR_FCRSF (1 << 5)
/* --- LCD_CLR values ----------------------------------------------------- */
#define LCD_CLR_SOFC (1 << 1)
#define LCD_CLR_UDDC (1 << 3)
/* --- Function prototypes ------------------------------------------------- */
BEGIN_DECLS
void lcd_enable(void);
void lcd_update(void);
void lcd_wait_for_lcd_enabled(void);
void lcd_wait_for_step_up_ready(void);
void lcd_wait_for_update_ready(void);
int lcd_is_enabled(void);
int lcd_is_step_up_ready(void);
int lcd_is_for_update_ready(void);
void lcd_set_contrast(uint8_t contrast);
void lcd_set_bias(uint8_t bias);
void lcd_set_duty(uint8_t duty);
void lcd_set_prescaler(uint8_t ps);
void lcd_set_divider(uint8_t div);
void lcd_enable_segment_multiplexing(void);
void lcd_disable_segment_multiplexing(void);
void lcd_set_refresh_frequency(uint32_t frequency);
END_DECLS
#endif
/**@}*/
|