Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

155 righe
6.1 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_ltdc_ex.c
  4. * @author MCD Application Team
  5. * @brief LTDC Extension HAL module driver.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Includes ------------------------------------------------------------------*/
  19. #include "stm32f4xx_hal.h"
  20. /** @addtogroup STM32F4xx_HAL_Driver
  21. * @{
  22. */
  23. #if defined(HAL_LTDC_MODULE_ENABLED) && defined(HAL_DSI_MODULE_ENABLED)
  24. #if defined (LTDC) && defined (DSI)
  25. /** @defgroup LTDCEx LTDCEx
  26. * @brief LTDC HAL module driver
  27. * @{
  28. */
  29. /* Private typedef -----------------------------------------------------------*/
  30. /* Private define ------------------------------------------------------------*/
  31. /* Private macro -------------------------------------------------------------*/
  32. /* Private variables ---------------------------------------------------------*/
  33. /* Private function prototypes -----------------------------------------------*/
  34. /* Exported functions --------------------------------------------------------*/
  35. /** @defgroup LTDCEx_Exported_Functions LTDC Extended Exported Functions
  36. * @{
  37. */
  38. /** @defgroup LTDCEx_Exported_Functions_Group1 Initialization and Configuration functions
  39. * @brief Initialization and Configuration functions
  40. *
  41. @verbatim
  42. ===============================================================================
  43. ##### Initialization and Configuration functions #####
  44. ===============================================================================
  45. [..] This section provides functions allowing to:
  46. (+) Initialize and configure the LTDC
  47. @endverbatim
  48. * @{
  49. */
  50. /**
  51. * @brief Retrieve common parameters from DSI Video mode configuration structure
  52. * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
  53. * the configuration information for the LTDC.
  54. * @param VidCfg pointer to a DSI_VidCfgTypeDef structure that contains
  55. * the DSI video mode configuration parameters
  56. * @note The implementation of this function is taking into account the LTDC
  57. * polarities inversion as described in the current LTDC specification
  58. * @retval HAL status
  59. */
  60. HAL_StatusTypeDef HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef *hltdc, DSI_VidCfgTypeDef *VidCfg)
  61. {
  62. /* Retrieve signal polarities from DSI */
  63. /* The following polarity is inverted:
  64. LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH */
  65. #if !defined(POLARITIES_INVERSION_UPDATED)
  66. /* Note 1 : Code in line w/ Current LTDC specification */
  67. hltdc->Init.DEPolarity = (VidCfg->DEPolarity == \
  68. DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
  69. hltdc->Init.VSPolarity = (VidCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AH : LTDC_VSPOLARITY_AL;
  70. hltdc->Init.HSPolarity = (VidCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AH : LTDC_HSPOLARITY_AL;
  71. #else
  72. /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
  73. hltdc->Init.DEPolarity = VidCfg->DEPolarity << 29;
  74. hltdc->Init.VSPolarity = VidCfg->VSPolarity << 29;
  75. hltdc->Init.HSPolarity = VidCfg->HSPolarity << 29;
  76. #endif /* POLARITIES_INVERSION_UPDATED */
  77. /* Retrieve vertical timing parameters from DSI */
  78. hltdc->Init.VerticalSync = VidCfg->VerticalSyncActive - 1U;
  79. hltdc->Init.AccumulatedVBP = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch - 1U;
  80. hltdc->Init.AccumulatedActiveH = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \
  81. VidCfg->VerticalActive - 1U;
  82. hltdc->Init.TotalHeigh = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \
  83. VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U;
  84. return HAL_OK;
  85. }
  86. /**
  87. * @brief Retrieve common parameters from DSI Adapted command mode configuration structure
  88. * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
  89. * the configuration information for the LTDC.
  90. * @param CmdCfg pointer to a DSI_CmdCfgTypeDef structure that contains
  91. * the DSI command mode configuration parameters
  92. * @note The implementation of this function is taking into account the LTDC
  93. * polarities inversion as described in the current LTDC specification
  94. * @retval HAL status
  95. */
  96. HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef *hltdc, DSI_CmdCfgTypeDef *CmdCfg)
  97. {
  98. /* Retrieve signal polarities from DSI */
  99. /* The following polarities are inverted:
  100. LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH
  101. LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH
  102. LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/
  103. #if !defined(POLARITIES_INVERSION_UPDATED)
  104. /* Note 1 : Code in line w/ Current LTDC specification */
  105. hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == \
  106. DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
  107. hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH;
  108. hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH;
  109. #else
  110. /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
  111. hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29;
  112. hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29;
  113. hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29;
  114. #endif /* POLARITIES_INVERSION_UPDATED */
  115. return HAL_OK;
  116. }
  117. /**
  118. * @}
  119. */
  120. /**
  121. * @}
  122. */
  123. /**
  124. * @}
  125. */
  126. #endif /* LTDC && DSI */
  127. #endif /* HAL_LTCD_MODULE_ENABLED && HAL_DSI_MODULE_ENABLED */
  128. /**
  129. * @}
  130. */