libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
lcd.h
Go to the documentation of this file.
1/** @defgroup lcd_defines LCD Defines
2 *
3 * @ingroup STM32L1xx_defines
4 *
5 * @brief Defined Constants and Types for the STM32L1xx LCD Controller
6 *
7 * @version 1.0.0
8 *
9 * @author @htmlonly © @endhtmlonly 2014
10 * Nikolay Merinov <nikolay.merinov@member.fsf.org>
11 *
12 * @date 2 March 2014
13 *
14 * LGPL License Terms @ref lgpl_license
15 */
16
17/*
18 * This file is part of the libopencm3 project.
19 *
20 * This library is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public License
31 * along with this library. If not, see <http://www.gnu.org/licenses/>.
32 */
33
34/**@{*/
35#ifndef LIBOPENCM3_LCD_H
36#define LIBOPENCM3_LCD_H
37
40
41/** @defgroup lcd_registers LCD registers
42 * @{ */
43/** Control register */
44#define LCD_CR MMIO32(LCD_BASE + 0x00)
45/** Frame control register */
46#define LCD_FCR MMIO32(LCD_BASE + 0x04)
47/** Status register */
48#define LCD_SR MMIO32(LCD_BASE + 0x08)
49/** Clear register */
50#define LCD_CLR MMIO32(LCD_BASE + 0x0C)
51/**@}*/
52
53/* --- LCD display memory ------------------------------------------------- */
54/* Base address of display memory */
55#define LCD_RAM_BASE (LCD_BASE + 0x14)
56
57/* COM0 memory */
58#define LCD_RAM_COM0 MMIO64(LCD_RAM_BASE + 0x00)
59/* COM1 memory */
60#define LCD_RAM_COM1 MMIO64(LCD_RAM_BASE + 0x08)
61/* COM2 memory */
62#define LCD_RAM_COM2 MMIO64(LCD_RAM_BASE + 0x10)
63/* COM3 memory */
64#define LCD_RAM_COM3 MMIO64(LCD_RAM_BASE + 0x18)
65/* COM4 memory */
66#define LCD_RAM_COM4 MMIO64(LCD_RAM_BASE + 0x20)
67/* COM5 memory */
68#define LCD_RAM_COM5 MMIO64(LCD_RAM_BASE + 0x28)
69/* COM6 memory */
70#define LCD_RAM_COM6 MMIO64(LCD_RAM_BASE + 0x30)
71/* COM7 memory */
72#define LCD_RAM_COM7 MMIO64(LCD_RAM_BASE + 0x38)
73
74/* --- LCD_CR values ------------------------------------------------------ */
75#define LCD_CR_LCDEN (1 << 0)
76#define LCD_CR_VSEL (1 << 1)
77
78#define LCD_CR_DUTY_SHIFT 2
79#define LCD_CR_DUTY_MASK 0x7
80#define LCD_CR_DUTY_STATIC 0x0
81#define LCD_CR_DUTY_1_2 0x1
82#define LCD_CR_DUTY_1_3 0x2
83#define LCD_CR_DUTY_1_4 0x3
84#define LCD_CR_DUTY_1_8 0x4
85
86#define LCD_CR_BIAS_SHIFT 5
87#define LCD_CR_BIAS_MASK 0x3
88#define LCD_CR_BIAS_1_4 0x0
89#define LCD_CR_BIAS_1_2 0x1
90#define LCD_CR_BIAS_1_3 0x2
91
92#define LCD_CR_MUX_SEG (1 << 7)
93
94/* --- LCD_FCR values ------------------------------------------------------ */
95#define LCD_FCR_HD (1 << 0)
96#define LCD_FCR_SOFIE (1 << 1)
97#define LCD_FCR_UDDIE (1 << 3)
98
99#define LCD_FCR_PON_SHIFT 4
100#define LCD_FCR_PON_MASK 0x7
101#define LCD_FCR_PON_0 0x0
102#define LCD_FCR_PON_1 0x1
103#define LCD_FCR_PON_2 0x2
104#define LCD_FCR_PON_3 0x3
105#define LCD_FCR_PON_4 0x4
106#define LCD_FCR_PON_5 0x5
107#define LCD_FCR_PON_6 0x6
108#define LCD_FCR_PON_7 0x7
109
110#define LCD_FCR_DEAD_SHIFT 7
111#define LCD_FCR_DEAD_MASK 0x7
112#define LCD_FCR_DEAD_NONE 0x0
113#define LCD_FCR_DEAD_1_PHASE 0x1
114#define LCD_FCR_DEAD_2_PHASE 0x2
115#define LCD_FCR_DEAD_3_PHASE 0x3
116#define LCD_FCR_DEAD_4_PHASE 0x4
117#define LCD_FCR_DEAD_5_PHASE 0x5
118#define LCD_FCR_DEAD_6_PHASE 0x6
119#define LCD_FCR_DEAD_7_PHASE 0x7
120
121#define LCD_FCR_CC_SHIFT 10
122#define LCD_FCR_CC_MASK 0x7
123#define LCD_FCR_CC_0 0x0
124#define LCD_FCR_CC_1 0x1
125#define LCD_FCR_CC_2 0x2
126#define LCD_FCR_CC_3 0x3
127#define LCD_FCR_CC_4 0x4
128#define LCD_FCR_CC_5 0x5
129#define LCD_FCR_CC_6 0x6
130#define LCD_FCR_CC_7 0x7
131
132#define LCD_FCR_BLINKF_SHIFT 13
133#define LCD_FCR_BLINKF_MASK 0x7
134#define LCD_FCR_BLINKF_8 0x0
135#define LCD_FCR_BLINKF_16 0x1
136#define LCD_FCR_BLINKF_32 0x2
137#define LCD_FCR_BLINKF_64 0x3
138#define LCD_FCR_BLINKF_128 0x4
139#define LCD_FCR_BLINKF_256 0x5
140#define LCD_FCR_BLINKF_512 0x6
141#define LCD_FCR_BLINKF_1024 0x7
142
143#define LCD_FCR_BLINK_SHIFT 16
144#define LCD_FCR_BLINK_MASK 0x3
145#define LCD_FCR_BLINK_DISABLE 0x0
146#define LCD_FCR_BLINK_SEG0_COM0_ENABLE 0x1
147#define LCD_FCR_BLINK_SEG0_ENABLE 0x2
148#define LCD_FCR_BLINK_ALL_ENABLE 0x3
149
150#define LCD_FCR_DIV_SHIFT 18
151#define LCD_FCR_DIV_MASK 0xF
152#define LCD_FCR_DIV_16 0x0
153#define LCD_FCR_DIV_17 0x1
154#define LCD_FCR_DIV_18 0x2
155#define LCD_FCR_DIV_19 0x3
156#define LCD_FCR_DIV_20 0x4
157#define LCD_FCR_DIV_21 0x5
158#define LCD_FCR_DIV_22 0x6
159#define LCD_FCR_DIV_23 0x7
160#define LCD_FCR_DIV_24 0x8
161#define LCD_FCR_DIV_25 0x9
162#define LCD_FCR_DIV_26 0xA
163#define LCD_FCR_DIV_27 0xB
164#define LCD_FCR_DIV_28 0xC
165#define LCD_FCR_DIV_29 0xD
166#define LCD_FCR_DIV_30 0xE
167#define LCD_FCR_DIV_31 0xF
168
169#define LCD_FCR_PS_SHIFT 22
170#define LCD_FCR_PS_MASK 0xF
171#define LCD_FCR_PS_1 0x0
172#define LCD_FCR_PS_2 0x1
173#define LCD_FCR_PS_4 0x2
174#define LCD_FCR_PS_8 0x3
175#define LCD_FCR_PS_16 0x4
176#define LCD_FCR_PS_32 0x5
177#define LCD_FCR_PS_64 0x6
178#define LCD_FCR_PS_128 0x7
179#define LCD_FCR_PS_256 0x8
180#define LCD_FCR_PS_512 0x9
181#define LCD_FCR_PS_1024 0xA
182#define LCD_FCR_PS_2048 0xB
183#define LCD_FCR_PS_4096 0xC
184#define LCD_FCR_PS_8192 0xD
185#define LCD_FCR_PS_16384 0xE
186#define LCD_FCR_PS_32768 0xF
187
188/* --- LCD_SR values ------------------------------------------------------ */
189#define LCD_SR_ENS (1 << 0)
190#define LCD_SR_SOF (1 << 1)
191#define LCD_SR_UDR (1 << 2)
192#define LCD_SR_UDD (1 << 3)
193#define LCD_SR_RDY (1 << 4)
194#define LCD_SR_FCRSF (1 << 5)
195
196/* --- LCD_CLR values ----------------------------------------------------- */
197#define LCD_CLR_SOFC (1 << 1)
198#define LCD_CLR_UDDC (1 << 3)
199
200/* --- Function prototypes ------------------------------------------------- */
201
203
204void lcd_enable(void);
205void lcd_update(void);
206
207void lcd_wait_for_lcd_enabled(void);
210
211int lcd_is_enabled(void);
212int lcd_is_step_up_ready(void);
214
215void lcd_set_contrast(uint8_t contrast);
216void lcd_set_bias(uint8_t bias);
217void lcd_set_duty(uint8_t duty);
218void lcd_set_prescaler(uint8_t ps);
219void lcd_set_divider(uint8_t div);
222void lcd_set_refresh_frequency(uint32_t frequency);
223
225
226#endif
227/**@}*/
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void lcd_disable_segment_multiplexing(void)
Definition: lcd.c:98
int lcd_is_enabled(void)
Definition: lcd.c:48
void lcd_set_prescaler(uint8_t ps)
Definition: lcd.c:81
void lcd_set_divider(uint8_t div)
Definition: lcd.c:87
void lcd_enable_segment_multiplexing(void)
Definition: lcd.c:93
int lcd_is_step_up_ready(void)
Definition: lcd.c:53
void lcd_set_duty(uint8_t duty)
Definition: lcd.c:75
void lcd_set_refresh_frequency(uint32_t frequency)
Definition: lcd.c:103
void lcd_wait_for_lcd_enabled(void)
Definition: lcd.c:33
void lcd_set_bias(uint8_t bias)
Definition: lcd.c:69
void lcd_enable(void)
Definition: lcd.c:23
int lcd_is_for_update_ready(void)
Definition: lcd.c:58
void lcd_update(void)
Definition: lcd.c:28
void lcd_wait_for_step_up_ready(void)
Definition: lcd.c:38
void lcd_wait_for_update_ready(void)
Definition: lcd.c:43
void lcd_set_contrast(uint8_t contrast)
Definition: lcd.c:63