STM32L4xx_HAL_Driver  1.14.0
Initialization and Configuration functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_DSI_Init (DSI_HandleTypeDef *hdsi, DSI_PLLInitTypeDef *PLLInit)
 Initializes the DSI according to the specified parameters in the DSI_InitTypeDef and create the associated handle. More...
 
HAL_StatusTypeDef HAL_DSI_DeInit (DSI_HandleTypeDef *hdsi)
 De-initializes the DSI peripheral registers to their default reset values. More...
 
HAL_StatusTypeDef HAL_DSI_ConfigErrorMonitor (DSI_HandleTypeDef *hdsi, uint32_t ActiveErrors)
 Enable the error monitor flags. More...
 
__weak void HAL_DSI_MspInit (DSI_HandleTypeDef *hdsi)
 Initializes the DSI MSP. More...
 
__weak void HAL_DSI_MspDeInit (DSI_HandleTypeDef *hdsi)
 De-initializes the DSI MSP. More...
 
HAL_StatusTypeDef HAL_DSI_RegisterCallback (DSI_HandleTypeDef *hdsi, HAL_DSI_CallbackIDTypeDef CallbackID, pDSI_CallbackTypeDef pCallback)
 Register a User DSI Callback To be used instead of the weak predefined callback. More...
 
HAL_StatusTypeDef HAL_DSI_UnRegisterCallback (DSI_HandleTypeDef *hdsi, HAL_DSI_CallbackIDTypeDef CallbackID)
 Unregister a DSI Callback DSI callabck is redirected to the weak predefined callback. More...
 

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
                ##### Initialization and Configuration functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Initialize and configure the DSI
      (+) De-initialize the DSI

Function Documentation

◆ HAL_DSI_ConfigErrorMonitor()

HAL_StatusTypeDef HAL_DSI_ConfigErrorMonitor ( DSI_HandleTypeDef hdsi,
uint32_t  ActiveErrors 
)

Enable the error monitor flags.

Parameters
hdsipointer to a DSI_HandleTypeDef structure that contains the configuration information for the DSI.
ActiveErrorsindicates which error interrupts will be enabled. This parameter can be any combination of
  • DSI_Error_Data_Type.
Return values
HALstatus

Definition at line 496 of file stm32l4xx_hal_dsi.c.

