STM32L4xx_HAL_Driver  1.14.0
Initialization/de-initialization methods

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_LCD_DeInit (LCD_HandleTypeDef *hlcd)
 DeInitialize the LCD peripheral. More...
 
HAL_StatusTypeDef HAL_LCD_Init (LCD_HandleTypeDef *hlcd)
 Initialize the LCD peripheral according to the specified parameters in the LCD_InitStruct and initialize the associated handle. More...
 
void HAL_LCD_MspInit (LCD_HandleTypeDef *hlcd)
 Initialize the LCD MSP. More...
 
void HAL_LCD_MspDeInit (LCD_HandleTypeDef *hlcd)
 DeInitialize the LCD MSP. More...
 

Detailed Description

Initialization and Configuration functions.

===============================================================================
            ##### Initialization and Configuration functions #####
 ===============================================================================
    [..]

Function Documentation

◆ HAL_LCD_DeInit()

HAL_StatusTypeDef HAL_LCD_DeInit ( LCD_HandleTypeDef hlcd)

DeInitialize the LCD peripheral.

Parameters
hlcdLCD handle
Return values
HALstatus

Definition at line 262 of file stm32l4xx_hal_lcd.c.

263 {
264  /* Check the LCD handle allocation */
265  if (hlcd == NULL)
266  {
267  return HAL_ERROR;
268  }
269 
270  /* Check the parameters */
271  assert_param(IS_LCD_ALL_INSTANCE(hlcd->Instance));
272 
273  hlcd->State = HAL_LCD_STATE_BUSY;
274 
275  /* DeInit the low level hardware */
276  HAL_LCD_MspDeInit(hlcd);
277 
278  hlcd->ErrorCode = HAL_LCD_ERROR_NONE;
279  hlcd->State = HAL_LCD_STATE_RESET;
280 
281  /* Release Lock */
282  __HAL_UNLOCK(hlcd);
283 
284  return HAL_OK;
285 }
__IO HAL_LCD_StateTypeDef State
__HAL_UNLOCK(hrtc)
return HAL_OK
__IO uint32_t ErrorCode
LCD_TypeDef * Instance
void HAL_LCD_MspDeInit(LCD_HandleTypeDef *hlcd)
DeInitialize the LCD MSP.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_LCD_Init()

HAL_StatusTypeDef HAL_LCD_Init ( LCD_HandleTypeDef hlcd)

Initialize the LCD peripheral according to the specified parameters in the LCD_InitStruct and initialize the associated handle.

Note
This function can be used only when the LCD is disabled.
Parameters
hlcdLCD handle
Return values
None

< Wait Until the LCD Booster is ready

Definition at line 139 of file stm32l4xx_hal_lcd.c.

