OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_STM32F103_IAR/] [STM32F10xFWLib/] [src/] [lcd.c] - Blame information for rev 582

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 582 jeremybenn
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
2
* File Name          : lcd.c
3
* Author             : MCD Application Team
4
* Date First Issued  : mm/dd/yyyy
5
* Description        : This file includes the LCD driver for AM-240320LTNQW00H
6
*                      liquid Crystal Display Module of STM32F10x-EVAL.
7
********************************************************************************
8
* History:
9
* mm/dd/yyyy
10
********************************************************************************
11
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
13
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
14
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
15
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
16
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17
*******************************************************************************/
18
 
19
/* Includes ------------------------------------------------------------------*/
20
#include "stm32f10x_type.h"
21
#include "lcd.h"
22
#include "spi_flash.h"
23
 
24
#include "FreeRTOS.h"
25
#include "task.h"
26
 
27
/* Private typedef -----------------------------------------------------------*/
28
/* Private define ------------------------------------------------------------*/
29
     /* ASCII Table: each character is 16 column (16dots large)
30
        and 24 raw (24 dots high) */
31
     const uc16 ASCII_Table[] =
32
       {
33
         /* Space ' ' */
34
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
35
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
36
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
37
         /* '!' */
38
         0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
39
         0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000, 0x0000,
40
         0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
41
         /* '"' */
42
         0x0000, 0x0000, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC,
43
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
44
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
45
         /* '#' */
46
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C60, 0x0C60,
47
         0x0C60, 0x0630, 0x0630, 0x1FFE, 0x1FFE, 0x0630, 0x0738, 0x0318,
48
         0x1FFE, 0x1FFE, 0x0318, 0x0318, 0x018C, 0x018C, 0x018C, 0x0000,
49
         /* '$' */
50
         0x0000, 0x0080, 0x03E0, 0x0FF8, 0x0E9C, 0x1C8C, 0x188C, 0x008C,
51
         0x0098, 0x01F8, 0x07E0, 0x0E80, 0x1C80, 0x188C, 0x188C, 0x189C,
52
         0x0CB8, 0x0FF0, 0x03E0, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000,
53
         /* '%' */
54
         0x0000, 0x0000, 0x0000, 0x180E, 0x0C1B, 0x0C11, 0x0611, 0x0611,
55
         0x0311, 0x0311, 0x019B, 0x018E, 0x38C0, 0x6CC0, 0x4460, 0x4460,
56
         0x4430, 0x4430, 0x4418, 0x6C18, 0x380C, 0x0000, 0x0000, 0x0000,
57
         /* '&' */
58
         0x0000, 0x01E0, 0x03F0, 0x0738, 0x0618, 0x0618, 0x0330, 0x01F0,
59
         0x00F0, 0x00F8, 0x319C, 0x330E, 0x1E06, 0x1C06, 0x1C06, 0x3F06,
60
         0x73FC, 0x21F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
61
         /* ''' */
62
         0x0000, 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
63
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
64
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
65
         /* '(' */
66
         0x0000, 0x0200, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x0060, 0x0060,
67
         0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
68
         0x0060, 0x0060, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0200, 0x0000,
69
         /* ')' */
70
         0x0000, 0x0020, 0x0060, 0x00C0, 0x0180, 0x0180, 0x0300, 0x0300,
71
         0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600,
72
         0x0300, 0x0300, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0020, 0x0000,
73
         /* '*' */
74
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0,
75
         0x06D8, 0x07F8, 0x01E0, 0x0330, 0x0738, 0x0000, 0x0000, 0x0000,
76
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
77
         /* '+' */
78
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180,
79
         0x0180, 0x0180, 0x0180, 0x3FFC, 0x3FFC, 0x0180, 0x0180, 0x0180,
80
         0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
81
         /* ',' */
82
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
83
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
84
         0x0000, 0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000,
85
         /* '-' */
86
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
87
         0x0000, 0x0000, 0x0000, 0x0000, 0x07E0, 0x07E0, 0x0000, 0x0000,
88
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
89
         /* '.' */
90
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
91
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
92
         0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
93
         /* '/' */
94
         0x0000, 0x0C00, 0x0C00, 0x0600, 0x0600, 0x0600, 0x0300, 0x0300,
95
         0x0300, 0x0380, 0x0180, 0x0180, 0x0180, 0x00C0, 0x00C0, 0x00C0,
96
         0x0060, 0x0060, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
97
         /* '0' */
98
         0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x180C, 0x180C, 0x180C,
99
         0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C18, 0x0E38,
100
         0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
101
         /* '1' */
102
         0x0000, 0x0100, 0x0180, 0x01C0, 0x01F0, 0x0198, 0x0188, 0x0180,
103
         0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
104
         0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
105
         /* '2' */
106
         0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x1800,
107
         0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018,
108
         0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
109
         /* '3' */
110
         0x0000, 0x01E0, 0x07F8, 0x0E18, 0x0C0C, 0x0C0C, 0x0C00, 0x0600,
111
         0x03C0, 0x07C0, 0x0C00, 0x1800, 0x1800, 0x180C, 0x180C, 0x0C18,
112
         0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
113
         /* '4' */
114
         0x0000, 0x0C00, 0x0E00, 0x0F00, 0x0F00, 0x0D80, 0x0CC0, 0x0C60,
115
         0x0C60, 0x0C30, 0x0C18, 0x0C0C, 0x3FFC, 0x3FFC, 0x0C00, 0x0C00,
116
         0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
117
         /* '5' */
118
         0x0000, 0x0FF8, 0x0FF8, 0x0018, 0x0018, 0x000C, 0x03EC, 0x07FC,
119
         0x0E1C, 0x1C00, 0x1800, 0x1800, 0x1800, 0x180C, 0x0C1C, 0x0E18,
120
         0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
121
         /* '6' */
122
         0x0000, 0x07C0, 0x0FF0, 0x1C38, 0x1818, 0x0018, 0x000C, 0x03CC,
123
         0x0FEC, 0x0E3C, 0x1C1C, 0x180C, 0x180C, 0x180C, 0x1C18, 0x0E38,
124
         0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
125
         /* '7' */
126
         0x0000, 0x1FFC, 0x1FFC, 0x0C00, 0x0600, 0x0600, 0x0300, 0x0380,
127
         0x0180, 0x01C0, 0x00C0, 0x00E0, 0x0060, 0x0060, 0x0070, 0x0030,
128
         0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
129
         /* '8' */
130
         0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x0C18, 0x0C18, 0x0638,
131
         0x07F0, 0x07F0, 0x0C18, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C38,
132
         0x0FF8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
133
         /* '9' */
134
         0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C1C, 0x180C, 0x180C, 0x180C,
135
         0x1C1C, 0x1E38, 0x1BF8, 0x19E0, 0x1800, 0x0C00, 0x0C00, 0x0E1C,
136
         0x07F8, 0x01F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
137
         /* ':' */
138
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180,
139
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
140
         0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
141
         /* ';' */
142
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180,
143
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
144
         0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000,
145
         /* '<' */
146
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
147
         0x1000, 0x1C00, 0x0F80, 0x03E0, 0x00F8, 0x0018, 0x00F8, 0x03E0,
148
         0x0F80, 0x1C00, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
149
         /* '=' */
150
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
151
         0x1FF8, 0x0000, 0x0000, 0x0000, 0x1FF8, 0x0000, 0x0000, 0x0000,
152
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
153
         /* '>' */
154
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
155
         0x0008, 0x0038, 0x01F0, 0x07C0, 0x1F00, 0x1800, 0x1F00, 0x07C0,
156
         0x01F0, 0x0038, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
157
         /* '?' */
158
         0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x0C00,
159
         0x0600, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x0000, 0x0000,
160
         0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
161
         /* '@' */
162
         0x0000, 0x0000, 0x07E0, 0x1818, 0x2004, 0x29C2, 0x4A22, 0x4411,
163
         0x4409, 0x4409, 0x4409, 0x2209, 0x1311, 0x0CE2, 0x4002, 0x2004,
164
         0x1818, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
165
         /* 'A' */
166
         0x0000, 0x0380, 0x0380, 0x06C0, 0x06C0, 0x06C0, 0x0C60, 0x0C60,
167
         0x1830, 0x1830, 0x1830, 0x3FF8, 0x3FF8, 0x701C, 0x600C, 0x600C,
168
         0xC006, 0xC006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
169
         /* 'B' */
170
         0x0000, 0x03FC, 0x0FFC, 0x0C0C, 0x180C, 0x180C, 0x180C, 0x0C0C,
171
         0x07FC, 0x0FFC, 0x180C, 0x300C, 0x300C, 0x300C, 0x300C, 0x180C,
172
         0x1FFC, 0x07FC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
173
         /* 'C' */
174
         0x0000, 0x07C0, 0x1FF0, 0x3838, 0x301C, 0x700C, 0x6006, 0x0006,
175
         0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x6006, 0x700C, 0x301C,
176
         0x1FF0, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
177
         /* 'D' */
178
         0x0000, 0x03FE, 0x0FFE, 0x0E06, 0x1806, 0x1806, 0x3006, 0x3006,
179
         0x3006, 0x3006, 0x3006, 0x3006, 0x3006, 0x1806, 0x1806, 0x0E06,
180
         0x0FFE, 0x03FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
181
         /* 'E' */
182
         0x0000, 0x3FFC, 0x3FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
183
         0x1FFC, 0x1FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
184
         0x3FFC, 0x3FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
185
         /* 'F' */
186
         0x0000, 0x3FF8, 0x3FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
187
         0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
188
         0x0018, 0x0018, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
189
         /* 'G' */
190
         0x0000, 0x0FE0, 0x3FF8, 0x783C, 0x600E, 0xE006, 0xC007, 0x0003,
191
         0x0003, 0xFE03, 0xFE03, 0xC003, 0xC007, 0xC006, 0xC00E, 0xF03C,
192
         0x3FF8, 0x0FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
193
         /* 'H' */
194
         0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C,
195
         0x3FFC, 0x3FFC, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C,
196
         0x300C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
197
         /* 'I' */
198
         0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
199
         0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
200
         0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
201
         /* 'J' */
202
         0x0000, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600,
203
         0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0618, 0x0618, 0x0738,
204
         0x03F0, 0x01E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
205
         /* 'K' */
206
         0x0000, 0x3006, 0x1806, 0x0C06, 0x0606, 0x0306, 0x0186, 0x00C6,
207
         0x0066, 0x0076, 0x00DE, 0x018E, 0x0306, 0x0606, 0x0C06, 0x1806,
208
         0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
209
         /* 'L' */
210
         0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
211
         0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
212
         0x1FF8, 0x1FF8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
213
         /* 'M' */
214
         0x0000, 0xE00E, 0xF01E, 0xF01E, 0xF01E, 0xD836, 0xD836, 0xD836,
215
         0xD836, 0xCC66, 0xCC66, 0xCC66, 0xC6C6, 0xC6C6, 0xC6C6, 0xC6C6,
216
         0xC386, 0xC386, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
217
         /* 'N' */
218
         0x0000, 0x300C, 0x301C, 0x303C, 0x303C, 0x306C, 0x306C, 0x30CC,
219
         0x30CC, 0x318C, 0x330C, 0x330C, 0x360C, 0x360C, 0x3C0C, 0x3C0C,
220
         0x380C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
221
         /* 'O' */
222
         0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xC003, 0xC003,
223
         0xC003, 0xC003, 0xC003, 0xC003, 0xC003, 0x6006, 0x700E, 0x381C,
224
         0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
225
         /* 'P' */
226
         0x0000, 0x0FFC, 0x1FFC, 0x380C, 0x300C, 0x300C, 0x300C, 0x300C,
227
         0x180C, 0x1FFC, 0x07FC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C,
228
         0x000C, 0x000C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
229
         /* 'Q' */
230
         0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xE003, 0xC003,
231
         0xC003, 0xC003, 0xC003, 0xC003, 0xE007, 0x6306, 0x3F0E, 0x3C1C,
232
         0x3FF8, 0xF7E0, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
233
         /* 'R' */
234
         0x0000, 0x0FFE, 0x1FFE, 0x3806, 0x3006, 0x3006, 0x3006, 0x3806,
235
         0x1FFE, 0x07FE, 0x0306, 0x0606, 0x0C06, 0x1806, 0x1806, 0x3006,
236
         0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
237
         /* 'S' */
238
         0x0000, 0x03E0, 0x0FF8, 0x0C1C, 0x180C, 0x180C, 0x000C, 0x001C,
239
         0x03F8, 0x0FE0, 0x1E00, 0x3800, 0x3006, 0x3006, 0x300E, 0x1C1C,
240
         0x0FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
241
         /* 'T' */
242
         0x0000, 0x7FFE, 0x7FFE, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
243
         0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
244
         0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
245
         /* 'U' */
246
         0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C,
247
         0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x1818,
248
         0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
249
         /* 'V' */
250
         0x0000, 0x6003, 0x3006, 0x3006, 0x3006, 0x180C, 0x180C, 0x180C,
251
         0x0C18, 0x0C18, 0x0E38, 0x0630, 0x0630, 0x0770, 0x0360, 0x0360,
252
         0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
253
         /* 'W' */
254
         0x0000, 0x6003, 0x61C3, 0x61C3, 0x61C3, 0x3366, 0x3366, 0x3366,
255
         0x3366, 0x3366, 0x3366, 0x1B6C, 0x1B6C, 0x1B6C, 0x1A2C, 0x1E3C,
256
         0x0E38, 0x0E38, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
257
         /* 'X' */
258
         0x0000, 0xE00F, 0x700C, 0x3018, 0x1830, 0x0C70, 0x0E60, 0x07C0,
259
         0x0380, 0x0380, 0x03C0, 0x06E0, 0x0C70, 0x1C30, 0x1818, 0x300C,
260
         0x600E, 0xE007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
261
         /* 'Y' */
262
         0x0000, 0xC003, 0x6006, 0x300C, 0x381C, 0x1838, 0x0C30, 0x0660,
263
         0x07E0, 0x03C0, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
264
         0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
265
         /* 'Z' */
266
         0x0000, 0x7FFC, 0x7FFC, 0x6000, 0x3000, 0x1800, 0x0C00, 0x0600,
267
         0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, 0x000C, 0x0006,
268
         0x7FFE, 0x7FFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
269
         /* '[' */
270
         0x0000, 0x03E0, 0x03E0, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060,
271
         0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060,
272
         0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x03E0, 0x03E0, 0x0000,
273
         /* '\' */
274
         0x0000, 0x0030, 0x0030, 0x0060, 0x0060, 0x0060, 0x00C0, 0x00C0,
275
         0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0300, 0x0300, 0x0300,
276
         0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
277
         /* ']' */
278
         0x0000, 0x03E0, 0x03E0, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300,
279
         0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300,
280
         0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x03E0, 0x03E0, 0x0000,
281
         /* '^' */
282
         0x0000, 0x0000, 0x01C0, 0x01C0, 0x0360, 0x0360, 0x0360, 0x0630,
283
         0x0630, 0x0C18, 0x0C18, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
284
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
285
         /* '_' */
286
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
287
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
288
         0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
289
         /* ''' */
290
         0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0000,
291
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
292
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
293
         /* 'a' */
294
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03F0, 0x07F8,
295
         0x0C1C, 0x0C0C, 0x0F00, 0x0FF0, 0x0CF8, 0x0C0C, 0x0C0C, 0x0F1C,
296
         0x0FF8, 0x18F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
297
         /* 'b' */
298
         0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x03D8, 0x0FF8,
299
         0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38,
300
         0x0FF8, 0x03D8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
301
         /* 'c' */
302
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x07F0,
303
         0x0E30, 0x0C18, 0x0018, 0x0018, 0x0018, 0x0018, 0x0C18, 0x0E30,
304
         0x07F0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
305
         /* 'd' */
306
         0x0000, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1BC0, 0x1FF0,
307
         0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30,
308
         0x1FF0, 0x1BC0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
309
         /* 'e' */
310
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0,
311
         0x0C30, 0x1818, 0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x1838, 0x1C30,
312
         0x0FF0, 0x07C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
313
         /* 'f' */
314
         0x0000, 0x0F80, 0x0FC0, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0,
315
         0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
316
         0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
317
         /* 'g' */
318
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0DE0, 0x0FF8,
319
         0x0E18, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0E18,
320
         0x0FF8, 0x0DE0, 0x0C00, 0x0C0C, 0x061C, 0x07F8, 0x01F0, 0x0000,
321
         /* 'h' */
322
         0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x07D8, 0x0FF8,
323
         0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818,
324
         0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
325
         /* 'i' */
326
         0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0,
327
         0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
328
         0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
329
         /* 'j' */
330
         0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0,
331
         0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
332
         0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00F8, 0x0078, 0x0000,
333
         /* 'k' */
334
         0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0C0C, 0x060C,
335
         0x030C, 0x018C, 0x00CC, 0x006C, 0x00FC, 0x019C, 0x038C, 0x030C,
336
         0x060C, 0x0C0C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
337
         /* 'l' */
338
         0x0000, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
339
         0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
340
         0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
341
         /* 'm' */
342
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3C7C, 0x7EFF,
343
         0xE3C7, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183,
344
         0xC183, 0xC183, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
345
         /* 'n' */
346
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0798, 0x0FF8,
347
         0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818,
348
         0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
349
         /* 'o' */
350
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0,
351
         0x0C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C30,
352
         0x0FF0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
353
         /* 'p' */
354
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03D8, 0x0FF8,
355
         0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38,
356
         0x0FF8, 0x03D8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0000,
357
         /* 'q' */
358
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1BC0, 0x1FF0,
359
         0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30,
360
         0x1FF0, 0x1BC0, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x0000,
361
         /* 'r' */
362
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07B0, 0x03F0,
363
         0x0070, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
364
         0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
365
         /* 's' */
366
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, 0x03F0,
367
         0x0E38, 0x0C18, 0x0038, 0x03F0, 0x07C0, 0x0C00, 0x0C18, 0x0E38,
368
         0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
369
         /* 't' */
370
         0x0000, 0x0000, 0x0080, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0,
371
         0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
372
         0x07C0, 0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
373
         /* 'u' */
374
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1818, 0x1818,
375
         0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C38,
376
         0x1FF0, 0x19E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
377
         /* 'v' */
378
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x180C, 0x0C18,
379
         0x0C18, 0x0C18, 0x0630, 0x0630, 0x0630, 0x0360, 0x0360, 0x0360,
380
         0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
381
         /* 'w' */
382
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x41C1, 0x41C1,
383
         0x61C3, 0x6363, 0x6363, 0x6363, 0x3636, 0x3636, 0x3636, 0x1C1C,
384
         0x1C1C, 0x1C1C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
385
         /* 'x' */
386
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x381C, 0x1C38,
387
         0x0C30, 0x0660, 0x0360, 0x0360, 0x0360, 0x0360, 0x0660, 0x0C30,
388
         0x1C38, 0x381C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
389
         /* 'y' */
390
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3018, 0x1830,
391
         0x1830, 0x1870, 0x0C60, 0x0C60, 0x0CE0, 0x06C0, 0x06C0, 0x0380,
392
         0x0380, 0x0380, 0x0180, 0x0180, 0x01C0, 0x00F0, 0x0070, 0x0000,
393
         /* 'z' */
394
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1FFC, 0x1FFC,
395
         0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018,
396
         0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
397
         /* '{' */
398
         0x0000, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0,
399
         0x00C0, 0x0060, 0x0060, 0x0030, 0x0060, 0x0040, 0x00C0, 0x00C0,
400
         0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0000, 0x0000,
401
         /* '|' */
402
         0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
403
         0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180,
404
         0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000,
405
         /* '}' */
406
         0x0000, 0x0060, 0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0180,
407
         0x0180, 0x0300, 0x0300, 0x0600, 0x0300, 0x0100, 0x0180, 0x0180,
408
         0x0180, 0x0180, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0000, 0x0000,
409
         /* '~' */
410
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
411
         0x10F0, 0x1FF8, 0x0F08, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
412
         0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
413
      };