497 {
498  /* Process locked */
499  __HAL_LOCK(hdsi);
500 
501  hdsi->Instance->IER[0U] = 0U;
502  hdsi->Instance->IER[1U] = 0U;
503 
504  /* Store active errors to the handle */
505  hdsi->ErrorMsk = ActiveErrors;
506 
507  if ((ActiveErrors & HAL_DSI_ERROR_ACK) != 0U)
508  {
509  /* Enable the interrupt generation on selected errors */
510  hdsi->Instance->IER[0U] |= DSI_ERROR_ACK_MASK;
511  }
512 
513  if ((ActiveErrors & HAL_DSI_ERROR_PHY) != 0U)
514  {
515  /* Enable the interrupt generation on selected errors */
516  hdsi->Instance->IER[0U] |= DSI_ERROR_PHY_MASK;
517  }
518 
519  if ((ActiveErrors & HAL_DSI_ERROR_TX) != 0U)
520  {
521  /* Enable the interrupt generation on selected errors */
522  hdsi->Instance->IER[1U] |= DSI_ERROR_TX_MASK;
523  }
524 
525  if ((ActiveErrors & HAL_DSI_ERROR_RX) != 0U)
526  {
527  /* Enable the interrupt generation on selected errors */
528  hdsi->Instance->IER[1U] |= DSI_ERROR_RX_MASK;
529  }
530 
531  if ((ActiveErrors & HAL_DSI_ERROR_ECC) != 0U)
532  {
533  /* Enable the interrupt generation on selected errors */
534  hdsi->Instance->IER[1U] |= DSI_ERROR_ECC_MASK;
535  }
536 
537  if ((ActiveErrors & HAL_DSI_ERROR_CRC) != 0U)
538  {
539  /* Enable the interrupt generation on selected errors */
540  hdsi->Instance->IER[1U] |= DSI_ERROR_CRC_MASK;
541  }
542 
543  if ((ActiveErrors & HAL_DSI_ERROR_PSE) != 0U)
544  {
545  /* Enable the interrupt generation on selected errors */
546  hdsi->Instance->IER[1U] |= DSI_ERROR_PSE_MASK;
547  }
548 
549  if ((ActiveErrors & HAL_DSI_ERROR_EOT) != 0U)
550  {
551  /* Enable the interrupt generation on selected errors */
552  hdsi->Instance->IER[1U] |= DSI_ERROR_EOT_MASK;
553  }
554 
555  if ((ActiveErrors & HAL_DSI_ERROR_OVF) != 0U)
556  {
557  /* Enable the interrupt generation on selected errors */
558  hdsi->Instance->IER[1U] |= DSI_ERROR_OVF_MASK;
559  }
560 
561  if ((ActiveErrors & HAL_DSI_ERROR_GEN) != 0U)
562  {
563  /* Enable the interrupt generation on selected errors */
564  hdsi->Instance->IER[1U] |= DSI_ERROR_GEN_MASK;
565  }
566 
567  /* Process Unlocked */
568  __HAL_UNLOCK(hdsi);
569 
570  return HAL_OK;
571 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_DSI_DeInit()

HAL_StatusTypeDef HAL_DSI_DeInit ( DSI_HandleTypeDef hdsi)

De-initializes the DSI peripheral registers to their default reset values.

Parameters
hdsipointer to a DSI_HandleTypeDef structure that contains the configuration information for the DSI.
Return values
HALstatus

Definition at line 438 of file stm32l4xx_hal_dsi.c.

439 {
440  /* Check the DSI handle allocation */
441  if (hdsi == NULL)
442  {
443  return HAL_ERROR;
444  }
445 
446  /* Change DSI peripheral state */
447  hdsi->State = HAL_DSI_STATE_BUSY;
448 
449  /* Disable the DSI wrapper */
450  __HAL_DSI_WRAPPER_DISABLE(hdsi);
451 
452  /* Disable the DSI host */
453  __HAL_DSI_DISABLE(hdsi);
454 
455  /* D-PHY clock and digital disable */
456  hdsi->Instance->PCTLR &= ~(DSI_PCTLR_CKE | DSI_PCTLR_DEN);
457 
458  /* Turn off the DSI PLL */
459  __HAL_DSI_PLL_DISABLE(hdsi);
460 
461  /* Disable the regulator */
462  __HAL_DSI_REG_DISABLE(hdsi);
463 
464 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
465  if (hdsi->MspDeInitCallback == NULL)
466  {
467  hdsi->MspDeInitCallback = HAL_DSI_MspDeInit;
468  }
469  /* DeInit the low level hardware */
470  hdsi->MspDeInitCallback(hdsi);
471 #else
472  /* DeInit the low level hardware */
473  HAL_DSI_MspDeInit(hdsi);
474 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
475 
476  /* Initialise the error code */
477  hdsi->ErrorCode = HAL_DSI_ERROR_NONE;
478 
479  /* Initialize the DSI state*/
480  hdsi->State = HAL_DSI_STATE_RESET;
481 
482  /* Release Lock */
483  __HAL_UNLOCK(hdsi);
484 
485  return HAL_OK;
486 }
__HAL_UNLOCK(hrtc)
return HAL_OK
__weak void HAL_DSI_MspDeInit(DSI_HandleTypeDef *hdsi)
De-initializes the DSI MSP.

◆ HAL_DSI_Init()

HAL_StatusTypeDef HAL_DSI_Init ( DSI_HandleTypeDef hdsi,
DSI_PLLInitTypeDef PLLInit 
)

Initializes the DSI according to the specified parameters in the DSI_InitTypeDef and create the associated handle.

Parameters
hdsipointer to a DSI_HandleTypeDef structure that contains the configuration information for the DSI.
PLLInitpointer to a DSI_PLLInitTypeDef structure that contains the PLL Clock structure definition for the DSI.
Return values
HALstatus

Definition at line 303 of file stm32l4xx_hal_dsi.c.

304 {
305  uint32_t tickstart;
306  uint32_t unitIntervalx4;
307  uint32_t tempIDF;
308 
309  /* Check the DSI handle allocation */
310  if (hdsi == NULL)
311  {
312  return HAL_ERROR;
313  }
314 
315  /* Check function parameters */
316  assert_param(IS_DSI_PLL_NDIV(PLLInit->PLLNDIV));
317  assert_param(IS_DSI_PLL_IDF(PLLInit->PLLIDF));
318  assert_param(IS_DSI_PLL_ODF(PLLInit->PLLODF));
319  assert_param(IS_DSI_AUTO_CLKLANE_CONTROL(hdsi->Init.AutomaticClockLaneControl));
320  assert_param(IS_DSI_NUMBER_OF_LANES(hdsi->Init.NumberOfLanes));
321 
322 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
323  if (hdsi->State == HAL_DSI_STATE_RESET)
324  {
325  /* Reset the DSI callback to the legacy weak callbacks */
326  hdsi->TearingEffectCallback = HAL_DSI_TearingEffectCallback; /* Legacy weak TearingEffectCallback */
327  hdsi->EndOfRefreshCallback = HAL_DSI_EndOfRefreshCallback; /* Legacy weak EndOfRefreshCallback */
328  hdsi->ErrorCallback = HAL_DSI_ErrorCallback; /* Legacy weak ErrorCallback */
329 
330  if (hdsi->MspInitCallback == NULL)
331  {
332  hdsi->MspInitCallback = HAL_DSI_MspInit;
333  }
334  /* Initialize the low level hardware */
335  hdsi->MspInitCallback(hdsi);
336  }
337 #else
338  if (hdsi->State == HAL_DSI_STATE_RESET)
339  {
340  /* Initialize the low level hardware */
341  HAL_DSI_MspInit(hdsi);
342  }
343 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
344 
345  /* Change DSI peripheral state */
346  hdsi->State = HAL_DSI_STATE_BUSY;
347 
348  /**************** Turn on the regulator and enable the DSI PLL ****************/
349 
350  /* Enable the regulator */
351  __HAL_DSI_REG_ENABLE(hdsi);
352 
353  /* Get tick */
354  tickstart = HAL_GetTick();
355 
356  /* Wait until the regulator is ready */
357  while (__HAL_DSI_GET_FLAG(hdsi, DSI_FLAG_RRS) == 0U)
358  {
359  /* Check for the Timeout */
360  if ((HAL_GetTick() - tickstart) > DSI_TIMEOUT_VALUE)
361  {
362  return HAL_TIMEOUT;
363  }
364  }
365 
366  /* Set the PLL division factors */
367  hdsi->Instance->WRPCR &= ~(DSI_WRPCR_PLL_NDIV | DSI_WRPCR_PLL_IDF | DSI_WRPCR_PLL_ODF);
368  hdsi->Instance->WRPCR |= (((PLLInit->PLLNDIV) << 2U) | ((PLLInit->PLLIDF) << 11U) | ((PLLInit->PLLODF) << 16U));
369 
370  /* Enable the DSI PLL */
371  __HAL_DSI_PLL_ENABLE(hdsi);
372 
373  /* Get tick */
374  tickstart = HAL_GetTick();
375 
376  /* Wait for the lock of the PLL */
377  while (__HAL_DSI_GET_FLAG(hdsi, DSI_FLAG_PLLLS) == 0U)
378  {
379  /* Check for the Timeout */
380  if ((HAL_GetTick() - tickstart) > DSI_TIMEOUT_VALUE)
381  {
382  return HAL_TIMEOUT;
383  }
384  }
385 
386  /*************************** Set the PHY parameters ***************************/
387 
388  /* D-PHY clock and digital enable*/
389  hdsi->Instance->PCTLR |= (DSI_PCTLR_CKE | DSI_PCTLR_DEN);
390 
391  /* Clock lane configuration */
392  hdsi->Instance->CLCR &= ~(DSI_CLCR_DPCC | DSI_CLCR_ACR);
393  hdsi->Instance->CLCR |= (DSI_CLCR_DPCC | hdsi->Init.AutomaticClockLaneControl);
394 
395  /* Configure the number of active data lanes */
396  hdsi->Instance->PCONFR &= ~DSI_PCONFR_NL;
397  hdsi->Instance->PCONFR |= hdsi->Init.NumberOfLanes;
398 
399  /************************ Set the DSI clock parameters ************************/
400 
401  /* Set the TX escape clock division factor */
402  hdsi->Instance->CCR &= ~DSI_CCR_TXECKDIV;
403  hdsi->Instance->CCR |= hdsi->Init.TXEscapeCkdiv;
404 
405  /* Calculate the bit period in high-speed mode in unit of 0.25 ns (UIX4) */
406  /* The equation is : UIX4 = IntegerPart( (1000/F_PHY_Mhz) * 4 ) */
407  /* Where : F_PHY_Mhz = (NDIV * HSE_Mhz) / (IDF * ODF) */
408  tempIDF = (PLLInit->PLLIDF > 0U) ? PLLInit->PLLIDF : 1U;
409  unitIntervalx4 = (4000000U * tempIDF * ((1UL << (0x3U & PLLInit->PLLODF)))) / ((HSE_VALUE / 1000U) * PLLInit->PLLNDIV);
410 
411  /* Set the bit period in high-speed mode */
412  hdsi->Instance->WPCR[0U] &= ~DSI_WPCR0_UIX4;
413  hdsi->Instance->WPCR[0U] |= unitIntervalx4;
414 
415  /****************************** Error management *****************************/
416 
417  /* Disable all error interrupts and reset the Error Mask */
418  hdsi->Instance->IER[0U] = 0U;
419  hdsi->Instance->IER[1U] = 0U;
420  hdsi->ErrorMsk = 0U;
421 
422  /* Initialise the error code */
423  hdsi->ErrorCode = HAL_DSI_ERROR_NONE;
424 
425  /* Initialize the DSI state*/
426  hdsi->State = HAL_DSI_STATE_READY;
427 
428  return HAL_OK;
429 }
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
__weak void HAL_DSI_MspInit(DSI_HandleTypeDef *hdsi)
Initializes the DSI MSP.
return HAL_OK
__weak void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *hdsi)
End of Refresh DSI callback.
__weak void HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef *hdsi)
Tearing Effect DSI callback.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__weak void HAL_DSI_ErrorCallback(DSI_HandleTypeDef *hdsi)
Operation Error DSI callback.

