STM8L15x Standard Peripherals Drivers
|
stm8l15x_lcd.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm8l15x_lcd.c 00004 * @author MCD Application Team 00005 * @version V1.5.0 00006 * @date 13-May-2011 00007 * @brief This file provides firmware functions to manage the following 00008 * functionalities of the LCD controller (LCD) peripheral: 00009 * - Initialization and configuration 00010 * - LCD RAM memory write 00011 * - Interrupts and flags management 00012 * 00013 * @verbatim 00014 * 00015 * =================================================================== 00016 * LCD Clock 00017 * =================================================================== 00018 * LCD has tow clock sources: 00019 * - RTCCLK divided by 2 used to generate LCD frame rate 00020 * - LCDCLK to used for LCD registers read/write access 00021 * 00022 * To configure the RTCCLK/LCDCLK, proceed as follows: 00023 * - Enable RTC clock using CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE) 00024 * function 00025 * - Enable LCD clock using CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE) 00026 * function 00027 * - Select the RTC clock source using the CLK_RTCClockConfig() function. 00028 * 00029 * =================================================================== 00030 * LCD and low power modes 00031 * =================================================================== 00032 * The LCD remains active during Active-halt, Wait, Low power run and 00033 * Low power wait modes unless disabled 00034 * 00035 * =================================================================== 00036 * How to use this driver 00037 * =================================================================== 00038 * 1. Enable RTC clock using CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE) function 00039 * 00040 * 2. Enable LCD clock using CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE) function 00041 * 00042 * 3. Select the RTC clock source using the CLK_RTCClockConfig() function. 00043 * 00044 * 4. Configure the LCD prescaler, divider, duty, bias and voltage source 00045 * using LCD_Init() function 00046 * 00047 * 5. Call the LCD_PortMaskConfig() function to assign the unused SEGx 00048 * (segment) and COMx (common) pins as standard general purpose IOs 00049 * 00050 * 6. Optionally you can enable/configure: 00051 * - LCD High Drive using the LCD_HighDriveCmd() function 00052 * - LCD Pulse ON Duration using the LCD_PulseOnDurationConfig() function 00053 * - LCD Dead Time using the LCD_DeadTimeConfig() function 00054 * - The LCD Blink mode and frequency using the LCD_BlinkConfig() function 00055 * - The LCD Contrast using the LCD_ContrastConfig() function 00056 * 00057 * 7. Call the LCD_Cmd() to enable the LCD controller 00058 * 00059 * 8. Write to the LCD RAM memory using the LCD_WriteRAM() function. 00060 * 00061 * @endverbatim 00062 * 00063 ****************************************************************************** 00064 * @attention 00065 * 00066 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00067 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 00068 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 00069 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 00070 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 00071 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00072 * 00073 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> 00074 ****************************************************************************** 00075 */ 00076 00077 /* Includes ------------------------------------------------------------------*/ 00078 #include "stm8l15x_lcd.h" 00079 00080 /** @addtogroup STM8L15x_StdPeriph_Driver 00081 * @{ 00082 */ 00083 00084 /** @defgroup LCD 00085 * @brief LCD driver modules 00086 * @{ 00087 */ 00088 /* Private typedef -----------------------------------------------------------*/ 00089 /* Private define ------------------------------------------------------------*/ 00090 /* Private macro -------------------------------------------------------------*/ 00091 /* Private function prototypes -----------------------------------------------*/ 00092 /* Private functions ---------------------------------------------------------*/ 00093 00094 /** @defgroup LCD_Private_Functions 00095 * @{ 00096 */ 00097 00098 /** @defgroup LCD_Group1 Initialization and Configuration functions 00099 * @brief Initialization and Configuration functions 00100 * 00101 @verbatim 00102 =============================================================================== 00103 Initialization and Configuration functions 00104 =============================================================================== 00105 00106 @endverbatim 00107 * @{ 00108 */ 00109 00110 /** 00111 * @brief Deinitializes the LCD Controller registers to their default reset values. 00112 * @param None 00113 * @retval None 00114 */ 00115 void LCD_DeInit(void) 00116 { 00117 uint8_t counter = 0; 00118 00119 LCD->CR1 = LCD_CR1_RESET_VALUE; 00120 LCD->CR2 = LCD_CR2_RESET_VALUE; 00121 LCD->CR3 = LCD_CR3_RESET_VALUE; 00122 LCD->FRQ = LCD_FRQ_RESET_VALUE; 00123 00124 for (counter = 0;counter < 0x05; counter++) 00125 { 00126 LCD->PM[counter] = LCD_PM_RESET_VALUE; 00127 } 00128 00129 for (counter = 0;counter < 0x16; counter++) 00130 { 00131 LCD->RAM[counter] = LCD_RAM_RESET_VALUE; 00132 } 00133 00134 LCD->CR4 = LCD_CR4_RESET_VALUE; 00135 00136 } 00137 00138 /** 00139 * @brief Initializes the LCD according to the specified parameters. 00140 * @param LCD_CLKPrescalerDiv : LCD clock prescaler 00141 * This parameter can be one of the following values: 00142 * @arg LCD_Prescaler_1: CLKprescaler = ClKinput 00143 * @arg LCD_Prescaler_2: CLKprescaler = ClKinput/2 00144 * @arg LCD_Prescaler_4: CLKprescaler = ClKinput/4 00145 * @arg LCD_Prescaler_8: CLKprescaler = ClKinput/8 00146 * @arg LCD_Prescaler_16: CLKprescaler = ClKinput/16 00147 * @arg LCD_Prescaler_32: CLKprescaler = ClKinput/32 00148 * @arg LCD_Prescaler_64: CLKprescaler = ClKinput/64 00149 * @arg LCD_Prescaler_128: CLKprescaler = ClKinput/128 00150 * @arg LCD_Prescaler_256: CLKprescaler = ClKinput/256 00151 * @arg LCD_Prescaler_512: CLKprescaler = ClKinput/512 00152 * @arg LCD_Prescaler_1024: CLKprescaler = ClKinput/1024 00153 * @arg LCD_Prescaler_2048: CLKprescaler = ClKinput/2048 00154 * @arg LCD_Prescaler_4096: CLKprescaler = ClKinput/4096 00155 * @arg LCD_Prescaler_8192: CLKprescaler = ClKinput/8192 00156 * @arg LCD_Prescaler_16384: CLKprescaler = ClKinput/16384 00157 * @arg LCD_Prescaler_32768: CLKprescaler = ClKinput/32768 00158 * @param LCD_Divider : LCD clock divider 00159 * This parameter can be one of the following values: 00160 * @arg LCD_Divider_16: LCD frequency = CLKprescaler/16 00161 * @arg LCD_Divider_17: LCD frequency = CLKprescaler/17 00162 * @arg LCD_Divider_18: LCD frequency = CLKprescaler/18 00163 * @arg LCD_Divider_19: LCD frequency = CLKprescaler/19 00164 * @arg LCD_Divider_20: LCD frequency = CLKprescaler/20 00165 * @arg LCD_Divider_21: LCD frequency = CLKprescaler/21 00166 * @arg LCD_Divider_22: LCD frequency = CLKprescaler/22 00167 * @arg LCD_Divider_23: LCD frequency = CLKprescaler/23 00168 * @arg LCD_Divider_24: LCD frequency = CLKprescaler/24 00169 * @arg LCD_Divider_25: LCD frequency = CLKprescaler/25 00170 * @arg LCD_Divider_26: LCD frequency = CLKprescaler/26 00171 * @arg LCD_Divider_27: LCD frequency = CLKprescaler/27 00172 * @arg LCD_Divider_28: LCD frequency = CLKprescaler/28 00173 * @arg LCD_Divider_29: LCD frequency = CLKprescaler/29 00174 * @arg LCD_Divider_30: LCD frequency = CLKprescaler/30 00175 * @arg LCD_Divider_31: LCD frequency = CLKprescaler/31 00176 * @param LCD_Duty : LCD duty 00177 * This parameter can be one of the following values: 00178 * @arg LCD_Duty_Static: Static duty 00179 * @arg LCD_Duty_1_2: 1/2 duty 00180 * @arg LCD_Duty_1_3: 1/3 duty 00181 * @arg LCD_Duty_1_4: 1/4 duty 00182 * @arg LCD_Duty_1_8: 1/8 duty 00183 * @param LCD_Bias : LCD bias 00184 * This parameter can be one of the following values: 00185 * @arg LCD_Bias_1_4: 1/4 bias 00186 * @arg LCD_Bias_1_3: 1/3 bias 00187 * @arg LCD_Bias_1_2: 1/2 bias 00188 * @param LCD_VoltageSource : LCD voltage source 00189 * This parameter can be one of the following values: 00190 * @arg LCD_VoltageSource_Internal: Internal voltage source 00191 * @arg LCD_VoltageSource_External: External voltage source 00192 * @retval None 00193 */ 00194 void LCD_Init(LCD_Prescaler_TypeDef LCD_Prescaler, LCD_Divider_TypeDef LCD_Divider, 00195 LCD_Duty_TypeDef LCD_Duty, LCD_Bias_TypeDef LCD_Bias, 00196 LCD_VoltageSource_TypeDef LCD_VoltageSource) 00197 { 00198 /* Check function parameters */ 00199 assert_param(IS_LCD_CLOCK_PRESCALER(LCD_Prescaler)); 00200 assert_param(IS_LCD_CLOCK_DIVIDER(LCD_Divider)); 00201 assert_param(IS_LCD_DUTY(LCD_Duty)); 00202 assert_param(IS_LCD_BIAS(LCD_Bias)); 00203 assert_param(IS_LCD_VOLTAGE_SOURCE(LCD_VoltageSource)); 00204 00205 LCD->FRQ &= (uint8_t)(~LCD_FRQ_PS); /* Clear the prescaler bits */ 00206 LCD->FRQ |= LCD_Prescaler; 00207 00208 LCD->FRQ &= (uint8_t)(~LCD_FRQ_DIV); /* Clear the divider bits */ 00209 LCD->FRQ |= LCD_Divider; 00210 00211 /* Configure the Duty cycle */ 00212 LCD->CR1 &= (uint8_t)(~LCD_CR1_DUTY); /* Clear the duty bits */ 00213 LCD->CR4 &= (uint8_t)(~LCD_CR4_DUTY8); /* Clear the DUTY8 bit */ 00214 00215 if (LCD_Duty == LCD_Duty_1_8) 00216 { 00217 LCD->CR4 |= (uint8_t)((uint8_t)((uint8_t)LCD_Duty & (uint8_t)0xF0) >> 4); 00218 } 00219 else 00220 { 00221 LCD->CR1 |= (uint8_t)((uint8_t)LCD_Duty & (uint8_t)0x0F); 00222 } 00223 00224 /* Configure the Bias */ 00225 LCD->CR1 &= (uint8_t)(~LCD_CR1_B2); /* Clear the B2 bit */ 00226 LCD->CR4 &= (uint8_t)(~LCD_CR4_B4); /* Clear the B4 bit */ 00227 00228 if (LCD_Bias == LCD_Bias_1_4) 00229 { 00230 LCD->CR1 |= (uint8_t)((uint8_t)LCD_Bias & (uint8_t)0x0F); 00231 LCD->CR4 |= (uint8_t)((uint8_t)((uint8_t)LCD_Bias & (uint8_t)0xF0) >> 4); 00232 } 00233 else 00234 { 00235 LCD->CR1 |= (uint8_t)((uint8_t)LCD_Bias & (uint8_t)0x0F); 00236 } 00237 00238 LCD->CR2 &= (uint8_t)(~LCD_CR2_VSEL); /* Clear the voltage source bit */ 00239 LCD->CR2 |= LCD_VoltageSource; 00240 00241 } 00242 00243 /** 00244 * @brief Configures the LCD Port Mask. 00245 * @param LCD_PortMaskRegister: The LCD register index in the port mask matrix. 00246 * This parameter can be one of the following values: 00247 * @arg LCD_PortMaskRegister_0: PortMask Register 0 00248 * @arg LCD_PortMaskRegister_1: PortMask Register 1 00249 * @arg LCD_PortMaskRegister_2: PortMask Register 2 00250 * @arg LCD_PortMaskRegister_3: PortMask Register 3 00251 * @arg LCD_PortMaskRegister_4: PortMask Register 4 00252 * @arg LCD_PortMaskRegister_5: PortMask Register 5 00253 * @param LCD_Mask : Value to be written 00254 * @retval None 00255 */ 00256 void LCD_PortMaskConfig(LCD_PortMaskRegister_TypeDef LCD_PortMaskRegister, uint8_t LCD_Mask) 00257 { 00258 /* Check function parameters */ 00259 assert_param(IS_LCD_PORT_MASK(LCD_PortMaskRegister)); 00260 00261 /* Copy data bytes to Port mask register */ 00262 LCD->PM[LCD_PortMaskRegister] = LCD_Mask; 00263 00264 } 00265 00266 /** 00267 * @brief Enables or disables the LCD Controller. 00268 * @param NewState: new state of the LCD peripheral. 00269 * This parameter can be: ENABLE or DISABLE. 00270 * @retval None 00271 * @retval None 00272 */ 00273 void LCD_Cmd(FunctionalState NewState) 00274 { 00275 /* Check function parameters */ 00276 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00277 00278 if (NewState != DISABLE) 00279 { 00280 LCD->CR3 |= LCD_CR3_LCDEN; /* Enable the LCD peripheral*/ 00281 } 00282 else 00283 { 00284 LCD->CR3 &= (uint8_t)(~LCD_CR3_LCDEN); /* Disable the LCD peripheral*/ 00285 } 00286 } 00287 00288 /** 00289 * @brief Enables or disables the low resistance divider. Displays with high 00290 * internal resistance may need a longer drive time to achieve 00291 * satisfactory contrast. This function is useful in this case if some 00292 * additional power consumption can be tolerated. 00293 * @note When this mode is enabled, the PulseOn Duration (PON) have to be 00294 * programmed to 1/CK_PS (LCD_PulseOnDuration_1). 00295 * @param NewState: new state of the low resistance divider. 00296 * This parameter can be: ENABLE or DISABLE. 00297 * @retval None 00298 */ 00299 void LCD_HighDriveCmd(FunctionalState NewState) 00300 { 00301 /* Check function parameters */ 00302 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00303 00304 if (NewState != DISABLE) 00305 { 00306 LCD->CR2 |= LCD_CR2_HD; /* Permanently enable low resistance divider */ 00307 } 00308 else 00309 { 00310 LCD->CR2 &= (uint8_t)(~LCD_CR2_HD); /* Permanently disable low resistance divider */ 00311 } 00312 } 00313 00314 /** 00315 * @brief Configures the LCD pulses on duration. 00316 * @param LCD_PulseOnDuration: specifies the LCD pulse on duration in terms of 00317 * CLKprescaler (prescaled LCD clock period) pulses. 00318 * This parameter can be one of the following values: 00319 * @arg LCD_PulseOnDuration_0: 0 pulse 00320 * @arg LCD_PulseOnDuration_1: Pulse ON duration = 1/CLKprescaler 00321 * @arg LCD_PulseOnDuration_2: Pulse ON duration = 2/CLKprescaler 00322 * @arg LCD_PulseOnDuration_3: Pulse ON duration = 3/CLKprescaler 00323 * @arg LCD_PulseOnDuration_4: Pulse ON duration = 4/CLKprescaler 00324 * @arg LCD_PulseOnDuration_5: Pulse ON duration = 5/CLKprescaler 00325 * @arg LCD_PulseOnDuration_6: Pulse ON duration = 6/CLKprescaler 00326 * @arg LCD_PulseOnDuration_7: Pulse ON duration = 7/CLKprescaler 00327 * @retval None 00328 */ 00329 void LCD_PulseOnDurationConfig(LCD_PulseOnDuration_TypeDef LCD_PulseOnDuration) 00330 { 00331 /* Check function parameters */ 00332 assert_param(IS_LCD_PULSE_DURATION(LCD_PulseOnDuration)); 00333 00334 LCD->CR2 &= (uint8_t)(~LCD_CR2_PON); /* Clear the pulses on duration bits */ 00335 LCD->CR2 |= LCD_PulseOnDuration; 00336 } 00337 00338 /** 00339 * @brief Configures the LCD dead time. 00340 * @param LCD_DeadTime: specifies the LCD dead time. 00341 * This parameter can be one of the following values: 00342 * @arg LCD_DeadTime_0: No dead Time 00343 * @arg LCD_DeadTime_1: One Phase between different couple of Frame 00344 * @arg LCD_DeadTime_2: Two Phase between different couple of Frame 00345 * @arg LCD_DeadTime_3: Three Phase between different couple of Frame 00346 * @arg LCD_DeadTime_4: Four Phase between different couple of Frame 00347 * @arg LCD_DeadTime_5: Five Phase between different couple of Frame 00348 * @arg LCD_DeadTime_6: Six Phase between different couple of Frame 00349 * @arg LCD_DeadTime_7: Seven Phase between different couple of Frame 00350 * @retval None 00351 */ 00352 void LCD_DeadTimeConfig(LCD_DeadTime_TypeDef LCD_DeadTime) 00353 { 00354 /* Check function parameters */ 00355 assert_param(IS_LCD_DEAD_TIME(LCD_DeadTime)); 00356 00357 LCD->CR3 &= (uint8_t)(~LCD_CR3_DEAD); /* Clear the dead time bits */ 00358 00359 LCD->CR3 |= LCD_DeadTime; 00360 00361 } 00362 00363 /** 00364 * @brief Configures the LCD Blink mode and Blink frequency. 00365 * @param LCD_BlinkMode: specifies the LCD blink mode. 00366 * This parameter can be one of the following values: 00367 * @arg LCD_BlinkMode_Off: Blink disabled 00368 * @arg LCD_BlinkMode_SEG0_COM0: Blink enabled on SEG[0], COM[0] (1 pixel) 00369 * @arg LCD_BlinkMode_SEG0_AllCOM: Blink enabled on SEG[0], all COM (up to 8 00370 * pixels according to the programmed duty) 00371 * @arg LCD_BlinkMode_AllSEG_AllCOM: Blink enabled on all SEG and all COM 00372 * (all pixels) 00373 * @param LCD_BlinkFrequency: specifies the LCD blink frequency. 00374 * This parameter can be one of the following values: 00375 * @arg LCD_BlinkFrequency_Div8: The Blink frequency = fLcd/8 00376 * @arg LCD_BlinkFrequency_Div16: The Blink frequency = fLcd/16 00377 * @arg LCD_BlinkFrequency_Div32: The Blink frequency = fLcd/32 00378 * @arg LCD_BlinkFrequency_Div64: The Blink frequency = fLcd/64 00379 * @arg LCD_BlinkFrequency_Div128: The Blink frequency = fLcd/128 00380 * @arg LCD_BlinkFrequency_Div256: The Blink frequency = fLcd/256 00381 * @arg LCD_BlinkFrequency_Div512: The Blink frequency = fLcd/512 00382 * @arg LCD_BlinkFrequency_Div1024: The Blink frequency = fLcd/1024 00383 * @retval None 00384 */ 00385 void LCD_BlinkConfig(LCD_BlinkMode_TypeDef LCD_BlinkMode, LCD_BlinkFrequency_TypeDef LCD_BlinkFrequency) 00386 { 00387 /* Check function parameters */ 00388 assert_param(IS_LCD_BLINK_MODE(LCD_BlinkMode)); 00389 assert_param(IS_LCD_BLINK_FREQUENCY(LCD_BlinkFrequency)); 00390 00391 LCD->CR1 &= (uint8_t)(~LCD_CR1_BLINK); /* Clear the blink mode bits */ 00392 LCD->CR1 |= LCD_BlinkMode; /* Config the LCD Blink Mode */ 00393 00394 LCD->CR1 &= (uint8_t)(~LCD_CR1_BLINKF); /* Clear the blink frequency bits */ 00395 LCD->CR1 |= LCD_BlinkFrequency; /* Config the LCD Blink Frequency */ 00396 00397 } 00398 00399 /** 00400 * @brief Configures the LCD Contrast. 00401 * @param LCD_Contrast: specifies the LCD Contrast. 00402 * This parameter can be one of the following values: 00403 * @arg LCD_Contrast_Level_0: Medium Density / High Density Maximum Voltage = 2.60V / 2.60V 00404 * @arg LCD_Contrast_Level_1: Medium Density / High Density Maximum Voltage = 2.70V / 2.73V 00405 * @arg LCD_Contrast_Level_2: Medium Density / High Density Maximum Voltage = 2.80V / 2.86V 00406 * @arg LCD_Contrast_Level_3: Medium Density / High Density Maximum Voltage = 2.90V / 2.99V 00407 * @arg LCD_Contrast_Level_4: Medium Density / High Density Maximum Voltage = 3.00V / 3.12V 00408 * @arg LCD_Contrast_Level_5: Medium Density / High Density Maximum Voltage = 3.10V / 3.25V 00409 * @arg LCD_Contrast_Level_6: Medium Density / High Density Maximum Voltage = 3.20V / 3.38V 00410 * @arg LCD_Contrast_Level_7: Medium Density / High Density Maximum Voltage = 3.30V / 3.51V 00411 * @retval None 00412 */ 00413 void LCD_ContrastConfig(LCD_Contrast_TypeDef LCD_Contrast) 00414 { 00415 /* Check function parameters */ 00416 assert_param(IS_LCD_CONTRAST(LCD_Contrast)); 00417 00418 LCD->CR2 &= (uint8_t)(~LCD_CR2_CC); /* Clear the contrast bits */ 00419 LCD->CR2 |= LCD_Contrast; /* Select the maximum voltage value Vlcd */ 00420 00421 } 00422 00423 /** 00424 * @} 00425 */ 00426 00427 /** @defgroup LCD_Group2 LCD RAM memory write functions 00428 * @brief LCD RAM memory write functions 00429 * 00430 @verbatim 00431 =============================================================================== 00432 LCD RAM memory write functions 00433 =============================================================================== 00434 00435 @endverbatim 00436 * @{ 00437 */ 00438 00439 /** 00440 * @brief Writes a word in the specific LCD RAM. 00441 * @param LCD_RAMRegister: specifies the LCD Contrast. 00442 * This parameter can be one of the following values: 00443 * @arg LCD_RAMRegister_0: LCD RAM Register 0 00444 * @arg LCD_RAMRegister_1: LCD RAM Register 1 00445 * @arg LCD_RAMRegister_2: LCD RAM Register 2 00446 * @arg LCD_RAMRegister_3: LCD RAM Register 3 00447 * @arg LCD_RAMRegister_4: LCD RAM Register 4 00448 * @arg LCD_RAMRegister_5: LCD RAM Register 5 00449 * @arg LCD_RAMRegister_6: LCD RAM Register 6 00450 * @arg LCD_RAMRegister_7: LCD RAM Register 7 00451 * @arg LCD_RAMRegister_8: LCD RAM Register 8 00452 * @arg LCD_RAMRegister_9: LCD RAM Register 9 00453 * @arg LCD_RAMRegister_10: LCD RAM Register 10 00454 * @arg LCD_RAMRegister_11: LCD RAM Register 11 00455 * @arg LCD_RAMRegister_12: LCD RAM Register 12 00456 * @arg LCD_RAMRegister_13: LCD RAM Register 13 00457 * @arg LCD_RAMRegister_14: LCD RAM Register 14 00458 * @arg LCD_RAMRegister_15: LCD RAM Register 15 00459 * @arg LCD_RAMRegister_15: LCD RAM Register 16 00460 * @arg LCD_RAMRegister_15: LCD RAM Register 17 00461 * @arg LCD_RAMRegister_15: LCD RAM Register 18 00462 * @arg LCD_RAMRegister_15: LCD RAM Register 19 00463 * @arg LCD_RAMRegister_15: LCD RAM Register 20 00464 * @arg LCD_RAMRegister_15: LCD RAM Register 21 00465 * @param LCD_Data: specifies LCD Data Value to be written. 00466 * @retval None 00467 */ 00468 void LCD_WriteRAM(LCD_RAMRegister_TypeDef LCD_RAMRegister, uint8_t LCD_Data) 00469 { 00470 /* Check function parameters */ 00471 assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister)); 00472 00473 /* Copy data bytes to RAM register */ 00474 LCD->RAM[LCD_RAMRegister] = LCD_Data; 00475 00476 } 00477 00478 /** 00479 * @brief Select the LCD page where the data will be written. 00480 * @param LCD_Page: The accessed LCD page. 00481 * This parameter can be one of the following values: 00482 * @arg LCD_PageSelection_FirstPage: The LCD RAM is selected as the first page 00483 * @arg LCD_PageSelection_SecondPage: The LCD RAM is selected as the second page 00484 * @retval None 00485 */ 00486 void LCD_PageSelect(LCD_PageSelection_TypeDef LCD_PageSelection) 00487 { 00488 /* Check function parameters */ 00489 assert_param(IS_LCD_PAGE_SELECT(LCD_PageSelection)); 00490 00491 LCD->CR4 &= (uint8_t)(~LCD_CR4_PAGECOM); /* Clear the PAGE COM bit */ 00492 LCD->CR4 |= LCD_PageSelection; /* Select the LCD page */ 00493 00494 } 00495 00496 /** 00497 * @} 00498 */ 00499 00500 /** @defgroup LCD_Group3 Interrupts and flags management functions 00501 * @brief Interrupts and flags management functions 00502 * 00503 @verbatim 00504 =============================================================================== 00505 Interrupts and flags management functions 00506 =============================================================================== 00507 00508 @endverbatim 00509 * @{ 00510 */ 00511 00512 00513 /** 00514 * @brief Enables or disables the start of frame interrupt. 00515 * @param NewState: new state of the specified LCD interrupts. 00516 * This parameter can be: ENABLE or DISABLE. 00517 * @retval None 00518 */ 00519 void LCD_ITConfig(FunctionalState NewState) 00520 { 00521 /* Check function parameters */ 00522 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00523 00524 if (NewState != DISABLE) 00525 { 00526 LCD->CR3 |= LCD_CR3_SOFIE; /* Enable interrupt*/ 00527 } 00528 else 00529 { 00530 LCD->CR3 &= (uint8_t)(~LCD_CR3_SOFIE); /* Disable interrupt*/ 00531 } 00532 00533 } 00534 00535 /** 00536 * @brief Checks whether the LCD start of new frame flag is set or not. 00537 * @retval The new state of the start of new frame flag. 00538 * This returned value can be: SET or RESET. 00539 */ 00540 FlagStatus LCD_GetFlagStatus(void) 00541 { 00542 FlagStatus status = RESET; 00543 00544 /* Check the status of the start of new frame LCD flag */ 00545 if ((LCD->CR3 & (uint8_t)LCD_CR3_SOF) != (uint8_t)RESET) 00546 { 00547 status = SET; /* Flag is set */ 00548 } 00549 else 00550 { 00551 status = RESET; /* Flag is reset*/ 00552 } 00553 /* Return the FLAG status */ 00554 return status; 00555 00556 } 00557 00558 /** 00559 * @brief Clears the start of frame LCD flag. 00560 * @param None 00561 * @retval None 00562 */ 00563 void LCD_ClearFlag(void) 00564 { 00565 /* Clear the flag bit */ 00566 LCD->CR3 |= (uint8_t)(LCD_CR3_SOFC); 00567 00568 } 00569 00570 /** 00571 * @brief Checks whether the start of frame interrupt has occurred or not. 00572 * @param None 00573 * @retval The new state of the start of new frame interrupt. 00574 * This returned value can be: SET or RESET. 00575 */ 00576 ITStatus LCD_GetITStatus(void) 00577 { 00578 ITStatus pendingbitstatus = RESET; 00579 uint8_t enablestatus = 0; 00580 00581 enablestatus = (uint8_t)((uint8_t)LCD->CR3 & LCD_CR3_SOFIE); 00582 /* Check the status of the start of frame interrupt */ 00583 if (((LCD->CR3 & LCD_CR3_SOF) != RESET) && enablestatus) 00584 { 00585 /* ITPENDINGBIT is set */ 00586 pendingbitstatus = SET; 00587 } 00588 else 00589 { 00590 /* ITPENDINGBIT is reset */ 00591 pendingbitstatus = RESET; 00592 } 00593 /* Return the ITPENDINGBIT status */ 00594 return pendingbitstatus; 00595 00596 } 00597 00598 /** 00599 * @brief Clears the start of frame interrupt pending bits. 00600 * @param None 00601 * @retval None 00602 */ 00603 void LCD_ClearITPendingBit(void) 00604 { 00605 /* Clear the flag bit */ 00606 LCD->CR3 |= (uint8_t)(LCD_CR3_SOFC); 00607 00608 } 00609 00610 /** 00611 * @} 00612 */ 00613 00614 /** 00615 * @} 00616 */ 00617 00618 /** 00619 * @} 00620 */ 00621 00622 /** 00623 * @} 00624 */ 00625 00626 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/