414
/* Private macro -------------------------------------------------------------*/
415
/* Private variables ---------------------------------------------------------*/
416
  /* Global variables to set the written text color */
417
static  vu16 TextColor = 0x0000, BackColor = 0xFFFF;
418
 
419
/* Private function prototypes -----------------------------------------------*/
420
/* Private functions ---------------------------------------------------------*/
421
static u32 StrLength(u8 *Str);
422
 
423
/*******************************************************************************
424
* Function Name  : LCD_Init
425
* Description    : Initializes LCD.
426
* Input          : None
427
* Output         : None
428
* Return         : None
429
*******************************************************************************/
430
void LCD_Init(void)
431
{
432
/* Configure the LCD Control pins --------------------------------------------*/
433
  LCD_CtrlLinesConfig();
434
 
435
/* Configure the SPI2 interface ----------------------------------------------*/
436
  LCD_SPIConfig();
437
 
438
/* Enable the LCD Oscillator -------------------------------------------------*/
439
  LCD_WriteReg(R1, 0x10);
440
  LCD_WriteReg(R0, 0xA0);
441
  LCD_WriteReg(R3, 0x01);
442
  vTaskDelay( 10 / portTICK_RATE_MS ); /* Delay 10 ms */
443
  LCD_WriteReg(R3, 0x00);
444
  LCD_WriteReg(R43, 0x04);
445
 
446
  LCD_WriteReg(R40, 0x18);
447
  LCD_WriteReg(R26, 0x05);
448
  LCD_WriteReg(R37, 0x05);
449
  LCD_WriteReg(R25, 0x00);
450
 
451
/* LCD Power On --------------------------------------------------------------*/
452
  LCD_WriteReg(R28, 0x73);
453
  LCD_WriteReg(R36, 0x74);
454
  LCD_WriteReg(R30, 0x01);
455
  LCD_WriteReg(R24, 0xC1);
456
  vTaskDelay( 10 / portTICK_RATE_MS ); /* Delay 10 ms */
457
  LCD_WriteReg(R24, 0xE1);
458
  LCD_WriteReg(R24, 0xF1);
459
  vTaskDelay( 60 / portTICK_RATE_MS ); /* Delay 60 ms */
460
  LCD_WriteReg(R24, 0xF5);
461
  vTaskDelay( 60 / portTICK_RATE_MS ); /* Delay 60 ms */
462
  LCD_WriteReg(R27, 0x09);
463
  vTaskDelay( 10 / portTICK_RATE_MS ); /* Delay 10 ms */
464
  LCD_WriteReg(R31, 0x11);
465
  LCD_WriteReg(R32, 0x0E);
466
  LCD_WriteReg(R30, 0x81);
467
  vTaskDelay( 10 / portTICK_RATE_MS ); /* Delay 10 ms */
468
 
469
/* Chip Set ------------------------------------------------------------------*/
470
  LCD_WriteReg(R157, 0x00);
471
  LCD_WriteReg(R192, 0x00);
472
 
473
  LCD_WriteReg(R14, 0x00);
474
  LCD_WriteReg(R15, 0x00);
475
  LCD_WriteReg(R16, 0x00);
476
  LCD_WriteReg(R17, 0x00);
477
  LCD_WriteReg(R18, 0x00);
478
  LCD_WriteReg(R19, 0x00);
479
  LCD_WriteReg(R20, 0x00);
480
  LCD_WriteReg(R21, 0x00);
481
  LCD_WriteReg(R22, 0x00);
482
  LCD_WriteReg(R23, 0x00);
483
 
484
  LCD_WriteReg(R52, 0x01);
485
  LCD_WriteReg(R53, 0x00);
486
 
487
  LCD_WriteReg(R75, 0x00);
488
  LCD_WriteReg(R76, 0x00);
489
  LCD_WriteReg(R78, 0x00);
490
  LCD_WriteReg(R79, 0x00);
491
  LCD_WriteReg(R80, 0x00);
492
 
493
  LCD_WriteReg(R60, 0x00);
494
  LCD_WriteReg(R61, 0x00);
495
  LCD_WriteReg(R62, 0x01);
496
  LCD_WriteReg(R63, 0x3F);
497
  LCD_WriteReg(R64, 0x02);
498
  LCD_WriteReg(R65, 0x02);
499
  LCD_WriteReg(R66, 0x00);
500
  LCD_WriteReg(R67, 0x00);
501
  LCD_WriteReg(R68, 0x00);
502
  LCD_WriteReg(R69, 0x00);
503
  LCD_WriteReg(R70, 0xEF);
504
  LCD_WriteReg(R71, 0x00);
505
  LCD_WriteReg(R72, 0x00);
506
  LCD_WriteReg(R73, 0x01);
507
  LCD_WriteReg(R74, 0x3F);
508
 
509
  LCD_WriteReg(R29, 0x08);  /* R29:Gate scan direction setting */
510
 
511
  LCD_WriteReg(R134, 0x00);
512
  LCD_WriteReg(R135, 0x30);
513
  LCD_WriteReg(R136, 0x02);
514
  LCD_WriteReg(R137, 0x05);
515
 
516
  LCD_WriteReg(R141, 0x01);  /* R141:Register set-up mode for one line clock */
517
  LCD_WriteReg(R139, 0x20);  /* R139:One line SYSCLK number in one-line */
518
  LCD_WriteReg(R51, 0x01);  /* R51:N line inversion setting */
519
  LCD_WriteReg(R55, 0x01);  /* R55:Scanning method setting */
520
  LCD_WriteReg(R118, 0x00);
521
 
522
/* Gamma Set -----------------------------------------------------------------*/
523
  LCD_WriteReg(R143, 0x10);
524
  LCD_WriteReg(R144, 0x67);
525
  LCD_WriteReg(R145, 0x07);
526
  LCD_WriteReg(R146, 0x65);
527
  LCD_WriteReg(R147, 0x07);
528
  LCD_WriteReg(R148, 0x01);
529
  LCD_WriteReg(R149, 0x76);
530
  LCD_WriteReg(R150, 0x56);
531
  LCD_WriteReg(R151, 0x00);
532
  LCD_WriteReg(R152, 0x06);
533
  LCD_WriteReg(R153, 0x03);
534
  LCD_WriteReg(R154, 0x00);
535
 
536
/* Display On ----------------------------------------------------------------*/
537
  LCD_WriteReg(R1, 0x50);
538
  LCD_WriteReg(R5, 0x04);
539
 
540
  LCD_WriteReg(R0, 0x80);
541
  LCD_WriteReg(R59, 0x01);
542
  vTaskDelay( 40 / portTICK_RATE_MS );  /* Delay 40 ms */
543
  LCD_WriteReg(R0, 0x20);
544
}
545
 