◆ HAL_DSI_MspDeInit()

__weak void HAL_DSI_MspDeInit ( DSI_HandleTypeDef hdsi)

De-initializes the DSI MSP.

Parameters
hdsipointer to a DSI_HandleTypeDef structure that contains the configuration information for the DSI.
Return values
None

Definition at line 594 of file stm32l4xx_hal_dsi.c.

595 {
596  /* Prevent unused argument(s) compilation warning */
597  UNUSED(hdsi);
598  /* NOTE : This function Should not be modified, when the callback is needed,
599  the HAL_DSI_MspDeInit could be implemented in the user file
600  */
601 }

◆ HAL_DSI_MspInit()

__weak void HAL_DSI_MspInit ( DSI_HandleTypeDef hdsi)

Initializes the DSI MSP.

Parameters
hdsipointer to a DSI_HandleTypeDef structure that contains the configuration information for the DSI.
Return values
None

Definition at line 579 of file stm32l4xx_hal_dsi.c.

580 {
581  /* Prevent unused argument(s) compilation warning */
582  UNUSED(hdsi);
583  /* NOTE : This function Should not be modified, when the callback is needed,
584  the HAL_DSI_MspInit could be implemented in the user file
585  */
586 }

◆ HAL_DSI_RegisterCallback()

HAL_StatusTypeDef HAL_DSI_RegisterCallback ( DSI_HandleTypeDef hdsi,
HAL_DSI_CallbackIDTypeDef  CallbackID,
pDSI_CallbackTypeDef  pCallback 
)

