Merge pull request #93 from zyp/master
[fw/stlink] / example / libs_stm / src / stm32l1xx / stm32l1xx_lcd.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_lcd.c\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0\r
6   * @date    31-December-2010\r
7   * @brief   This file provides firmware functions to manage the following \r
8   *          functionalities of the LCD controller (LCD) peripheral:           \r
9   *           - Initialization and configuration\r
10   *           - LCD RAM memory write\r
11   *           - Interrupts and flags management   \r
12   *           \r
13   *  @verbatim\r
14   *      \r
15   *          ===================================================================      \r
16   *                                    LCD Clock\r
17   *          ===================================================================    \r
18   *          LCDCLK is the same as RTCCLK. \r
19   *          To configure the RTCCLK/LCDCLK, proceed as follows:\r
20   *            - Enable the Power Controller (PWR) APB1 interface clock using the\r
21   *              RCC_APB1PeriphClockCmd() function.\r
22   *            - Enable access to RTC domain using the PWR_RTCAccessCmd() function.\r
23   *            - Select the RTC clock source using the RCC_RTCCLKConfig() function.    \r
24   *          \r
25   *          The frequency generator allows you to achieve various LCD frame rates \r
26   *          starting from an LCD input clock frequency (LCDCLK) which can vary \r
27   *          from 32 kHz up to 1 MHz.\r
28   *            \r
29   *          ===================================================================      \r
30   *                                  LCD and low power modes\r
31   *          =================================================================== \r
32   *          The LCD still active during STOP mode.\r
33   *              \r
34   *          ===================================================================\r
35   *                                 How to use this driver\r
36   *          =================================================================== \r
37   *          1. Enable LCD clock using RCC_APB1PeriphClockCmd(RCC_APB1Periph_LCD, ENABLE) function\r
38   *            \r
39   *          2. Configure the LCD prescaler, divider, duty, bias and voltage source\r
40   *             using LCD_Init() function     \r
41   *            \r
42   *          3. Optionally you can enable/configure:\r
43   *              -  LCD High Drive using the LCD_HighDriveCmd() function\r
44   *              -  LCD High Drive using the LCD_MuxSegmentCmd() function  \r
45   *              -  LCD Pulse ON Duration using the LCD_PulseOnDurationConfig() function\r
46   *              -  LCD Dead Time using the LCD_DeadTimeConfig() function  \r
47   *              -  The LCD Blink mode and frequency using the LCD_BlinkConfig() function\r
48   *              -  The LCD Contrast using the LCD_ContrastConfig() function  \r
49   *\r
50   *          4. Call the LCD_WaitForSynchro() function to wait for LCD_FCR register\r
51   *             synchronization.\r
52   *           \r
53   *          5. Call the LCD_Cmd() to enable the LCD controller\r
54   *          \r
55   *          6. Wait until the LCD Controller status is enabled and the step-up\r
56   *             converter is ready using the LCD_GetFlagStatus() and\r
57   *             LCD_FLAG_ENS and LCD_FLAG_RDY flags.               \r
58   *  \r
59   *          7. Write to the LCD RAM memory using the LCD_Write() function.\r
60   *          \r
61   *          8. Request an update display using the LCD_UpdateDisplayRequest()\r
62   *             function.\r
63   *             \r
64   *          9. Wait until the update display is finished by checking the UDD\r
65   *             flag status using the LCD_GetFlagStatus(LCD_FLAG_UDD)\r
66   *                                  \r
67   *                     \r
68   *  @endverbatim\r
69   *           \r
70   ******************************************************************************\r
71   * @attention\r
72   *\r
73   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
74   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
75   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
76   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
77   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
78   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
79   *\r
80   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
81   ******************************************************************************  \r
82   */ \r
83 \r
84 /* Includes ------------------------------------------------------------------*/\r
85 #include "stm32l1xx_lcd.h"\r
86 #include "stm32l1xx_rcc.h"\r
87 \r
88 /** @addtogroup STM32L1xx_StdPeriph_Driver\r
89   * @{\r
90   */\r
91 \r
92 /** @defgroup LCD \r
93   * @brief LCD driver modules\r
94   * @{\r
95   */\r
96 \r
97 /* Private typedef -----------------------------------------------------------*/\r
98 /* Private define ------------------------------------------------------------*/\r
99 /* ------------ LCD registers bit address in the alias region --------------- */\r
100 #define LCD_OFFSET                   (LCD_BASE - PERIPH_BASE)\r
101 \r
102 /* --- CR Register ---*/\r
103 \r
104 /* Alias word address of LCDEN bit */\r
105 #define CR_OFFSET                    (LCD_OFFSET + 0x00)\r
106 #define LCDEN_BitNumber              0x00\r
107 #define CR_LCDEN_BB                  (PERIPH_BB_BASE + (CR_OFFSET * 32) + (LCDEN_BitNumber * 4))\r
108 \r
109 /* Alias word address of MUX_SEG bit */\r
110 #define MUX_SEG_BitNumber            0x07\r
111 #define CR_MUX_SEG_BB                (PERIPH_BB_BASE + (CR_OFFSET * 32) + (MUX_SEG_BitNumber * 4))\r
112 \r
113 \r
114 /* --- FCR Register ---*/\r
115 \r
116 /* Alias word address of HD bit */\r
117 #define FCR_OFFSET                   (LCD_OFFSET + 0x04)\r
118 #define HD_BitNumber                 0x00\r
119 #define FCR_HD_BB                    (PERIPH_BB_BASE + (FCR_OFFSET * 32) + (HD_BitNumber * 4))\r
120 \r
121 /* --- SR Register ---*/\r
122 \r
123 /* Alias word address of UDR bit */\r
124 #define SR_OFFSET                    (LCD_OFFSET + 0x08)\r
125 #define UDR_BitNumber                0x02\r
126 #define SR_UDR_BB                    (PERIPH_BB_BASE + (SR_OFFSET * 32) + (UDR_BitNumber * 4))\r
127 \r
128 #define FCR_MASK                     ((uint32_t)0xFC03FFFF)  /* LCD FCR Mask */\r
129 #define CR_MASK                      ((uint32_t)0xFFFFFF81)  /* LCD CR Mask */\r
130 #define PON_MASK                     ((uint32_t)0xFFFFFF8F)  /* LCD PON Mask */\r
131 #define DEAD_MASK                    ((uint32_t)0xFFFFFC7F)  /* LCD DEAD Mask */\r
132 #define BLINK_MASK                   ((uint32_t)0xFFFC1FFF)  /* LCD BLINK Mask */\r
133 #define CONTRAST_MASK                ((uint32_t)0xFFFFE3FF)  /* LCD CONTRAST Mask */\r
134 \r
135 /* Private macro -------------------------------------------------------------*/\r
136 /* Private variables ---------------------------------------------------------*/\r
137 /* Private function prototypes -----------------------------------------------*/\r
138 /* Private functions ---------------------------------------------------------*/\r
139 \r
140 /** @defgroup LCD_Private_Functions\r
141   * @{\r
142   */\r
143 \r
144 /** @defgroup LCD_Group1 Initialization and Configuration functions\r
145  *  @brief   Initialization and Configuration functions \r
146  *\r
147 @verbatim   \r
148  ===============================================================================\r
149                     Initialization and Configuration functions\r
150  ===============================================================================  \r
151 \r
152 @endverbatim\r
153   * @{\r
154   */\r
155 \r
156 /**\r
157   * @brief  Deinitializes the LCD peripheral registers to their default reset \r
158   *         values.\r
159   * @param  None\r
160   * @retval None\r
161   */\r
162 void LCD_DeInit(void)\r
163 {\r
164   /* Enable LCD reset state */\r
165   RCC_APB1PeriphResetCmd(RCC_APB1Periph_LCD, ENABLE);\r
166   /* Release LCD from reset state */\r
167   RCC_APB1PeriphResetCmd(RCC_APB1Periph_LCD, DISABLE);\r
168 }\r
169 \r
170 /**\r
171   * @brief  Initializes the LCD peripheral according to the specified parameters \r
172   *         in the LCD_InitStruct.\r
173   * @note   This function can be used only when the LCD is disabled.  \r
174   * @param  LCD_InitStruct: pointer to a LCD_InitTypeDef structure that contains \r
175   *         the configuration information for the specified LCD peripheral.\r
176   * @retval None\r
177   */\r
178 void LCD_Init(LCD_InitTypeDef* LCD_InitStruct)\r
179 {\r
180   /* Check function parameters */\r
181   assert_param(IS_LCD_PRESCALER(LCD_InitStruct->LCD_Prescaler));\r
182   assert_param(IS_LCD_DIVIDER(LCD_InitStruct->LCD_Divider));\r
183   assert_param(IS_LCD_DUTY(LCD_InitStruct->LCD_Duty));\r
184   assert_param(IS_LCD_BIAS(LCD_InitStruct->LCD_Bias));  \r
185   assert_param(IS_LCD_VOLTAGE_SOURCE(LCD_InitStruct->LCD_VoltageSource));\r
186 \r
187   LCD->FCR &= (uint32_t)FCR_MASK;\r
188   LCD->FCR |= (uint32_t)(LCD_InitStruct->LCD_Prescaler | LCD_InitStruct->LCD_Divider);\r
189 \r
190   LCD_WaitForSynchro();\r
191 \r
192   LCD->CR &= (uint32_t)CR_MASK;\r
193   LCD->CR |= (uint32_t)(LCD_InitStruct->LCD_Duty | LCD_InitStruct->LCD_Bias | \\r
194                         LCD_InitStruct->LCD_VoltageSource);\r
195 \r
196 }\r
197 \r
198 /**\r
199   * @brief  Fills each LCD_InitStruct member with its default value.\r
200   * @param  LCD_InitStruct: pointer to a LCD_InitTypeDef structure which will \r
201   *         be initialized.\r
202   * @retval None\r
203   */\r
204 void LCD_StructInit(LCD_InitTypeDef* LCD_InitStruct)\r
205 {\r
206 /*--------------- Reset LCD init structure parameters values -----------------*/\r
207   LCD_InitStruct->LCD_Prescaler = LCD_Prescaler_1; /*!< Initialize the LCD_Prescaler member */\r
208   \r
209   LCD_InitStruct->LCD_Divider = LCD_Divider_16; /*!< Initialize the LCD_Divider member */\r
210   \r
211   LCD_InitStruct->LCD_Duty = LCD_Duty_Static; /*!< Initialize the LCD_Duty member */\r
212   \r
213   LCD_InitStruct->LCD_Bias = LCD_Bias_1_4; /*!< Initialize the LCD_Bias member */\r
214   \r
215   LCD_InitStruct->LCD_VoltageSource = LCD_VoltageSource_Internal; /*!< Initialize the LCD_VoltageSource member */\r
216 }\r
217 \r
218 /**\r
219   * @brief  Enables or disables the LCD Controller.\r
220   * @param  NewState: new state of the LCD peripheral.\r
221   *   This parameter can be: ENABLE or DISABLE.\r
222   * @retval None\r
223   */\r
224 void LCD_Cmd(FunctionalState NewState)\r
225 {\r
226   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
227 \r
228   /* Check the parameters */\r
229   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
230 \r
231   *(__IO uint32_t *) CR_LCDEN_BB = (uint32_t)NewState;\r
232 }\r
233 \r
234 /**\r
235   * @brief  Waits until the LCD FCR register is synchronized in the LCDCLK domain.\r
236   *   This function must be called after any write operation to LCD_FCR register.\r
237   * @param  None\r
238   * @retval None\r
239   */\r
240 void LCD_WaitForSynchro(void)\r
241 {\r
242   /* Loop until FCRSF flag is set */\r
243   while ((LCD->SR & LCD_FLAG_FCRSF) == (uint32_t)RESET)\r
244   {\r
245   }\r
246 }\r
247 \r
248 /**\r
249   * @brief  Enables or disables the low resistance divider. Displays with high \r
250   *         internal resistance may need a longer drive time to achieve \r
251   *         satisfactory contrast. This function is useful in this case if some \r
252   *         additional power consumption can be tolerated.\r
253   * @note   When this mode is enabled, the PulseOn Duration (PON) have to be \r
254   *         programmed to 1/CK_PS (LCD_PulseOnDuration_1).    \r
255   * @param  NewState: new state of the low resistance divider.\r
256   *   This parameter can be: ENABLE or DISABLE.\r
257   * @retval None\r
258   */\r
259 void LCD_HighDriveCmd(FunctionalState NewState)\r
260 {\r
261   /* Check the parameters */\r
262   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
263 \r
264   *(__IO uint32_t *) FCR_HD_BB = (uint32_t)NewState;\r
265 }\r
266 \r
267 /**\r
268   * @brief  Enables or disables the Mux Segment.\r
269   * @note   This function can be used only when the LCD is disabled.  \r
270   * @param  NewState: new state of the Mux Segment.\r
271   *   This parameter can be: ENABLE or DISABLE.\r
272   * @retval None\r
273   */\r
274 void LCD_MuxSegmentCmd(FunctionalState NewState)\r
275 {\r
276   /* Check the parameters */\r
277   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
278 \r
279   *(__IO uint32_t *) CR_MUX_SEG_BB = (uint32_t)NewState;\r
280 }\r
281 \r
282 /**\r
283   * @brief  Configures the LCD pulses on duration.\r
284   * @param  LCD_PulseOnDuration: specifies the LCD pulse on duration in terms of \r
285   *         CK_PS (prescaled LCD clock period) pulses.\r
286   *   This parameter can be one of the following values:\r
287   *     @arg LCD_PulseOnDuration_0: 0 pulse\r
288   *     @arg LCD_PulseOnDuration_1: Pulse ON duration = 1/CK_PS\r
289   *     @arg LCD_PulseOnDuration_2: Pulse ON duration = 2/CK_PS\r
290   *     @arg LCD_PulseOnDuration_3: Pulse ON duration = 3/CK_PS\r
291   *     @arg LCD_PulseOnDuration_4: Pulse ON duration = 4/CK_PS\r
292   *     @arg LCD_PulseOnDuration_5: Pulse ON duration = 5/CK_PS\r
293   *     @arg LCD_PulseOnDuration_6: Pulse ON duration = 6/CK_PS\r
294   *     @arg LCD_PulseOnDuration_7: Pulse ON duration = 7/CK_PS\r
295   * @retval None\r
296   */\r
297 void LCD_PulseOnDurationConfig(uint32_t LCD_PulseOnDuration)\r
298 {\r
299   /* Check the parameters */\r
300   assert_param(IS_LCD_PULSE_ON_DURATION(LCD_PulseOnDuration));\r
301 \r
302   LCD->FCR &= (uint32_t)PON_MASK;\r
303   LCD->FCR |= (uint32_t)(LCD_PulseOnDuration);\r
304 }\r
305 \r
306 /**\r
307   * @brief  Configures the LCD dead time.\r
308   * @param  LCD_DeadTime: specifies the LCD dead time.\r
309   *   This parameter can be one of the following values:\r
310   *     @arg LCD_DeadTime_0: No dead Time\r
311   *     @arg LCD_DeadTime_1: One Phase between different couple of Frame\r
312   *     @arg LCD_DeadTime_2: Two Phase between different couple of Frame\r
313   *     @arg LCD_DeadTime_3: Three Phase between different couple of Frame\r
314   *     @arg LCD_DeadTime_4: Four Phase between different couple of Frame\r
315   *     @arg LCD_DeadTime_5: Five Phase between different couple of Frame\r
316   *     @arg LCD_DeadTime_6: Six Phase between different couple of Frame \r
317   *     @arg LCD_DeadTime_7: Seven Phase between different couple of Frame\r
318   * @retval None\r
319   */\r
320 void LCD_DeadTimeConfig(uint32_t LCD_DeadTime)\r
321 {\r
322   /* Check the parameters */\r
323   assert_param(IS_LCD_DEAD_TIME(LCD_DeadTime));\r
324 \r
325   LCD->FCR &= (uint32_t)DEAD_MASK;\r
326   LCD->FCR |= (uint32_t)(LCD_DeadTime);\r
327 }\r
328 \r
329 /**\r
330   * @brief  Configures the LCD Blink mode and Blink frequency.\r
331   * @param  LCD_BlinkMode: specifies the LCD blink mode.\r
332   *   This parameter can be one of the following values:\r
333   *     @arg LCD_BlinkMode_Off:           Blink disabled\r
334   *     @arg LCD_BlinkMode_SEG0_COM0:     Blink enabled on SEG[0], COM[0] (1 pixel)\r
335   *     @arg LCD_BlinkMode_SEG0_AllCOM:   Blink enabled on SEG[0], all COM (up to 8 \r
336   *                                       pixels according to the programmed duty)\r
337   *     @arg LCD_BlinkMode_AllSEG_AllCOM: Blink enabled on all SEG and all COM \r
338   *                                       (all pixels)\r
339   * @param  LCD_BlinkFrequency: specifies the LCD blink frequency.\r
340   *   This parameter can be one of the following values:\r
341   *     @arg LCD_BlinkFrequency_Div8:    The Blink frequency = fLcd/8\r
342   *     @arg LCD_BlinkFrequency_Div16:   The Blink frequency = fLcd/16\r
343   *     @arg LCD_BlinkFrequency_Div32:   The Blink frequency = fLcd/32\r
344   *     @arg LCD_BlinkFrequency_Div64:   The Blink frequency = fLcd/64 \r
345   *     @arg LCD_BlinkFrequency_Div128:  The Blink frequency = fLcd/128\r
346   *     @arg LCD_BlinkFrequency_Div256:  The Blink frequency = fLcd/256\r
347   *     @arg LCD_BlinkFrequency_Div512:  The Blink frequency = fLcd/512\r
348   *     @arg LCD_BlinkFrequency_Div1024: The Blink frequency = fLcd/1024\r
349   * @retval None\r
350   */\r
351 void LCD_BlinkConfig(uint32_t LCD_BlinkMode, uint32_t LCD_BlinkFrequency)\r
352 {\r
353   /* Check the parameters */\r
354   assert_param(IS_LCD_BLINK_MODE(LCD_BlinkMode));\r
355   assert_param(IS_LCD_BLINK_FREQUENCY(LCD_BlinkFrequency));\r
356   \r
357   LCD->FCR &= (uint32_t)BLINK_MASK;\r
358   LCD->FCR |= (uint32_t)(LCD_BlinkMode | LCD_BlinkFrequency);\r
359 }\r
360 \r
361 /**\r
362   * @brief  Configures the LCD Contrast.\r
363   * @param  LCD_Contrast: specifies the LCD Contrast.\r
364   *   This parameter can be one of the following values:\r
365   *     @arg LCD_Contrast_Level_0: Maximum Voltage = 2.60V\r
366   *     @arg LCD_Contrast_Level_1: Maximum Voltage = 2.73V\r
367   *     @arg LCD_Contrast_Level_2: Maximum Voltage = 2.86V\r
368   *     @arg LCD_Contrast_Level_3: Maximum Voltage = 2.99V\r
369   *     @arg LCD_Contrast_Level_4: Maximum Voltage = 3.12V\r
370   *     @arg LCD_Contrast_Level_5: Maximum Voltage = 3.25V\r
371   *     @arg LCD_Contrast_Level_6: Maximum Voltage = 3.38V\r
372   *     @arg LCD_Contrast_Level_7: Maximum Voltage = 3.51V\r
373   * @retval None\r
374   */\r
375 void LCD_ContrastConfig(uint32_t LCD_Contrast)\r
376 {\r
377   /* Check the parameters */\r
378   assert_param(IS_LCD_CONTRAST(LCD_Contrast));\r
379 \r
380   LCD->FCR &= (uint32_t)CONTRAST_MASK;\r
381   LCD->FCR |= (uint32_t)(LCD_Contrast);\r
382 }\r
383 \r
384 /**\r
385   * @}\r
386   */\r
387 \r
388 /** @defgroup LCD_Group2  LCD RAM memory write functions\r
389  *  @brief    LCD RAM memory write functions \r
390  *\r
391 @verbatim   \r
392  ===============================================================================\r
393                            LCD RAM memory write functions\r
394  ===============================================================================  \r
395 \r
396  Using its double buffer memory the LCD controller ensures the coherency of the \r
397  displayed information without having to use interrupts to control LCD_RAM \r
398  modification.\r
399  The application software can access the first buffer level (LCD_RAM) through \r
400  the APB interface. Once it has modified the LCD_RAM, it sets the UDR flag in \r
401  the LCD_SR register using the LCD_UpdateDisplayRequest() function.\r
402  This UDR flag (update display request) requests the updated information to be \r
403  moved into the second buffer level (LCD_DISPLAY).\r
404  This operation is done synchronously with the frame (at the beginning of the \r
405  next frame), until the update is completed, the LCD_RAM is write protected and \r
406  the UDR flag stays high.\r
407  Once the update is completed another flag (UDD - Update Display Done) is set and\r
408  generates an interrupt if the UDDIE bit in the LCD_FCR register is set.\r
409  The time it takes to update LCD_DISPLAY is, in the worst case, one odd and one \r
410  even frame.\r
411  The update will not occur (UDR = 1 and UDD = 0) until the display is \r
412  enabled (LCDEN = 1).\r
413 \r
414 @endverbatim\r
415   * @{\r
416   */\r
417 \r
418 /**\r
419   * @brief  Writes a word in the specific LCD RAM.\r
420   * @param  LCD_RAMRegister: specifies the LCD Contrast.\r
421   *   This parameter can be one of the following values:\r
422   *     @arg LCD_RAMRegister_0: LCD RAM Register 0\r
423   *     @arg LCD_RAMRegister_1: LCD RAM Register 1\r
424   *     @arg LCD_RAMRegister_2: LCD RAM Register 2\r
425   *     @arg LCD_RAMRegister_3: LCD RAM Register 3\r
426   *     @arg LCD_RAMRegister_4: LCD RAM Register 4\r
427   *     @arg LCD_RAMRegister_5: LCD RAM Register 5\r
428   *     @arg LCD_RAMRegister_6: LCD RAM Register 6 \r
429   *     @arg LCD_RAMRegister_7: LCD RAM Register 7  \r
430   *     @arg LCD_RAMRegister_8: LCD RAM Register 8\r
431   *     @arg LCD_RAMRegister_9: LCD RAM Register 9\r
432   *     @arg LCD_RAMRegister_10: LCD RAM Register 10\r
433   *     @arg LCD_RAMRegister_11: LCD RAM Register 11\r
434   *     @arg LCD_RAMRegister_12: LCD RAM Register 12 \r
435   *     @arg LCD_RAMRegister_13: LCD RAM Register 13 \r
436   *     @arg LCD_RAMRegister_14: LCD RAM Register 14 \r
437   *     @arg LCD_RAMRegister_15: LCD RAM Register 15 \r
438   * @param  LCD_Data: specifies LCD Data Value to be written.\r
439   * @retval None\r
440   */\r
441 void LCD_Write(uint32_t LCD_RAMRegister, uint32_t LCD_Data)\r
442 {\r
443   /* Check the parameters */\r
444   assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister));\r
445 \r
446   /* Copy data bytes to RAM register */\r
447   LCD->RAM[LCD_RAMRegister] = (uint32_t)LCD_Data;\r
448 }\r
449 \r
450 /**\r
451   * @brief  Enables the Update Display Request.\r
452   * @note   Each time software modifies the LCD_RAM it must set the UDR bit to \r
453   *         transfer the updated data to the second level buffer. \r
454   *         The UDR bit stays set until the end of the update and during this \r
455   *         time the LCD_RAM is write protected. \r
456   * @note   When the display is disabled, the update is performed for all \r
457   *         LCD_DISPLAY locations.\r
458   *         When the display is enabled, the update is performed only for locations \r
459   *         for which commons are active (depending on DUTY). For example if \r
460   *         DUTY = 1/2, only the LCD_DISPLAY of COM0 and COM1 will be updated.    \r
461   * @param  None\r
462   * @retval None\r
463   */\r
464 void LCD_UpdateDisplayRequest(void)\r
465 {\r
466   *(__IO uint32_t *) SR_UDR_BB = (uint32_t)0x01;\r
467 }\r
468 \r
469 /**\r
470   * @}\r
471   */\r
472 \r
473 /** @defgroup LCD_Group3 Interrupts and flags management functions\r
474  *  @brief   Interrupts and flags management functions \r
475  *\r
476 @verbatim   \r
477  ===============================================================================\r
478                    Interrupts and flags management functions\r
479  ===============================================================================  \r
480 \r
481 @endverbatim\r
482   * @{\r
483   */\r
484 \r
485 /**\r
486   * @brief  Enables or disables the specified LCD interrupts.\r
487   * @param  LCD_IT: specifies the LCD interrupts sources to be enabled or disabled.\r
488   *   This parameter can be any combination of the following values:\r
489   *     @arg LCD_IT_SOF: Start of Frame Interrupt\r
490   *     @arg LCD_IT_UDD: Update Display Done Interrupt\r
491   * @param NewState: new state of the specified LCD interrupts.\r
492   *   This parameter can be: ENABLE or DISABLE.\r
493   * @retval None\r
494   */\r
495 void LCD_ITConfig(uint32_t LCD_IT, FunctionalState NewState)\r
496 {\r
497   /* Check the parameters */\r
498   assert_param(IS_LCD_IT(LCD_IT));  \r
499   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
500   \r
501   if (NewState != DISABLE)\r
502   {\r
503     LCD->FCR |= LCD_IT;\r
504   }\r
505   else\r
506   {\r
507     LCD->FCR &= (uint32_t)~LCD_IT;\r
508   }\r
509 }\r
510 \r
511 /**\r
512   * @brief  Checks whether the specified LCD flag is set or not.\r
513   * @param  LCD_FLAG: specifies the flag to check.\r
514   *   This parameter can be one of the following values:\r
515   *     @arg LCD_FLAG_ENS: LCD Enabled flag. It indicates the LCD controller status.\r
516   *      @note  The ENS bit is set immediately when the LCDEN bit in the LCD_CR \r
517   *             goes from 0 to 1. On deactivation it reflects the real status of \r
518   *             LCD so it becomes 0 at the end of the last displayed frame.  \r
519   *     @arg LCD_FLAG_SOF: Start of Frame flag. This flag is set by hardware at \r
520   *       the beginning of a new frame, at the same time as the display data is \r
521   *       updated.\r
522   *     @arg LCD_FLAG_UDR: Update Display Request flag.\r
523   *     @arg LCD_FLAG_UDD: Update Display Done flag. \r
524   *     @arg LCD_FLAG_RDY: Step_up converter Ready flag. It indicates the status \r
525   *                        of the step-up converter.\r
526   *     @arg LCD_FLAG_FCRSF: LCD Frame Control Register Synchronization Flag. \r
527   *       This flag is set by hardware each time the LCD_FCR register is updated \r
528   *       in the LCDCLK domain.   \r
529   * @retval The new state of LCD_FLAG (SET or RESET).\r
530   */\r
531 FlagStatus LCD_GetFlagStatus(uint32_t LCD_FLAG)\r
532 {\r
533   FlagStatus bitstatus = RESET;\r
534   \r
535   /* Check the parameters */\r
536   assert_param(IS_LCD_GET_FLAG(LCD_FLAG));\r
537   \r
538   if ((LCD->SR & LCD_FLAG) != (uint32_t)RESET)\r
539   {\r
540     bitstatus = SET;\r
541   }\r
542   else\r
543   {\r
544     bitstatus = RESET;\r
545   }\r
546   return bitstatus;\r
547 }\r
548 \r
549 /**\r
550   * @brief  Clears the LCD's pending flags.\r
551   * @param  LCD_FLAG: specifies the flag to clear.\r
552   *   This parameter can be any combination of the following values:\r
553   *     @arg LCD_FLAG_SOF: Start of Frame Interrupt\r
554   *     @arg LCD_FLAG_UDD: Update Display Done Interrupt\r
555   * @retval None\r
556   */\r
557 void LCD_ClearFlag(uint32_t LCD_FLAG)\r
558 {\r
559   /* Check the parameters */\r
560   assert_param(IS_LCD_CLEAR_FLAG(LCD_FLAG));\r
561     \r
562   /* Clear the corresponding LCD flag */\r
563   LCD->CLR = (uint32_t)LCD_FLAG;\r
564 }\r
565 \r
566 /**\r
567   * @brief  Checks whether the specified RTC interrupt has occurred or not.\r
568   * @param  RTC_IT: specifies the RTC interrupts sources to check.\r
569   *   This parameter can be one of the following values:\r
570   *     @arg LCD_IT_SOF: Start of Frame Interrupt\r
571   *     @arg LCD_IT_UDD: Update Display Done Interrupt.\r
572   *     @note If the device is in STOP mode (PCLK not provided) UDD will not \r
573   *          generate an interrupt even if UDDIE = 1. \r
574   *          If the display is not enabled the UDD interrupt will never occur.    \r
575   * @retval The new state of the LCD_IT (SET or RESET).\r
576   */\r
577 ITStatus LCD_GetITStatus(uint32_t LCD_IT)\r
578 {\r
579   ITStatus bitstatus = RESET;\r
580   \r
581   /* Check the parameters */\r
582   assert_param(IS_LCD_GET_IT(LCD_IT));\r
583     \r
584   if ((LCD->SR & LCD_IT) != (uint16_t)RESET) \r
585   {\r
586     bitstatus = SET;\r
587   }\r
588   else\r
589   {\r
590     bitstatus = RESET;\r
591   }\r
592   \r
593   if (((LCD->FCR & LCD_IT) != (uint16_t)RESET) && (bitstatus != (uint32_t)RESET))\r
594   {\r
595     bitstatus = SET;\r
596   }\r
597   else\r
598   {\r
599     bitstatus = RESET;\r
600   }\r
601   return bitstatus;\r
602 }\r
603 \r
604 /**\r
605   * @brief  Clears the LCD's interrupt pending bits.\r
606   * @param  LCD_IT: specifies the interrupt pending bit to clear.\r
607   *   This parameter can be any combination of the following values:\r
608   *     @arg LCD_IT_SOF: Start of Frame Interrupt\r
609   *     @arg LCD_IT_UDD: Update Display Done Interrupt\r
610   * @retval None\r
611   */\r
612 void LCD_ClearITPendingBit(uint32_t LCD_IT)\r
613 {\r
614   /* Check the parameters */\r
615   assert_param(IS_LCD_IT(LCD_IT));\r
616   \r
617   /* Clear the corresponding LCD pending bit */\r
618   LCD->CLR = (uint32_t)LCD_IT;\r
619 }\r
620 \r
621 /**\r
622   * @}\r
623   */\r
624 \r
625 /**\r
626   * @}\r
627   */\r
628 \r
629 /**\r
630   * @}\r
631   */\r
632 \r
633 /**\r
634   * @}\r
635   */\r
636 \r
637 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r