546
/*******************************************************************************
547
* Function Name  : LCD_SetTextColor
548
* Description    : Sets the Text color.
549
* Input          : - Color: specifies the Text color code RGB(5-6-5).
550
* Output         : - TextColor: Text color global variable used by LCD_DrawChar
551
*                  and LCD_DrawPicture functions.
552
* Return         : None
553
*******************************************************************************/
554
void LCD_SetTextColor(vu16 Color)
555
{
556
  TextColor = Color;
557
}
558
 
559
/*******************************************************************************
560
* Function Name  : LCD_SetBackColor
561
* Description    : Sets the Background color.
562
* Input          : - Color: specifies the Background color code RGB(5-6-5).
563
* Output         : - BackColor: Background color global variable used by
564
*                  LCD_DrawChar and LCD_DrawPicture functions.
565
* Return         : None
566
*******************************************************************************/
567
void LCD_SetBackColor(vu16 Color)
568
{
569
  BackColor = Color;
570
}
571
 
572
/*******************************************************************************
573
* Function Name  : LCD_ClearLine
574
* Description    : Clears the selected line.
575
* Input          : - Line: the Line to be cleared.
576
*                    This parameter can be one of the following values:
577
*                       - Linex: where x can be 0..9
578
* Output         : None
579
* Return         : None
580
*******************************************************************************/
581
void LCD_ClearLine(u8 Line)
582
{
583
  LCD_DisplayStringLine(Line, "                    ");
584
}
585
 