140 {
141  uint32_t tickstart;
142  uint32_t counter;
143  HAL_StatusTypeDef status;
144 
145  /* Check the LCD handle allocation */
146  if (hlcd == NULL)
147  {
148  return HAL_ERROR;
149  }
150 
151  /* Check function parameters */
152  assert_param(IS_LCD_ALL_INSTANCE(hlcd->Instance));
153  assert_param(IS_LCD_PRESCALER(hlcd->Init.Prescaler));
154  assert_param(IS_LCD_DIVIDER(hlcd->Init.Divider));
155  assert_param(IS_LCD_DUTY(hlcd->Init.Duty));
156  assert_param(IS_LCD_BIAS(hlcd->Init.Bias));
157  assert_param(IS_LCD_VOLTAGE_SOURCE(hlcd->Init.VoltageSource));
158  assert_param(IS_LCD_PULSE_ON_DURATION(hlcd->Init.PulseOnDuration));
159  assert_param(IS_LCD_HIGH_DRIVE(hlcd->Init.HighDrive));
160  assert_param(IS_LCD_DEAD_TIME(hlcd->Init.DeadTime));
161  assert_param(IS_LCD_CONTRAST(hlcd->Init.Contrast));
162  assert_param(IS_LCD_BLINK_FREQUENCY(hlcd->Init.BlinkFrequency));
163  assert_param(IS_LCD_BLINK_MODE(hlcd->Init.BlinkMode));
164  assert_param(IS_LCD_MUX_SEGMENT(hlcd->Init.MuxSegment));
165 
166  if (hlcd->State == HAL_LCD_STATE_RESET)
167  {
168  /* Allocate lock resource and initialize it */
169  hlcd->Lock = HAL_UNLOCKED;
170 
171  /* Initialize the low level hardware (MSP) */
172  HAL_LCD_MspInit(hlcd);
173  }
174 
175  hlcd->State = HAL_LCD_STATE_BUSY;
176 
177  /* Disable the peripheral */
178  __HAL_LCD_DISABLE(hlcd);
179 
180  /* Clear the LCD_RAM registers and enable the display request by setting the UDR bit
181  in the LCD_SR register */
182  for (counter = LCD_RAM_REGISTER0; counter <= LCD_RAM_REGISTER15; counter++)
183  {
184  hlcd->Instance->RAM[counter] = 0;
185  }
186  /* Enable the display request */
187  hlcd->Instance->SR |= LCD_SR_UDR;
188  /* Configure the LCD Prescaler, Divider, Blink mode and Blink Frequency:
189  Set PS[3:0] bits according to hlcd->Init.Prescaler value
190  Set DIV[3:0] bits according to hlcd->Init.Divider value
191  Set BLINK[1:0] bits according to hlcd->Init.BlinkMode value
192  Set BLINKF[2:0] bits according to hlcd->Init.BlinkFrequency value
193  Set DEAD[2:0] bits according to hlcd->Init.DeadTime value
194  Set PON[2:0] bits according to hlcd->Init.PulseOnDuration value
195  Set CC[2:0] bits according to hlcd->Init.Contrast value
196  Set HD bit according to hlcd->Init.HighDrive value */
197  MODIFY_REG(hlcd->Instance->FCR, \
198  (LCD_FCR_PS | LCD_FCR_DIV | LCD_FCR_BLINK | LCD_FCR_BLINKF | \
199  LCD_FCR_DEAD | LCD_FCR_PON | LCD_FCR_CC | LCD_FCR_HD), \
200  (hlcd->Init.Prescaler | hlcd->Init.Divider | hlcd->Init.BlinkMode | hlcd->Init.BlinkFrequency | \
201  hlcd->Init.DeadTime | hlcd->Init.PulseOnDuration | hlcd->Init.Contrast | hlcd->Init.HighDrive));
202 
203  /* Wait until LCD Frame Control Register Synchronization flag (FCRSF) is set in the LCD_SR register
204  This bit is set by hardware each time the LCD_FCR register is updated in the LCDCLK
205  domain. It is cleared by hardware when writing to the LCD_FCR register.*/
206  status = LCD_WaitForSynchro(hlcd);
207  if (status != HAL_OK)
208  {
209  return status;
210  }
211 
212  /* Configure the LCD Duty, Bias, Voltage Source, Dead Time, Pulse On Duration and Contrast:
213  Set DUTY[2:0] bits according to hlcd->Init.Duty value
214  Set BIAS[1:0] bits according to hlcd->Init.Bias value
215  Set VSEL bit according to hlcd->Init.VoltageSource value
216  Set MUX_SEG bit according to hlcd->Init.MuxSegment value */
217  MODIFY_REG(hlcd->Instance->CR, \
218  (LCD_CR_DUTY | LCD_CR_BIAS | LCD_CR_VSEL | LCD_CR_MUX_SEG), \
219  (hlcd->Init.Duty | hlcd->Init.Bias | hlcd->Init.VoltageSource | hlcd->Init.MuxSegment));
220 
221  /* Enable the peripheral */
222  __HAL_LCD_ENABLE(hlcd);
223 
224  /* Get timeout */
225  tickstart = HAL_GetTick();
226 
227  /* Wait Until the LCD is enabled */
228  while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_ENS) == RESET)
229  {
230  if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
231  {
232  hlcd->ErrorCode = HAL_LCD_ERROR_ENS;
233  return HAL_TIMEOUT;
234  }
235  }
236 
237  /* Get timeout */
238  tickstart = HAL_GetTick();
239 
241  while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_RDY) == RESET)
242  {
243  if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
244  {
245  hlcd->ErrorCode = HAL_LCD_ERROR_RDY;
246  return HAL_TIMEOUT;
247  }
248  }
249 
250  /* Initialize the LCD state */
251  hlcd->ErrorCode = HAL_LCD_ERROR_NONE;
252  hlcd->State = HAL_LCD_STATE_READY;
253 
254  return status;
255 }
uint32_t PulseOnDuration
__IO HAL_LCD_StateTypeDef State
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
void HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd)
Initialize the LCD MSP.
LCD_InitTypeDef Init
return HAL_OK
__IO uint32_t ErrorCode
HAL_LockTypeDef Lock
LCD_TypeDef * Instance
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
HAL_StatusTypeDef LCD_WaitForSynchro(LCD_HandleTypeDef *hlcd)
Wait until the LCD FCR register is synchronized in the LCDCLK domain. This function must be called af...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_LCD_MspDeInit()

__weak void HAL_LCD_MspDeInit ( LCD_HandleTypeDef hlcd)

DeInitialize the LCD MSP.

Parameters
hlcdLCD handle
Return values
None

Definition at line 292 of file stm32l4xx_hal_lcd.c.

293 {
294  /* Prevent unused argument(s) compilation warning */
295  UNUSED(hlcd);
296 
297  /* NOTE: This function should not be modified, when the callback is needed,
298  the HAL_LCD_MspDeInit it to be implemented in the user file
299  */
300 }

◆ HAL_LCD_MspInit()

__weak void HAL_LCD_MspInit ( LCD_HandleTypeDef hlcd)

Initialize the LCD MSP.

Parameters
hlcdLCD handle
Return values
None

Definition at line 307 of file stm32l4xx_hal_lcd.c.

308 {
309  /* Prevent unused argument(s) compilation warning */
310  UNUSED(hlcd);
311 
312  /* NOTE: This function should not be modified, when the callback is needed,
313  the HAL_LCD_MspInit is to be implemented in the user file
314  */
315 }