comparison libs/STM32F10x_StdPeriph_Lib_V3.5.0/Utilities/STM32_EVAL/STM32L152_EVAL/stm32l152_eval_glass_lcd.c @ 0:c59513fd84fb

Initial commit of STM32 test code.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 03 Oct 2011 21:19:15 +1030
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c59513fd84fb
1 /**
2 ******************************************************************************
3 * @file stm32l152_eval_glass_lcd.c
4 * @author MCD Application Team
5 * @version V4.5.0
6 * @date 07-March-2011
7 * @brief This file includes the LCD Glass driver for Pacific Display
8 * (LCD_PD878, PD878-DP-FH-W-LV-6-RH) Module of STM32L152-EVAL board RevB.
9 ******************************************************************************
10 * @attention
11 *
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 *
19 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
20 ******************************************************************************
21 */
22
23 /* Includes ------------------------------------------------------------------*/
24 #include "stm32l152_eval_glass_lcd.h"
25
26 /** @addtogroup Utilities
27 * @{
28 */
29
30 /** @addtogroup STM32_EVAL
31 * @{
32 */
33
34 /** @addtogroup STM32L152_EVAL
35 * @{
36 */
37
38 /** @defgroup STM32L152_EVAL_GLASS_LCD
39 * @brief This file includes the LCD Glass driver for Pacific Display
40 * (LCD_PD878, PD878-DP-FH-W-LV-6-RH) Module of STM32L152-EVAL board.
41 * @{
42 */
43
44 /** @defgroup STM32L152_EVAL_GLASS_LCD_Private_Types
45 * @{
46 */
47 /**
48 * @}
49 */
50
51
52 /** @defgroup STM32L152_EVAL_GLASS_LCD_Private_Defines
53 * @{
54 */
55 /**
56 * @}
57 */
58
59
60 /** @defgroup STM32L152_EVAL_GLASS_LCD_Private_Macros
61 * @{
62 */
63 /**
64 * @}
65 */
66
67
68 /** @defgroup STM32L152_EVAL_GLASS_LCD_Private_Variables
69 * @{
70 */
71
72 /**
73 @verbatim
74 ================================================================================
75 GLASS LCD MAPPING
76 ================================================================================
77 A
78 -- ----------
79 X \/ |\ |I /|
80 F| H | J |B
81 | \ | / |
82 --G-- --K--
83 | /| \ |
84 E | L | N |C
85 | / |M \| _
86 ----------- | |DP
87 D -
88
89 A LCD character coding is based on the following matrix:
90
91
92 { X , F , E , D }
93 { I , J , K , N }
94 { A , B , C , DP }
95 { H , G , L , M }
96
97 The character A for example is:
98 -------------------------------
99 { 0 , 1 , 1 , 0 }
100 { 0 , 0 , 1 , 0 }
101 { 1 , 1 , 1 , 0 }
102 { 0 , 1 , 0 , 0 }
103 -------------------
104 = 4 D 7 0 hex
105
106 => 'A' = 0x4D70
107
108 @endverbatim
109 */
110
111 /**
112 * @brief LETTERS AND NUMBERS MAPPING DEFINITION
113 */
114 uint8_t digit[4]; /* Digit LCD RAM buffer */
115 __I uint16_t mask[4] = {0xF000, 0x0F00, 0x00F0, 0x000F};
116 __I uint8_t shift[4] = {0x0C, 0x08, 0x04, 0x00};
117
118 /* Letters and number map of PD_878 LCD */
119 __I uint16_t LetterMap[26]=
120 {
121 /* A B C D E F G H I */
122 0x4D70, 0x6469, 0x4111, 0x6449, 0x4911, 0x4910, 0x4171, 0x0D70, 0x6009,
123 /* J K L M N O P Q R */
124 0x0451, 0x0B12, 0x0111, 0x8750, 0x8552, 0x4551, 0x4D30, 0x4553, 0x4D32,
125 /* S T U V W X Y Z */
126 0x4961, 0x6008, 0x0551, 0x0390, 0x05D2, 0x8282, 0x8208, 0x4281
127 };
128
129 __I uint16_t NumberMap[10]=
130 {
131 /* 0 1 2 3 4 5 6 7 8 9 */
132 0x47D1, 0x0640, 0x4C31, 0x4C61, 0x0D60, 0x4961, 0x4971, 0x4440, 0x4D71, 0x4D61
133 };
134
135 /**
136 * @}
137 */
138
139
140 /** @defgroup STM32L152_EVAL_LCD_Private_Function_Prototypes
141 * @{
142 */
143 static void Convert(uint8_t* c, Point_Typedef point, Apostrophe_Typedef apostrophe);
144 static void delay(__IO uint32_t nCount);
145 static void LCD_GPIOConfig(void);
146
147 /**
148 * @}
149 */
150
151 /** @defgroup STM32L152_EVAL_LCD_Private_Functions
152 * @{
153 */
154
155 /**
156 * @brief Configures the LCD GLASS relative GPIO port IOs and LCD peripheral.
157 * @param None
158 * @retval None
159 */
160 void LCD_GLASS_Init(void)
161 {
162 LCD_InitTypeDef LCD_InitStructure;
163
164 LCD_GPIOConfig(); /*!< Configure the LCD Glass GPIO pins */
165
166 /*!< Configure the LCD interface -------------------------------------------*/
167 RCC_APB1PeriphClockCmd(RCC_APB1Periph_LCD, ENABLE); /*!< Enable LCD APB1 Clock */
168
169 LCD_InitStructure.LCD_Prescaler = LCD_Prescaler_8;
170 LCD_InitStructure.LCD_Divider = LCD_Divider_16;
171 LCD_InitStructure.LCD_Duty = LCD_Duty_1_4;
172 LCD_InitStructure.LCD_Bias = LCD_Bias_1_3;
173 LCD_InitStructure.LCD_VoltageSource = LCD_VoltageSource_Internal;
174 LCD_Init(&LCD_InitStructure);
175
176 /*!< Configure the Pulse On Duration */
177 LCD_PulseOnDurationConfig(LCD_PulseOnDuration_2);
178
179 /*!< Configure the LCD Contrast (3.51V) */
180 LCD_ContrastConfig(LCD_Contrast_Level_7);
181
182 /*!< Wait Until the LCD FCR register is synchronized */
183 LCD_WaitForSynchro();
184
185 /*!< Enable LCD peripheral */
186 LCD_Cmd(ENABLE);
187
188 /*!< Wait Until the LCD is enabled */
189 while(LCD_GetFlagStatus(LCD_FLAG_ENS) == RESET)
190 {
191 }
192 /*!< Wait Until the LCD Booster is ready */
193 while(LCD_GetFlagStatus(LCD_FLAG_RDY) == RESET)
194 {
195 }
196 }
197
198 /**
199 * @brief This function writes a char in the LCD RAM.
200 * @param ch: The character to dispaly.
201 * @param point: A point to add in front of char.
202 * This parameter can be one of the following values:
203 * @arg POINT_OFF: No point to add in front of char.
204 * @arg POINT_ON: Add a point in front of char.
205 * @param apostrophe: Flag indicating if a apostrophe has to be add in front
206 * of displayed character.
207 * This parameter can be one of the following values:
208 * @arg APOSTROPHE_OFF: No apostrophe to add in back of char.
209 * @arg APOSTROPHE_ON: Add an apostrophe in back of char.
210 * @param position: Position in the LCD of the caracter to write.
211 * This parameter can be any value in range [0:7].
212 * @retval None
213 */
214 void LCD_GLASS_DisplayChar(uint8_t* ch, Point_Typedef point, Apostrophe_Typedef apostrophe, uint8_t position)
215 {
216 /*!< Wait Until the last LCD RAM update finish */
217 while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET)
218 {
219 }
220 /*!< LCD Write Char */
221 LCD_GLASS_WriteChar(ch, point, apostrophe, position);
222
223 /*!< Requesy LCD RAM update */
224 LCD_UpdateDisplayRequest();
225 }
226
227 /**
228 * @brief This function writes a char in the LCD RAM.
229 * @param ptr: Pointer to string to display on the LCD Glass.
230 * @retval None
231 */
232 void LCD_GLASS_DisplayString(uint8_t* ptr)
233 {
234 uint32_t i = 0x00;
235
236 /*!< Wait Until the last LCD RAM update finish */
237 while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET)
238 {
239 }
240
241 /*!< Send the string character by character on lCD */
242 while ((*ptr != 0) & (i < 8))
243 {
244 /*!< Display one character on LCD */
245 LCD_GLASS_WriteChar(ptr, POINT_OFF, APOSTROPHE_OFF, i);
246 /*!< Point on the next character */
247 ptr++;
248 /*!< Increment the character counter */
249 i++;
250 }
251 /*!< Requesy LCD RAM update */
252 LCD_UpdateDisplayRequest();
253 }
254
255 /**
256 * @brief This function writes a char in the LCD RAM.
257 * @param ch: The character to dispaly.
258 * @param point: A point to add in front of char.
259 * This parameter can be one of the following values:
260 * @arg POINT_OFF : No point to add in front of char.
261 * @arg POINT_ON : Add a point in front of char.
262 * @param apostrophe: Flag indicating if a apostrophe has to be add in front
263 * of displayed character.
264 * This parameter can be one of the following values:
265 * @arg APOSTROPHE_OFF : No apostrophe to add in back of char.
266 * @arg APOSTROPHE_ON : Add an apostrophe in back of char.
267 * @param position: Position in the LCD of the caracter to write.
268 * This parameter can be any value in range [0:7].
269 * @retval None
270 */
271 void LCD_GLASS_WriteChar(uint8_t* ch, Point_Typedef point, Apostrophe_Typedef apostrophe, uint8_t position)
272 {
273 uint32_t tmp = 0x00;
274
275 Convert(ch, point, apostrophe); /*!< Convert the corresponding character */
276
277 switch (position)
278 {
279 case 7:
280 /*!< Clear the corresponding segments (SEG0, SEG1, SEG2, SEG3) */
281 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFFFFFFF0);
282 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFFFFFFF0);
283 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFFFFFFF0);
284 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFFFFFFF0);
285
286 /*!< Write the corresponding segments (SEG0, SEG1, SEG2, SEG3) */
287 LCD->RAM[LCD_RAMRegister_0] |= (uint32_t)(digit[0]);
288 LCD->RAM[LCD_RAMRegister_2] |= (uint32_t)(digit[1]);
289 LCD->RAM[LCD_RAMRegister_4] |= (uint32_t)(digit[2]);
290 LCD->RAM[LCD_RAMRegister_6] |= (uint32_t)(digit[3]);
291 break;
292
293 case 6:
294 /*!< Clear the corresponding segments (SEG4, SEG5, SEG6, SEG10) */
295 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFFFFFB8F);
296 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFFFFFB8F);
297 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFFFFFB8F);
298 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFFFFFB8F);
299
300 /*!< Write the corresponding segments (SEG4, SEG5, SEG6, SEG10) */
301 tmp = (((digit[0] & 0x8) << 7) | ((digit[0]& 0x7) << 4));
302 LCD->RAM[LCD_RAMRegister_0] |= (uint32_t) tmp;
303 tmp = (((digit[1] & 0x8) << 7) | ((digit[1]& 0x7) << 4));
304 LCD->RAM[LCD_RAMRegister_2] |= (uint32_t) tmp;
305 tmp = (((digit[2] & 0x8) << 7) | ((digit[2]& 0x7) << 4));
306 LCD->RAM[LCD_RAMRegister_4] |= (uint32_t) tmp;
307 tmp = (((digit[3] & 0x8) << 7) | ((digit[3]& 0x7) << 4));
308 LCD->RAM[LCD_RAMRegister_6] |= (uint32_t) tmp;
309 break;
310
311 case 5:
312 /*!< Clear the corresponding segments (SEG11, SEG16, SEG18, SEG19) */
313 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFFF2F7FF);
314 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFFF2F7FF);
315 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFFF2F7FF);
316 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFFF2F7FF);
317
318 /*!< Write the corresponding segments (SEG11, SEG16, SEG18, SEG19) */
319 tmp = (((digit[0] & 0x1) << 11) | ((digit[0]& 0x2) << 15) | ((digit[0]& 0xC) << 16));
320 LCD->RAM[LCD_RAMRegister_0] |= (uint32_t)(tmp);
321 tmp = (((digit[1] & 0x1) << 11) | ((digit[1]& 0x2) << 15) | ((digit[1]& 0xC) << 16));
322 LCD->RAM[LCD_RAMRegister_2] |= (uint32_t)(tmp);
323 tmp = (((digit[2] & 0x1) << 11) | ((digit[2]& 0x2) << 15) | ((digit[2]& 0xC) << 16));
324 LCD->RAM[LCD_RAMRegister_4] |= (uint32_t)(tmp);
325 tmp = (((digit[3] & 0x1) << 11) | ((digit[3]& 0x2) << 15) | ((digit[3]& 0xC) << 16));
326 LCD->RAM[LCD_RAMRegister_6] |= (uint32_t)(tmp);
327 break;
328
329 case 4:
330 /*!< Clear the corresponding segments (SEG20, SEG21, SEG22, SEG23) */
331 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFF0FFFFF);
332 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFF0FFFFF);
333 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFF0FFFFF);
334 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFF0FFFFF);
335
336 /*!< Write the corresponding segments (SEG20, SEG21, SEG22, SEG23) */
337 LCD->RAM[LCD_RAMRegister_0] |= (uint32_t)(digit[0] << 20);
338 LCD->RAM[LCD_RAMRegister_2] |= (uint32_t)(digit[1] << 20);
339 LCD->RAM[LCD_RAMRegister_4] |= (uint32_t)(digit[2] << 20);
340 LCD->RAM[LCD_RAMRegister_6] |= (uint32_t)(digit[3] << 20);
341 break;
342
343 case 3:
344 /*!< Clear the corresponding segments (SEG28, SEG29, SEG30, SEG31) */
345 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0x0FFFFFFF);
346 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0x0FFFFFFF);
347 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0x0FFFFFFF);
348 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0x0FFFFFFF);
349
350 /*!< Write the corresponding segments (SEG28, SEG29, SEG30, SEG31) */
351 LCD->RAM[LCD_RAMRegister_0] |= (uint32_t)(digit[0] << 28);
352 LCD->RAM[LCD_RAMRegister_2] |= (uint32_t)(digit[1] << 28);
353 LCD->RAM[LCD_RAMRegister_4] |= (uint32_t)(digit[2] << 28);
354 LCD->RAM[LCD_RAMRegister_6] |= (uint32_t)(digit[3] << 28);
355 break;
356
357 case 2:
358 /*!< Clear the corresponding segments (SEG32, SEG33, SEG34, SEG35) */
359 LCD->RAM[LCD_RAMRegister_1] &= (uint32_t)(0xFFFFFFF0);
360 LCD->RAM[LCD_RAMRegister_3] &= (uint32_t)(0xFFFFFFF0);
361 LCD->RAM[LCD_RAMRegister_5] &= (uint32_t)(0xFFFFFFF0);
362 LCD->RAM[LCD_RAMRegister_7] &= (uint32_t)(0xFFFFFFF0);
363
364 /*!< Write the corresponding segments (SEG32, SEG33, SEG34, SEG35) */
365 LCD->RAM[LCD_RAMRegister_1] |= (uint32_t)(digit[0] << 0);
366 LCD->RAM[LCD_RAMRegister_3] |= (uint32_t)(digit[1] << 0);
367 LCD->RAM[LCD_RAMRegister_5] |= (uint32_t)(digit[2] << 0);
368 LCD->RAM[LCD_RAMRegister_7] |= (uint32_t)(digit[3] << 0);
369 break;
370
371 case 1:
372 /*!< Clear the corresponding segments (SEG36, SEG37, SEG38, SEG39) */
373 LCD->RAM[LCD_RAMRegister_1] &= (uint32_t)(0xFFFFFF0F);
374 LCD->RAM[LCD_RAMRegister_3] &= (uint32_t)(0xFFFFFF0F);
375 LCD->RAM[LCD_RAMRegister_5] &= (uint32_t)(0xFFFFFF0F);
376 LCD->RAM[LCD_RAMRegister_7] &= (uint32_t)(0xFFFFFF0F);
377
378 /*!< Write the corresponding segments (SEG36, SEG37, SEG38, SEG39) */
379 LCD->RAM[LCD_RAMRegister_1] |= (uint32_t)(digit[0] << 4);
380 LCD->RAM[LCD_RAMRegister_3] |= (uint32_t)(digit[1] << 4);
381 LCD->RAM[LCD_RAMRegister_5] |= (uint32_t)(digit[2] << 4);
382 LCD->RAM[LCD_RAMRegister_7] |= (uint32_t)(digit[3] << 4);
383
384 break;
385
386 case 0:
387 /*!< Clear the corresponding segments (SEG40, SEG41, SEG42, SEG43) */
388 LCD->RAM[LCD_RAMRegister_1] &= (uint32_t)(0xFFFFF0FF);
389 LCD->RAM[LCD_RAMRegister_3] &= (uint32_t)(0xFFFFF0FF);
390 LCD->RAM[LCD_RAMRegister_5] &= (uint32_t)(0xFFFFF0FF);
391 LCD->RAM[LCD_RAMRegister_7] &= (uint32_t)(0xFFFFF0FF);
392
393 /*!< Write the corresponding segments (SEG40, SEG41, SEG42, SEG43) */
394 LCD->RAM[LCD_RAMRegister_1] |= (uint32_t)(digit[0] << 8);
395 LCD->RAM[LCD_RAMRegister_3] |= (uint32_t)(digit[1] << 8);
396 LCD->RAM[LCD_RAMRegister_5] |= (uint32_t)(digit[2] << 8);
397 LCD->RAM[LCD_RAMRegister_7] |= (uint32_t)(digit[3] << 8);
398 break;
399 }
400 }
401
402 /**
403 * @brief Display a string in scrolling mode
404 * @note The LCD should be cleared before to start the write operation.
405 * @param ptr: Pointer to string to display on the LCD Glass.
406 * @param nScroll: Specifies how many time the message will be scrolled
407 * @param ScrollSpeed: Speciifes the speed of the scroll.
408 * Low value gives higher speed.
409 * @retval None
410 */
411 void LCD_GLASS_ScrollString(uint8_t* ptr, uint16_t nScroll, uint16_t ScrollSpeed)
412 {
413 uint8_t Repetition = 0;
414 uint8_t* ptr1;
415 uint8_t str[8] = "";
416 ptr1 = ptr;
417
418 LCD_GLASS_DisplayString(ptr1);
419
420 delay(ScrollSpeed);
421
422 for (Repetition = 0; Repetition < nScroll; Repetition++)
423 {
424 *(str + 1) = *ptr1;
425 *(str + 2) = *(ptr1 + 1);
426 *(str + 3) = *(ptr1 + 2);
427 *(str + 4) = *(ptr1 + 3);
428 *(str + 5) = *(ptr1 + 4);
429 *(str + 6) = *(ptr1 + 5);
430 *(str + 7) =*(ptr1 + 6);
431 *(str) = *(ptr1 + 7);
432 LCD_GLASS_Clear();
433 LCD_GLASS_DisplayString(str);
434 delay(ScrollSpeed);
435
436 *(str + 1) = *(ptr1 + 7);
437 *(str + 2) = *ptr1;
438 *(str + 3) = *(ptr1 + 1);
439 *(str + 4) = *(ptr1 + 2);
440 *(str + 5) = *(ptr1 + 3);
441 *(str + 6) = *(ptr1 + 4);
442 *(str + 7) = *(ptr1 + 5);
443 *(str) = *(ptr1 + 6);
444 LCD_GLASS_Clear();
445 LCD_GLASS_DisplayString(str);
446 delay(ScrollSpeed);
447
448 *(str + 1) = *(ptr1 + 6);
449 *(str + 2) = *(ptr1 + 7);
450 *(str + 3) = *ptr1;
451 *(str + 4) = *(ptr1 + 1);
452 *(str + 5) = *(ptr1 + 2);
453 *(str + 6) = *(ptr1 + 3);
454 *(str + 7) = *(ptr1 + 4);
455 *(str) = *(ptr1 + 5);
456 LCD_GLASS_Clear();
457 LCD_GLASS_DisplayString(str);
458 delay(ScrollSpeed);
459
460 *(str + 1) = *(ptr1 + 5);
461 *(str + 2) = *(ptr1 + 6);
462 *(str + 3) = *(ptr1 + 7);
463 *(str + 4) = *ptr1;
464 *(str + 5) = *(ptr1 + 1);
465 *(str + 6) = *(ptr1 + 2);
466 *(str + 7) = *(ptr1 + 3);
467 *(str) = *(ptr1 + 4);
468 LCD_GLASS_Clear();
469 LCD_GLASS_DisplayString(str);
470 delay(ScrollSpeed);
471
472 *(str + 1) = *(ptr1 + 4);
473 *(str + 2) = *(ptr1 + 5);
474 *(str + 3) = *(ptr1 + 6);
475 *(str + 4) = *(ptr1 + 7);
476 *(str + 5) = *ptr1;
477 *(str + 6) = *(ptr1 + 1);
478 *(str + 7) = *(ptr1 + 2);
479 *(str) = *(ptr1 + 3);
480 LCD_GLASS_Clear();
481 LCD_GLASS_DisplayString(str);
482 delay(ScrollSpeed);
483
484 *(str + 1) = *(ptr1 + 3);
485 *(str + 2) = *(ptr1 + 4);
486 *(str + 3) = *(ptr1 + 5);
487 *(str + 4) = *(ptr1 + 6);
488 *(str + 5) = *(ptr1 + 7);
489 *(str + 6) = *ptr1;
490 *(str + 7) = *(ptr1 + 1);
491 *(str) = *(ptr1 + 2);
492 LCD_GLASS_Clear();
493 LCD_GLASS_DisplayString(str);
494 delay(ScrollSpeed);
495
496 *(str + 1) = *(ptr1 + 2);
497 *(str + 2) = *(ptr1 + 3);
498 *(str + 3) = *(ptr1 + 4);
499 *(str + 4) = *(ptr1 + 5);
500 *(str + 5) = *(ptr1 + 6);
501 *(str + 6) = *(ptr1 + 7);
502 *(str + 7) = *ptr1;
503 *(str) = *(ptr1 + 1);
504 LCD_GLASS_Clear();
505 LCD_GLASS_DisplayString(str);
506 delay(ScrollSpeed);
507
508 *(str + 1) = *(ptr1 + 1);
509 *(str + 2) = *(ptr1 + 2);
510 *(str + 3) = *(ptr1 + 3);
511 *(str + 4) = *(ptr1 + 4);
512 *(str + 5) = *(ptr1 + 5);
513 *(str + 6) = *(ptr1 + 6);
514 *(str + 7) = *(ptr1 + 7);
515 *(str) = *(ptr1);
516 LCD_GLASS_Clear();
517 LCD_GLASS_DisplayString(str);
518 delay(ScrollSpeed);
519 }
520 }
521
522 /**
523 * @brief This function Clear a char in the LCD RAM.
524 * @param position: Position in the LCD of the caracter to write.
525 * This parameter can be any value in range [0:7].
526 * @retval None
527 */
528 void LCD_GLASS_ClearChar(uint8_t position)
529 {
530 switch (position)
531 {
532 case 7:
533 /*!< Clear the corresponding segments (SEG0, SEG1, SEG2, SEG3) */
534 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFFFFFFF0);
535 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFFFFFFF0);
536 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFFFFFFF0);
537 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFFFFFFF0);
538 break;
539
540 case 6:
541 /*!< Clear the corresponding segments (SEG4, SEG5, SEG6, SEG10) */
542 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFFFFFB8F);
543 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFFFFFB8F);
544 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFFFFFB8F);
545 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFFFFFB8F);
546 break;
547
548 case 5:
549 /*!< Clear the corresponding segments (SEG11, SEG16, SEG18, SEG19) */
550 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFFF2F7FF);
551 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFFF2F7FF);
552 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFFF2F7FF);
553 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFFF2F7FF);
554 break;
555
556 case 4:
557 /*!< Clear the corresponding segments (SEG20, SEG21, SEG22, SEG23) */
558 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0xFF0FFFFF);
559 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0xFF0FFFFF);
560 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0xFF0FFFFF);
561 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0xFF0FFFFF);
562 break;
563
564 case 3:
565 /*!< Clear the corresponding segments (SEG28, SEG29, SEG30, SEG31) */
566 LCD->RAM[LCD_RAMRegister_0] &= (uint32_t)(0x0FFFFFFF);
567 LCD->RAM[LCD_RAMRegister_2] &= (uint32_t)(0x0FFFFFFF);
568 LCD->RAM[LCD_RAMRegister_4] &= (uint32_t)(0x0FFFFFFF);
569 LCD->RAM[LCD_RAMRegister_6] &= (uint32_t)(0x0FFFFFFF);
570 break;
571
572 case 2:
573 /*!< Clear the corresponding segments (SEG32, SEG33, SEG34, SEG35) */
574 LCD->RAM[LCD_RAMRegister_1] &= (uint32_t)(0xFFFFFFF0);
575 LCD->RAM[LCD_RAMRegister_3] &= (uint32_t)(0xFFFFFFF0);
576 LCD->RAM[LCD_RAMRegister_5] &= (uint32_t)(0xFFFFFFF0);
577 LCD->RAM[LCD_RAMRegister_7] &= (uint32_t)(0xFFFFFFF0);
578 break;
579
580 case 1:
581 /*!< Clear the corresponding segments (SEG36, SEG37, SEG38, SEG39) */
582 LCD->RAM[LCD_RAMRegister_1] &= (uint32_t)(0xFFFFFF0F);
583 LCD->RAM[LCD_RAMRegister_3] &= (uint32_t)(0xFFFFFF0F);
584 LCD->RAM[LCD_RAMRegister_5] &= (uint32_t)(0xFFFFFF0F);
585 LCD->RAM[LCD_RAMRegister_7] &= (uint32_t)(0xFFFFFF0F);
586 break;
587
588 case 0:
589 /*!< Clear the corresponding segments (SEG40, SEG41, SEG42, SEG43) */
590 LCD->RAM[LCD_RAMRegister_1] &= (uint32_t)(0xFFFFF0FF);
591 LCD->RAM[LCD_RAMRegister_3] &= (uint32_t)(0xFFFFF0FF);
592 LCD->RAM[LCD_RAMRegister_5] &= (uint32_t)(0xFFFFF0FF);
593 LCD->RAM[LCD_RAMRegister_7] &= (uint32_t)(0xFFFFF0FF);
594 break;
595 }
596 }
597
598 /**
599 * @brief This function Clear the whole LCD RAM.
600 * @param None
601 * @retval None
602 */
603 void LCD_GLASS_Clear(void)
604 {
605 uint32_t counter = 0;
606
607 for (counter = 0; counter < 0x0F; counter++)
608 {
609 LCD->RAM[counter] = (uint32_t)0x00;
610 }
611 }
612
613 /**
614 * @brief Converts an ascii char to an LCD digit.
615 * @param c: Char to display.
616 * @param point: A point to add in front of char.
617 * This parameter can be one of the following values:
618 * @arg POINT_OFF : No point to add in front of char.
619 * @arg POINT_ON : Add a point in front of char.
620 * @param apostrophe: Flag indicating if a apostrophe has to be add in front
621 * of displayed character.
622 * This parameter can be one of the following values:
623 * @arg APOSTROPHE_OFF : No apostrophe to add in back of char.
624 * @arg APOSTROPHE_ON : Add an apostrophe in back of char.
625 * @retval None
626 */
627 static void Convert(uint8_t* c, Point_Typedef point, Apostrophe_Typedef apostrophe)
628 {
629 uint16_t ch = 0, tmp = 0;
630 uint8_t i = 0;
631
632 /*!< The character c is a letter in upper case*/
633 if ((*c < 0x5B) & (*c > 0x40))
634 {
635 ch = LetterMap[*c - 0x41];
636 }
637
638 /*!< The character c is a number*/
639 if ((*c < 0x3A) & (*c > 0x2F))
640 {
641 ch = NumberMap[*c - 0x30];
642 }
643
644 /*!< The character c is a space character */
645 if (*c == 0x20)
646 {
647 ch =0x00;
648 }
649
650 /*!< Set the DP seg in the character that can be displayed if the point is on */
651 if (point == POINT_ON)
652 {
653 ch |= 0x0004;
654 }
655
656 /*!< Set the X seg in the character that can be displayed if the apostrophe is on */
657 if (apostrophe == APOSTROPHE_ON)
658 {
659 ch |= 0x1000;
660 }
661
662 for (i = 0; i < 4; i++)
663 {
664 tmp = ch & mask[i];
665 digit[i] =(uint8_t)(tmp >> shift[i]);
666 }
667 }
668
669 /**
670 * @brief Configures the LCD Segments and Coms GPIOs.
671 * @param None
672 * @retval None
673 */
674 static void LCD_GPIOConfig(void)
675 {
676 GPIO_InitTypeDef GPIO_InitStructure;
677
678 /*!< Enable GPIOA, GPIOB, GPIOC, GPIOD and GPIOE AHB Clocks */
679 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC
680 | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOE, ENABLE);
681
682 /*!< Connect PA.08 to LCD COM0 */
683 GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_LCD);
684
685 /*!< Connect PA.09 to LCD COM1 */
686 GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_LCD);
687
688 /*!< Connect PA.10 to LCD COM2 */
689 GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_LCD);
690
691 /*!< Connect PB.09 to LCD COM3 */
692 GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_LCD);
693
694 /*!< Connect PA.01 to LCD SEG0 */
695 GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_LCD);
696
697 /*!< Connect PA.02 to LCD SEG1 */
698 GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_LCD);
699
700 /*!< Connect PA.03 to LCD SEG2 */
701 GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_LCD);
702
703 /*!< Connect PA.06 to LCD SEG3 */
704 GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_LCD);
705
706 /*!< Connect PA.07 to LCD SEG4 */
707 GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_LCD);
708
709 /*!< Connect PB.00 to LCD SEG5 */
710 GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_LCD);
711
712 /*!< Connect PB.01 to LCD SEG6 */
713 GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_LCD);
714
715 /*!< Connect PB.10 to LCD SEG10 */
716 GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_LCD);
717
718 /*!< Connect PB.11 to LCD SEG11 */
719 GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_LCD);
720
721 /*!< Connect PB.08 to LCD SEG16 */
722 GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_LCD);
723
724 /*!< Connect PC.00 to LCD SEG18 */
725 GPIO_PinAFConfig(GPIOC, GPIO_PinSource0, GPIO_AF_LCD);
726
727 /*!< Connect PC.01 to LCD SEG19 */
728 GPIO_PinAFConfig(GPIOC, GPIO_PinSource1, GPIO_AF_LCD);
729
730 /*!< Connect PC.02 to LCD SEG20 */
731 GPIO_PinAFConfig(GPIOC, GPIO_PinSource2, GPIO_AF_LCD);
732
733 /*!< Connect PC.03 to LCD SEG21 */
734 GPIO_PinAFConfig(GPIOC, GPIO_PinSource3, GPIO_AF_LCD);
735
736 /*!< Connect PC.04 to LCD SEG22 */
737 GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_LCD);
738
739 /*!< Connect PC.05 to LCD SEG23 */
740 GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_LCD);
741
742 /*!< Connect PD.08 to LCD SEG28 */
743 GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_LCD);
744
745 /*!< Connect PD.09 to LCD SEG29 */
746 GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_LCD);
747
748 /*!< Connect PD.10 to LCD SEG30 */
749 GPIO_PinAFConfig(GPIOD, GPIO_PinSource10, GPIO_AF_LCD);
750
751 /*!< Connect PD.11 to LCD SEG31 */
752 GPIO_PinAFConfig(GPIOD, GPIO_PinSource11, GPIO_AF_LCD);
753
754 /*!< Connect PD.12 to LCD SEG32 */
755 GPIO_PinAFConfig(GPIOD, GPIO_PinSource12, GPIO_AF_LCD);
756
757 /*!< Connect PD.13 to LCD SEG33 */
758 GPIO_PinAFConfig(GPIOD, GPIO_PinSource13, GPIO_AF_LCD);
759
760 /*!< Connect PD.14 to LCD SEG34 */
761 GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_LCD);
762
763 /*!< Connect PD.15 to LCD SEG35 */
764 GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_LCD);
765
766 /*!< Connect PE.00 to LCD SEG36 */
767 GPIO_PinAFConfig(GPIOE, GPIO_PinSource0, GPIO_AF_LCD);
768
769 /*!< Connect PE.01 to LCD SEG37 */
770 GPIO_PinAFConfig(GPIOE, GPIO_PinSource1, GPIO_AF_LCD);
771
772 /*!< Connect PE.02 to LCD SEG38 */
773 GPIO_PinAFConfig(GPIOE, GPIO_PinSource2, GPIO_AF_LCD);
774
775 /*!< Connect PE.03 to LCD SEG39 */
776 GPIO_PinAFConfig(GPIOE, GPIO_PinSource3, GPIO_AF_LCD);
777
778 /*!< Connect PC.10 to LCD SEG40 */
779 GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_LCD);
780
781 /*!< Connect PC.11 to LCD SEG41 */
782 GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_LCD);
783
784 /*!< Connect PC.12 to LCD SEG42 */
785 GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_LCD);
786
787 /*!< Connect PD.02 to LCD SEG43 */
788 GPIO_PinAFConfig(GPIOD, GPIO_PinSource2, GPIO_AF_LCD);
789
790 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 | \
791 GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
792 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
793 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
794 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
795 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
796 GPIO_Init(GPIOA, &GPIO_InitStructure);
797
798 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | \
799 GPIO_Pin_10 | GPIO_Pin_11;
800 GPIO_Init(GPIOB, &GPIO_InitStructure);
801
802 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | \
803 GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_10 | GPIO_Pin_11 | \
804 GPIO_Pin_12;
805 GPIO_Init(GPIOC, &GPIO_InitStructure);
806
807 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | \
808 GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | \
809 GPIO_Pin_15;
810 GPIO_Init(GPIOD, &GPIO_InitStructure);
811
812 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
813 GPIO_Init(GPIOE, &GPIO_InitStructure);
814 }
815
816 /**
817 * @brief Inserts a delay time.
818 * @param nCount: specifies the delay time length.
819 * @retval None
820 */
821 static void delay(__IO uint32_t nCount)
822 {
823 __IO uint32_t index = 0;
824 for(index = (0xFF * nCount); index != 0; index--)
825 {
826 }
827 }
828
829 /**
830 * @}
831 */
832
833
834 /**
835 * @}
836 */
837
838 /**
839 * @}
840 */
841
842 /**
843 * @}
844 */
845
846
847 /**
848 * @}
849 */
850
851 /**
852 * @}
853 */
854
855 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/