586
/*******************************************************************************
587
* Function Name  : LCD_Clear
588
* Description    : Clears the hole LCD.
589
* Input          : None
590
* Output         : None
591
* Return         : None
592
*******************************************************************************/
593
void LCD_Clear(void)
594
{
595
  u32 index = 0;
596
 
597
  LCD_SetCursor(0x00, 0x013F);
598
 
599
  for(index = 0; index < 0x12C00; index++)
600
  {
601
    LCD_WriteRAM(White);
602
  }
603
}
604
 
605
/*******************************************************************************
606
* Function Name  : LCD_SetCursor
607
* Description    : Sets the cursor position.
608
* Input          : - Xpos: specifies the X position.
609
*                  - Ypos: specifies the Y position.
610
* Output         : None
611
* Return         : None
612
*******************************************************************************/
613
void LCD_SetCursor(u8 Xpos, u16 Ypos)
614
{
615
  LCD_WriteReg(R66, Xpos);
616
  LCD_WriteReg(R67, ((Ypos & 0x100)>> 8));
617
  LCD_WriteReg(R68, (Ypos & 0xFF));
618
}
619
 
620
/*******************************************************************************
621
* Function Name  : LCD_DrawChar
622
* Description    : Draws a character on LCD.
623
* Input          : - Xpos: the Line where to display the character shape.
624
*                    This parameter can be one of the following values:
625
*                       - Linex: where x can be 0..9
626
*                  - Ypos: start column address.
627
*                  - c: pointer to the character data.
628
* Output         : None
629
* Return         : None
630
*******************************************************************************/
631
void LCD_DrawChar(u8 Xpos, u16 Ypos, uc16 *c)
632
{
633
  u32 index = 0, i = 0;
634
  u8 Xaddress = 0;
635
 
636
  Xaddress = Xpos;
637
 
638
  LCD_SetCursor(Xaddress, Ypos);
639
 
640
  for(index = 0; index < 24; index++)
641
  {
642
    for(i = 0; i < 16; i++)
643
    {
644
      if((c[index] & (1 << i)) == 0x00)
645
      {
646
        LCD_WriteRAM(BackColor);
647
      }
648
      else
649
      {
650
        LCD_WriteRAM(TextColor);
651
      }
652
    }
653
    Xaddress++;
654
    LCD_SetCursor(Xaddress, Ypos);
655
  }
656
}
657
 
