/** * @brief Initializes the LCD according to the specified parameters. * @param LCD_CLKPrescalerDiv : LCD clock prescaler * This parameter can be one of the following values: * @arg LCD_Prescaler_1: CLKprescaler = ClKinput * @arg LCD_Prescaler_2: CLKprescaler = ClKinput/2 * @arg LCD_Prescaler_4: CLKprescaler = ClKinput/4 * @arg LCD_Prescaler_8: CLKprescaler = ClKinput/8 * @arg LCD_Prescaler_16: CLKprescaler = ClKinput/16 * @arg LCD_Prescaler_32: CLKprescaler = ClKinput/32 * @arg LCD_Prescaler_64: CLKprescaler = ClKinput/64 * @arg LCD_Prescaler_128: CLKprescaler = ClKinput/128 * @arg LCD_Prescaler_256: CLKprescaler = ClKinput/256 * @arg LCD_Prescaler_512: CLKprescaler = ClKinput/512 * @arg LCD_Prescaler_1024: CLKprescaler = ClKinput/1024 * @arg LCD_Prescaler_2048: CLKprescaler = ClKinput/2048 * @arg LCD_Prescaler_4096: CLKprescaler = ClKinput/4096 * @arg LCD_Prescaler_8192: CLKprescaler = ClKinput/8192 * @arg LCD_Prescaler_16384: CLKprescaler = ClKinput/16384 * @arg LCD_Prescaler_32768: CLKprescaler = ClKinput/32768 * @param LCD_Divider : LCD clock divider * This parameter can be one of the following values: * @arg LCD_Divider_16: LCD frequency = CLKprescaler/16 * @arg LCD_Divider_17: LCD frequency = CLKprescaler/17 * @arg LCD_Divider_18: LCD frequency = CLKprescaler/18 * @arg LCD_Divider_19: LCD frequency = CLKprescaler/19 * @arg LCD_Divider_20: LCD frequency = CLKprescaler/20 * @arg LCD_Divider_21: LCD frequency = CLKprescaler/21 * @arg LCD_Divider_22: LCD frequency = CLKprescaler/22 * @arg LCD_Divider_23: LCD frequency = CLKprescaler/23 * @arg LCD_Divider_24: LCD frequency = CLKprescaler/24 * @arg LCD_Divider_25: LCD frequency = CLKprescaler/25 * @arg LCD_Divider_26: LCD frequency = CLKprescaler/26 * @arg LCD_Divider_27: LCD frequency = CLKprescaler/27 * @arg LCD_Divider_28: LCD frequency = CLKprescaler/28 * @arg LCD_Divider_29: LCD frequency = CLKprescaler/29 * @arg LCD_Divider_30: LCD frequency = CLKprescaler/30 * @arg LCD_Divider_31: LCD frequency = CLKprescaler/31 * @param LCD_Duty : LCD duty * This parameter can be one of the following values: * @arg LCD_Duty_Static: Static duty * @arg LCD_Duty_1_2: 1/2 duty * @arg LCD_Duty_1_3: 1/3 duty * @arg LCD_Duty_1_4: 1/4 duty * @arg LCD_Duty_1_8: 1/8 duty * @param LCD_Bias : LCD bias * This parameter can be one of the following values: * @arg LCD_Bias_1_4: 1/4 bias * @arg LCD_Bias_1_3: 1/3 bias * @arg LCD_Bias_1_2: 1/2 bias * @param LCD_VoltageSource : LCD voltage source * This parameter can be one of the following values: * @arg LCD_VoltageSource_Internal: Internal voltage source * @arg LCD_VoltageSource_External: External voltage source * @retval None */ void LCD_Init(LCD_Prescaler_TypeDef LCD_Prescaler, LCD_Divider_TypeDef LCD_Divider, LCD_Duty_TypeDef LCD_Duty, LCD_Bias_TypeDef LCD_Bias, LCD_VoltageSource_TypeDef LCD_VoltageSource) { /* Check function parameters */ assert_param(IS_LCD_CLOCK_PRESCALER(LCD_Prescaler)); assert_param(IS_LCD_CLOCK_DIVIDER(LCD_Divider)); assert_param(IS_LCD_DUTY(LCD_Duty)); assert_param(IS_LCD_BIAS(LCD_Bias)); assert_param(IS_LCD_VOLTAGE_SOURCE(LCD_VoltageSource)); LCD->FRQ &= (uint8_t)(~LCD_FRQ_PS); /* Clear the prescaler bits */ LCD->FRQ |= LCD_Prescaler; LCD->FRQ &= (uint8_t)(~LCD_FRQ_DIV); /* Clear the divider bits */ LCD->FRQ |= LCD_Divider; /* Configure the Duty cycle */ LCD->CR1 &= (uint8_t)(~LCD_CR1_DUTY); /* Clear the duty bits */ LCD->CR4 &= (uint8_t)(~LCD_CR4_DUTY8); /* Clear the DUTY8 bit */ if (LCD_Duty == LCD_Duty_1_8) { LCD->CR4 |= (uint8_t)((uint8_t)((uint8_t)LCD_Duty & (uint8_t)0xF0) >> 4); }
/** * @brief Initializes the LCD according to the specified parameters. * @param LCD_CLKPrescalerDiv : This parameter can be any of the @ref LCD_Divider_TypeDef enumeration. * @param LCD_Divider : This parameter can be any of the @ref LCD_Divider_TypeDef enumeration. * @param LCD_Duty : This parameter can be any of the @ref LCD_Duty_TypeDef enumeration. * @param LCD_Bias : This parameter can be any of the @ref LCD_Bias_TypeDef enumeration. * @param LCD_VoltageSource : This parameter can be any of the @ref LCD_VoltageSource_TypeDef enumeration. * @retval None */ void LCD_Init(LCD_Prescaler_TypeDef LCD_Prescaler, LCD_Divider_TypeDef LCD_Divider, LCD_Duty_TypeDef LCD_Duty, LCD_Bias_TypeDef LCD_Bias, LCD_VoltageSource_TypeDef LCD_VoltageSource) { /* Check function parameters */ assert_param(IS_LCD_CLOCK_PRESCALER(LCD_Prescaler)); assert_param(IS_LCD_CLOCK_DIVIDER(LCD_Divider)); assert_param(IS_LCD_DUTY(LCD_Duty)); assert_param(IS_LCD_BIAS(LCD_Bias)); assert_param(IS_LCD_VOLTAGE_SOURCE(LCD_VoltageSource)); LCD->FRQ &= (uint8_t)(~LCD_FRQ_PS); /* Clear the prescaler bits */ LCD->FRQ |= (uint8_t)LCD_Prescaler; LCD->FRQ &= (uint8_t)(~LCD_FRQ_DIV); /* Clear the divider bits */ LCD->FRQ |= (uint8_t)LCD_Divider; LCD->CR1 &= (uint8_t)(~LCD_CR1_DUTY); /* Clear the duty bits */ LCD->CR1 |= (uint8_t)LCD_Duty; LCD->CR1 &= (uint8_t)(~LCD_CR1_B2); /* Clear the bias bits */ LCD->CR1 |= (uint8_t)LCD_Bias; LCD->CR2 &= (uint8_t)(~LCD_CR2_VSEL); /* Clear the voltage source bit */ LCD->CR2 |= (uint8_t)LCD_VoltageSource; }