Register a User DSI Callback To be used instead of the weak predefined callback.

Parameters
hdsidsi handle
CallbackIDID of the callback to be registered This parameter can be one of the following values:
  • HAL_DSI_TEARING_EFFECT_CB_ID Tearing Effect Callback ID
  • HAL_DSI_ENDOF_REFRESH_CB_ID End Of Refresh Callback ID
  • HAL_DSI_ERROR_CB_ID Error Callback ID
  • HAL_DSI_MSPINIT_CB_ID MspInit callback ID
  • HAL_DSI_MSPDEINIT_CB_ID MspDeInit callback ID
pCallbackpointer to the Callback function
Return values
status

Definition at line 618 of file stm32l4xx_hal_dsi.c.

620 {
621  HAL_StatusTypeDef status = HAL_OK;
622 
623  if (pCallback == NULL)
624  {
625  /* Update the error code */
626  hdsi->ErrorCode |= HAL_DSI_ERROR_INVALID_CALLBACK;
627 
628  return HAL_ERROR;
629  }
630  /* Process locked */
631  __HAL_LOCK(hdsi);
632 
633  if (hdsi->State == HAL_DSI_STATE_READY)
634  {
635  switch (CallbackID)
636  {
638  hdsi->TearingEffectCallback = pCallback;
639  break;
640 
642  hdsi->EndOfRefreshCallback = pCallback;
643  break;
644 
645  case HAL_DSI_ERROR_CB_ID :
646  hdsi->ErrorCallback = pCallback;
647  break;
648 
649  case HAL_DSI_MSPINIT_CB_ID :
650  hdsi->MspInitCallback = pCallback;
651  break;
652 
654  hdsi->MspDeInitCallback = pCallback;
655  break;
656 
657  default :
658  /* Update the error code */
659  hdsi->ErrorCode |= HAL_DSI_ERROR_INVALID_CALLBACK;
660  /* Return error status */
661  status = HAL_ERROR;
662  break;
663  }
664  }
665  else if (hdsi->State == HAL_DSI_STATE_RESET)
666  {
667  switch (CallbackID)
668  {
669  case HAL_DSI_MSPINIT_CB_ID :
670  hdsi->MspInitCallback = pCallback;
671  break;
672 
674  hdsi->MspDeInitCallback = pCallback;
675  break;
676 
677  default :
678  /* Update the error code */
679  hdsi->ErrorCode |= HAL_DSI_ERROR_INVALID_CALLBACK;
680  /* Return error status */
681  status = HAL_ERROR;
682  break;
683  }
684  }
685  else
686  {
687  /* Update the error code */
688  hdsi->ErrorCode |= HAL_DSI_ERROR_INVALID_CALLBACK;
689  /* Return error status */
690  status = HAL_ERROR;
691  }
692 
693  /* Release Lock */
694  __HAL_UNLOCK(hdsi);
695 
696  return status;
697 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_DSI_UnRegisterCallback()

HAL_StatusTypeDef HAL_DSI_UnRegisterCallback ( DSI_HandleTypeDef hdsi,
HAL_DSI_CallbackIDTypeDef  CallbackID 
)

Unregister a DSI Callback DSI callabck is redirected to the weak predefined callback.

Parameters
hdsidsi handle
CallbackIDID of the callback to be unregistered This parameter can be one of the following values:
  • HAL_DSI_TEARING_EFFECT_CB_ID Tearing Effect Callback ID
  • HAL_DSI_ENDOF_REFRESH_CB_ID End Of Refresh Callback ID
  • HAL_DSI_ERROR_CB_ID Error Callback ID
  • HAL_DSI_MSPINIT_CB_ID MspInit callback ID
  • HAL_DSI_MSPDEINIT_CB_ID MspDeInit callback ID
Return values
status

Definition at line 712 of file stm32l4xx_hal_dsi.c.

713 {
714  HAL_StatusTypeDef status = HAL_OK;
715 
716  /* Process locked */
717  __HAL_LOCK(hdsi);
718 
719  if (hdsi->State == HAL_DSI_STATE_READY)
720  {
721  switch (CallbackID)
722  {
724  hdsi->TearingEffectCallback = HAL_DSI_TearingEffectCallback; /* Legacy weak TearingEffectCallback */
725  break;
726 
728  hdsi->EndOfRefreshCallback = HAL_DSI_EndOfRefreshCallback; /* Legacy weak EndOfRefreshCallback */
729  break;
730 
731  case HAL_DSI_ERROR_CB_ID :
732  hdsi->ErrorCallback = HAL_DSI_ErrorCallback; /* Legacy weak ErrorCallback */
733  break;
734 
735  case HAL_DSI_MSPINIT_CB_ID :
736  hdsi->MspInitCallback = HAL_DSI_MspInit; /* Legcay weak MspInit Callback */
737  break;
738 
740  hdsi->MspDeInitCallback = HAL_DSI_MspDeInit; /* Legcay weak MspDeInit Callback */
741  break;
742 
743  default :
744  /* Update the error code */
745  hdsi->ErrorCode |= HAL_DSI_ERROR_INVALID_CALLBACK;
746  /* Return error status */
747  status = HAL_ERROR;
748  break;
749  }
750  }
751  else if (hdsi->State == HAL_DSI_STATE_RESET)
752  {
753  switch (CallbackID)
754  {
755  case HAL_DSI_MSPINIT_CB_ID :
756  hdsi->MspInitCallback = HAL_DSI_MspInit; /* Legcay weak MspInit Callback */
757  break;
758 
760  hdsi->MspDeInitCallback = HAL_DSI_MspDeInit; /* Legcay weak MspDeInit Callback */
761  break;
762 
763  default :
764  /* Update the error code */
765  hdsi->ErrorCode |= HAL_DSI_ERROR_INVALID_CALLBACK;
766  /* Return error status */
767  status = HAL_ERROR;
768  break;
769  }
770  }
771  else
772  {
773  /* Update the error code */
774  hdsi->ErrorCode |= HAL_DSI_ERROR_INVALID_CALLBACK;
775  /* Return error status */
776  status = HAL_ERROR;
777  }
778 
779  /* Release Lock */
780  __HAL_UNLOCK(hdsi);
781 
782  return status;
783 }
__weak void HAL_DSI_MspInit(DSI_HandleTypeDef *hdsi)
Initializes the DSI MSP.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__weak void HAL_DSI_MspDeInit(DSI_HandleTypeDef *hdsi)
De-initializes the DSI MSP.
__weak void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *hdsi)
End of Refresh DSI callback.
__weak void HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef *hdsi)
Tearing Effect DSI callback.
__weak void HAL_DSI_ErrorCallback(DSI_HandleTypeDef *hdsi)
Operation Error DSI callback.