658
/*******************************************************************************
659
* Function Name  : LCD_DisplayChar
660
* Description    : Displays one character (16dots width, 24dots height).
661
* Input          : - Line: the Line where to display the character shape .
662
*                    This parameter can be one of the following values:
663
*                       - Linex: where x can be 0..9
664
*                  - Column: start column address.
665
*                  - Ascii: character ascii code, must be between 0x20 and 0x7E.
666
* Output         : None
667
* Return         : None
668
*******************************************************************************/
669
void LCD_DisplayChar(u8 Line, u16 Column, u8 Ascii)
670
{
671
  Ascii -= 32;
672
  LCD_DrawChar(Line, Column, &ASCII_Table[Ascii * 24]);
673
}
674
 
675
/*******************************************************************************
676
* Function Name  : LCD_DisplayStringLine
677
* Description    : Displays a maximum of 20 char on the LCD.
678
* Input          : - Line: the Line where to display the character shape .
679
*                    This parameter can be one of the following values:
680
*                       - Linex: where x can be 0..9
681
*                  - *ptr: pointer to string to display on LCD.
682
* Output         : None
683
* Return         : None
684
*******************************************************************************/
685
void LCD_DisplayStringLine(u8 Line, u8 *ptr)
686
{
687
  u32 i = 0;
688
  u16 refcolumn = 319;
689
 
690
  /* Send the string character by character on lCD */
691
  while ((*ptr != 0) & (i < 20))
692
  {
693
    /* Display one character on LCD */
694
    LCD_DisplayChar(Line, refcolumn, *ptr);
695
    /* Decrement the column position by 16 */
696
    refcolumn -= 16;
697
    /* Point on the next character */
698
    ptr++;
699
    /* Increment the character counter */
700
    i++;
701
  }
702
}
703
 
704
/*******************************************************************************
705
* Function Name  : LCD_DisplayString
706
* Description    : Displays a maximum of 200 char on the LCD.
707
* Input          : - Line: the starting Line where to display the character shape.
708
*                    This parameter can be one of the following values:
709
*                       - Linex: where x can be 0..9
710
*                  - *ptr: pointer to string to display on LCD.
711
* Output         : None
712
* Return         : None
713
*******************************************************************************/
714
void LCD_DisplayString(u8 Line, u8 *ptr)
715
{
716
  u32 i = 0, column = 0, index = 0, spaceindex = 0;
717
  u16 refcolumn = 319;
718
  u32 length = 0;
719
 
720
  /* Get the string length */
721
  length = StrLength(ptr);
722
  if(length > 200)
723
  {
724
    /* Set the Cursor position */
725
    LCD_SetCursor(Line, 0x013F);
726
    /* Clear the Selected Line */
727
    LCD_ClearLine(Line);
728
    LCD_DisplayStringLine(Line, "   String too long  ");
729
  }
730
  else
731
  {
732
    /* Set the Cursor position */
733
    LCD_SetCursor(Line, 0x013F);
734
    /* Clear the Selected Line */
735
    LCD_ClearLine(Line);
736
 
737
    while(length--)
738
    {
739
      if(index == 20)
740
      {
741
        if(*ptr == 0x20)
742
        {
743
          ptr++;
744
        }
745
        else
746
        {
747
          for(i = 0; i < spaceindex; i++)
748
          {
749
            LCD_DisplayChar(Line, column, ' ');
750
            column -= 16;
751
          }
752
          ptr -= (spaceindex - 1);
753
          length += (spaceindex - 1);
754
        }
755
        Line += 24;
756
        /* Clear the Selected Line */
757
        LCD_ClearLine(Line);
758
        refcolumn = 319;
759
        index = 0;
760
      }
761
      /* Display one character on LCD */
762
      LCD_DisplayChar(Line, refcolumn, *ptr);
763
 
764
      /* Increment character number in one line */
765
      index++;
766
 
767
      /* Decrement the column position by 16 */
768
      refcolumn -= 16;
769
      /* Point on the next character */
770
      ptr++;
771
      /* Increment the number of character after the last space */
772
      spaceindex++;
773
      if(*ptr == 0x20)
774
      {
775
        spaceindex = 0;
776
        column = refcolumn - 16;
777
      }
778
    }
779
  }
780
}
781
 
782
/*******************************************************************************
783
* Function Name  : LCD_ScrollText
784
* Description    :
785
* Input          :
786
* Output         : None
787
* Return         : None
788
*******************************************************************************/
789
void LCD_ScrollText(u8 Line, u8 *ptr)
790
{
791
  u32 i = 0, length = 0, x = 0;
792
  u16 refcolumn = 319;
793
 
794
  /* Get the string length */
795
  length = StrLength(ptr);
796
 
797
  while(1)
798
  {
799
    /* Send the string character by character on lCD */
800
    while ((*ptr != 0) & (i < 20))
801
    {
802
      /* Display one character on LCD */
803
      LCD_DisplayChar(Line, refcolumn, *ptr);
804
      /* Decrement the column position by 16 */
805
      refcolumn -= 16;
806
      /* Point on the next character */
807
      ptr++;
808
      /* Increment the character counter */
809
      i++;
810
    }
811
    vTaskDelay( 100 / portTICK_RATE_MS );
812
    i = 0;
813
    //LCD_ClearLine(Line);
814
    ptr -= length;
815
    x++;
816
    if(refcolumn < 16)
817
    {
818
      x = 0;
819
    }
820
    refcolumn = 319 - (x * 16);
821
  }
822
}
823
 
824
/*******************************************************************************
825
* Function Name  : LCD_SetDisplayWindow
826
* Description    : Sets a display window
827
* Input          : - Xpos: specifies the X position.
828
*                  - Ypos: specifies the Y position.
829
*                  - Height: display window height.
830
*                  - Width: display window width.
831
* Output         : None
832
* Return         : None
833
*******************************************************************************/
834
void LCD_SetDisplayWindow(u8 Xpos, u16 Ypos, u8 Height, u16 Width)
835
{
836
  LCD_WriteReg(R1, 0xD0);
837
  LCD_WriteReg(R5, 0x14);
838
 
839
  LCD_WriteReg(R69, Xpos);
840
  LCD_WriteReg(R70, (Xpos + Height + 1));
841
 
842
  LCD_WriteReg(R71, ((Ypos & 0x100)>> 8));
843
  LCD_WriteReg(R72, (Ypos & 0xFF));
844
 
845
  LCD_WriteReg(R73, (((Ypos + Width + 1) & 0x100)>> 8));
846
  LCD_WriteReg(R74, ((Ypos + Width + 1) & 0xFF));
847
 
848
  LCD_SetCursor(Xpos, Ypos);
849
}
850
 
851
/*******************************************************************************
852
* Function Name  : LCD_DrawLine
853
* Description    : Displays a line.
854
* Input          : - Xpos: specifies the X position.
855
*                  - Ypos: specifies the Y position.
856
*                  - Length: line length.
857
*                  - Direction: line direction.
858
*                    This parameter can be one of the following values: Vertical
859
*                    or Horizontal.
860
* Output         : None
861
* Return         : None
862
*******************************************************************************/
863
void LCD_DrawLine(u8 Xpos, u16 Ypos, u16 Length, u8 Direction)
864
{
865
  u32 i = 0;
866
 
867
  LCD_SetCursor(Xpos, Ypos);
868
 
869
  if(Direction == Horizontal)
870
  {
871
    for(i = 0; i < Length; i++)
872
    {
873
      LCD_WriteRAM(TextColor);
874
    }
875
  }
876
  else
877
  {
878
   for(i = 0; i < Length; i++)
879
    {
880
 
881
      LCD_WriteRAM(TextColor);
882
      Xpos++;
883
      LCD_SetCursor(Xpos, Ypos);
884
    }
885
  }
886
}
887
 
888
/*******************************************************************************
889
* Function Name  : LCD_DrawRect
890
* Description    : Displays a rectangle.
891
* Input          : - Xpos: specifies the X position.
892
*                  - Ypos: specifies the Y position.
893
*                  - Height: display rectangle height.
894
*                  - Width: display rectangle width.
895
* Output         : None
896
* Return         : None
897
*******************************************************************************/
898
void LCD_DrawRect(u8 Xpos, u16 Ypos, u8 Height, u16 Width)
899
{
900
  LCD_DrawLine(Xpos, Ypos, Width, Horizontal);
901
  LCD_DrawLine((Xpos + Height), Ypos, Width, Horizontal);
902
 
903
  LCD_DrawLine(Xpos, Ypos, Height, Vertical);
904
  LCD_DrawLine(Xpos, (Ypos - Width + 1), Height, Vertical);
905
}
906
 
907
/*******************************************************************************
908
* Function Name  : LCD_DrawCircle
909
* Description    : Displays a circle.
910
* Input          : - Xpos: specifies the X position.
911
*                  - Ypos: specifies the Y position.
912
*                  - Height: display rectangle height.
913
*                  - Width: display rectangle width.
914
* Output         : None
915
* Return         : None
916
*******************************************************************************/
917
void LCD_DrawCircle(u8 Xpos, u16 Ypos, u16 Radius)
918
{
919
  s32   D;      /* Decision Variable */
920
  u32   CurX;   /* Current X Value */
921
  u32   CurY;   /* Current Y Value */
922
 
923
  D = 3 - (Radius << 1);
924
  CurX = 0;
925
  CurY = Radius;
926
 
927
  while (CurX <= CurY)
928
  {
929
    LCD_SetCursor(Xpos + CurX, Ypos + CurY);
930
    LCD_WriteRAM(TextColor);
931
    LCD_SetCursor(Xpos + CurX, Ypos - CurY);
932
    LCD_WriteRAM(TextColor);
933
    LCD_SetCursor(Xpos - CurX, Ypos + CurY);
934
    LCD_WriteRAM(TextColor);
935
    LCD_SetCursor(Xpos - CurX, Ypos - CurY);
936
    LCD_WriteRAM(TextColor);
937
    LCD_SetCursor(Xpos + CurY, Ypos + CurX);
938
    LCD_WriteRAM(TextColor);
939
    LCD_SetCursor(Xpos + CurY, Ypos - CurX);
940
    LCD_WriteRAM(TextColor);
941
    LCD_SetCursor(Xpos - CurY, Ypos + CurX);
942
    LCD_WriteRAM(TextColor);
943
    LCD_SetCursor(Xpos - CurY, Ypos - CurX);
944
    LCD_WriteRAM(TextColor);
945
 
946
    if (D < 0)
947
    {
948
      D += (CurX << 2) + 6;
949
    }
950
    else
951
    {
952
      D += ((CurX - CurY) << 2) + 10;
953
      CurY--;
954
    }
955
    CurX++;
956
  }
957
}
958
 
959
/*******************************************************************************
960
* Function Name  : LCD_DrawMonoPict
961
* Description    : Displays a monocolor picture.
962
* Input          : - Pict: pointer to the picture array.
963
* Output         : None
964
* Return         : None
965
*******************************************************************************/
966
void LCD_DrawMonoPict(uc32 *Pict)
967
{
968
  u32 index = 0, i = 0;
969
 
970
  LCD_SetCursor(0, 319);
971
 
972
  for(index = 0; index < 2400; index++)
973
  {
974
    for(i = 0; i < 32; i++)
975
    {
976
      if((Pict[index] & (1 << i)) == 0x00)
977
      {
978
        LCD_WriteRAM(BackColor);
979
      }
980
      else
981
      {
982
        LCD_WriteRAM(TextColor);
983
      }
984
    }
985
  }
986
}
987
 
988
/*******************************************************************************
989
* Function Name  : LCD_DrawBMP
990
* Description    : Displays a bitmap picture loaded in the SPI Flash.
991
* Input          : - BmpAddress: Bmp picture address in the SPI Flash.
992
* Output         : None
993
* Return         : None
994
*******************************************************************************/
995
void LCD_DrawBMP(u32 BmpAddress)
996
{
997
  u32 i = 0;
998
 
999
  LCD_WriteReg(R1, 0xD0);
1000
  LCD_WriteReg(R5, 0x04);
1001
 
1002
  LCD_SetCursor(239, 0x013F);
1003
 
1004
  SPI_FLASH_StartReadSequence(BmpAddress);
1005
 
1006
  /* Disable SPI1  */
1007
  SPI_Cmd(SPI1, DISABLE);
1008
  /* SPI in 16-bit mode */
1009
  SPI_DataSizeConfig(SPI1, SPI_DataSize_16b);
1010
  /* Enable SPI1  */
1011
  SPI_Cmd(SPI1, ENABLE);
1012
 
1013
  for(i = 0; i < 76800; i++)
1014
  {
1015
    LCD_WriteRAM(__REV_HalfWord(SPI_FLASH_SendHalfWord(0xA5A5)));
1016
  }
1017
 
1018
  /* Deselect the FLASH: Chip Select high */
1019
  SPI_FLASH_ChipSelect(1);
1020
 
1021
  /* Disable SPI1  */
1022
  SPI_Cmd(SPI1, DISABLE);
1023
  /* SPI in 8-bit mode */
1024
  SPI_DataSizeConfig(SPI1, SPI_DataSize_8b);
1025
  /* Enable SPI1  */
1026
  SPI_Cmd(SPI1, ENABLE);
1027
}
1028
 
1029
/*******************************************************************************
1030
* Function Name  : LCD_WriteReg
1031
* Description    : Writes to the selected LCD register.
1032
* Input          : - LCD_Reg: address of the selected register.
1033
*                  - LCD_RegValue: value to write to the selected register.
1034
* Output         : None
1035
* Return         : None
1036
*******************************************************************************/
1037
void LCD_WriteReg(u8 LCD_Reg, u8 LCD_RegValue)
1038
{
1039
  u16 tmp = 0;
1040
 
1041
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_NWR, Bit_RESET);
1042
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_RS, Bit_RESET);
1043
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_RESET);
1044
 
1045
  tmp = LCD_Reg << 8;
1046
  tmp |= LCD_RegValue;
1047
 
1048
  SPI_SendData(SPI2, tmp);
1049
  while(SPI_GetFlagStatus(SPI2, SPI_FLAG_TXE) == RESET)
1050
  {
1051
  }
1052
 
1053
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);
1054
}
1055
 
1056
/*******************************************************************************
1057
* Function Name  : LCD_ReadReg
1058
* Description    : Reads the selected LCD Register.
1059
* Input          : None
1060
* Output         : None
1061
* Return         : LCD Register Value.
1062
*******************************************************************************/
1063
u8 LCD_ReadReg(u8 LCD_Reg)
1064
{
1065
  u16 tmp = 0;
1066
 
1067
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_NWR, Bit_RESET);
1068
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_RS, Bit_RESET);
1069
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_RESET);
1070
 
1071
  while(SPI_GetFlagStatus(SPI2, SPI_FLAG_TXE) == RESET)
1072
  {
1073
  }
1074
  SPI_SendData(SPI2, LCD_Reg);
1075
 
1076
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_NWR, Bit_SET);
1077
 
1078
  while(SPI_GetFlagStatus(SPI2, SPI_FLAG_TXE) == RESET)
1079
  {
1080
  }
1081
  SPI_SendData(SPI2, 0xFF);
1082
 
1083
  while(SPI_GetFlagStatus(SPI2, SPI_FLAG_RXNE)== RESET)
1084
  {
1085
  }
1086
  tmp = SPI_ReceiveData(SPI2);
1087
 
1088
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);
1089
  return tmp;
1090
}
1091
 
1092
/*******************************************************************************
1093
* Function Name  : LCD_WriteRAM
1094
* Description    : Writes to the LCD RAM.
1095
* Input          : - RGB_Code: the pixel color in RGB mode (5-6-5).
1096
* Output         : None
1097
* Return         : None
1098
*******************************************************************************/
1099
void LCD_WriteRAM(u16 RGB_Code)
1100
{
1101
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_NWR, Bit_RESET);
1102
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_RS, Bit_SET);
1103
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_RESET);
1104
 
1105
  SPI_SendData(SPI2, RGB_Code);
1106
  while(SPI_GetFlagStatus(SPI2, SPI_FLAG_TXE) == RESET)
1107
  {
1108
  }
1109
 
1110
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);
1111
}
1112
 
1113
/*******************************************************************************
1114
* Function Name  : LCD_ReadRAM
1115
* Description    : Reads the LCD RAM.
1116
* Input          : None
1117
* Output         : None
1118
* Return         : LCD RAM Value.
1119
*******************************************************************************/
1120
u16  LCD_ReadRAM(void)
1121
{
1122
  u16 tmp = 0;
1123
 
1124
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_NWR, Bit_SET);
1125
  LCD_CtrlLinesWrite(GPIOD, CtrlPin_RS, Bit_SET);
1126
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_RESET);
1127
 
1128
  while(SPI_GetFlagStatus(SPI2, SPI_FLAG_TXE) == RESET)
1129
  {
1130
  }
1131
  SPI_SendData(SPI2, 0xFF);
1132
  while(SPI_GetFlagStatus(SPI2, SPI_FLAG_RXNE)==RESET)
1133
  {
1134
  }
1135
  tmp = SPI_ReceiveData(SPI2);
1136
 
1137
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);
1138
 
1139
  return tmp;
1140
}
1141
 
1142
/*******************************************************************************
1143
* Function Name  : LCD_PowerOn
1144
* Description    :
1145
* Input          : None
1146
* Output         : None
1147
* Return         : None
1148
*******************************************************************************/
1149
void LCD_PowerOn(void)
1150
{
1151
  /* Power On Set */
1152
  LCD_WriteReg(R28, 0x73);
1153
  LCD_WriteReg(R36, 0x74);
1154
  LCD_WriteReg(R30, 0x01);
1155
  LCD_WriteReg(R24, 0xC1);
1156
  vTaskDelay( 10 / portTICK_RATE_MS ); /* Delay 10 ms */
1157
  LCD_WriteReg(R24, 0xE1);
1158
  LCD_WriteReg(R24, 0xF1);
1159
  vTaskDelay( 60 / portTICK_RATE_MS ); /* Delay 60 ms */
1160
  LCD_WriteReg(R24, 0xF5);
1161
  vTaskDelay( 60 / portTICK_RATE_MS ); /* Delay 60 ms */
1162
  LCD_WriteReg(R27, 0x09);
1163
  vTaskDelay( 10 / portTICK_RATE_MS ); /* Delay 10 ms */
1164
  LCD_WriteReg(R31, 0x11);
1165
  LCD_WriteReg(R32, 0x0E);
1166
  LCD_WriteReg(R30, 0x81);
1167
  vTaskDelay( 10 / portTICK_RATE_MS ); /* Delay 10 ms */
1168
}
1169
 
1170
/*******************************************************************************
1171
* Function Name  : LCD_DisplayOn
1172
* Description    : Enables the Display.
1173
* Input          : None
1174
* Output         : None
1175
* Return         : None
1176
*******************************************************************************/
1177
void LCD_DisplayOn(void)
1178
{
1179
  LCD_WriteReg(R1, 0x50);
1180
  LCD_WriteReg(R5, 0x04);
1181
 
1182
  /* Display On */
1183
  LCD_WriteReg(R0, 0x80);
1184
  LCD_WriteReg(R59, 0x01);
1185
  vTaskDelay( 40 / portTICK_RATE_MS );                 /* Delay 40 ms */
1186
  LCD_WriteReg(R0, 0x20);
1187
}
1188
 
1189
/*******************************************************************************
1190
* Function Name  : LCD_DisplayOff
1191
* Description    : Disables the Display.
1192
* Input          : None
1193
* Output         : None
1194
* Return         : None
1195
*******************************************************************************/
1196
void LCD_DisplayOff(void)
1197
{
1198
  /* Display Off */
1199
  LCD_WriteReg(R0, 0xA0);
1200
  vTaskDelay( 40 / portTICK_RATE_MS );                 /* Delay 40 ms */
1201
  LCD_WriteReg(R59, 0x00);
1202
}
1203
 
1204
/*******************************************************************************
1205
* Function Name  : LCD_CtrlLinesConfig
1206
* Description    : Configures LCD control lines in Output Push-Pull mode.
1207
* Input          : None
1208
* Output         : None
1209
* Return         : None
1210
*******************************************************************************/
1211
void LCD_CtrlLinesConfig(void)
1212
{
1213
  GPIO_InitTypeDef GPIO_InitStructure;
1214
 
1215
  /* Configure NCS (PB.02) in Output Push-Pull mode */
1216
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
1217
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
1218
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
1219
  GPIO_Init(GPIOB, &GPIO_InitStructure);
1220
 
1221
  /* Configure NWR(RNW), RS (PD.15, PD.07) in Output Push-Pull mode */
1222
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_15;
1223
  GPIO_Init(GPIOD, &GPIO_InitStructure);
1224
}
1225
 
1226
/*******************************************************************************
1227
* Function Name  : LCD_CtrlLinesWrite
1228
* Description    : Sets or reset LCD control lines.
1229
* Input          : - GPIOx: where x can be B or D to select the GPIO peripheral.
1230
*                  - CtrlPins: the Control line. This parameter can be:
1231
*                       - CtrlPin_NCS: Chip Select pin (PB.02)
1232
*                       - CtrlPin_NWR: Read/Write Selection pin (PD.15)
1233
*                       - CtrlPin_RS: Register/RAM Selection pin (PD.07)
1234
*                  - BitVal: specifies the value to be written to the selected bit.
1235
*                    This parameter can be:
1236
*                       - Bit_RESET: to clear the port pin
1237
*                       - Bit_SET: to set the port pin
1238
* Output         : None
1239
* Return         : None
1240
*******************************************************************************/
1241
void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, u16 CtrlPins, BitAction BitVal)
1242
{
1243
  /* Set or Reset the control line */
1244
  GPIO_WriteBit(GPIOx, CtrlPins, BitVal);
1245
}
1246
 
1247
/*******************************************************************************
1248
* Function Name  : LCD_SPIConfig
1249
* Description    : Configures the SPI2 interface.
1250
* Input          : None
1251
* Output         : None
1252
* Return         : None
1253
*******************************************************************************/
1254
void LCD_SPIConfig(void)
1255
{
1256
  SPI_InitTypeDef    SPI_InitStructure;
1257
  GPIO_InitTypeDef   GPIO_InitStructure;
1258
 
1259
  /* Enable GPIOA clock */
1260
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
1261
 
1262
  /* Enable SPI2 clock  */
1263
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
1264
 
1265
  /* Configure SPI2 pins: NSS, SCK, MISO and MOSI */
1266
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
1267
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
1268
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
1269
  GPIO_Init(GPIOB, &GPIO_InitStructure);
1270
 
1271
  /* SPI2 Config */
1272
  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
1273
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
1274
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
1275
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
1276
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
1277
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
1278
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
1279
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
1280
  SPI_Init(SPI2, &SPI_InitStructure);
1281
 
1282
  /* SPI2 enable */
1283
  SPI_Cmd(SPI2, ENABLE);
1284
}
1285
 
1286
/*******************************************************************************
1287
* Function Name  : StrLength
1288
* Description    : Returns length of string.
1289
* Input          : - Str: Character Pointer.
1290
* Output         : None
1291
* Return         : String length.
1292
*******************************************************************************/
1293
static u32 StrLength(u8 *Str)
1294
{
1295
  u32 Index = 0;
1296
 
1297
  /* Increment the Index unless the end of string */
1298
  for(Index = 0; *Str != '\0'; Str++, Index++)
1299
  {
1300
  }
1301
 
1302
  return Index;
1303
}
1304
 
1305
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.