stm32f4xx_hal_ltdc_ex.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Includes ------------------------------------------------------------------*/
  36. #include "stm32f4xx_hal.h"
  37. /** @addtogroup STM32F4xx_HAL_Driver
  38. * @{
  39. */
  40. /** @defgroup LTDCEx LTDCEx
  41. * @brief LTDC HAL module driver
  42. * @{
  43. */
  44. #ifdef HAL_LTDC_MODULE_ENABLED
  45. /* Private typedef -----------------------------------------------------------*/
  46. /* Private define ------------------------------------------------------------*/
  47. /* Private macro -------------------------------------------------------------*/
  48. /* Private variables ---------------------------------------------------------*/
  49. /* Private function prototypes -----------------------------------------------*/
  50. /* Exported functions --------------------------------------------------------*/
  51. /** @defgroup LTDCEx_Exported_Functions LTDC Extended Exported Functions
  52. * @{
  53. */
  54. /** @defgroup LTDCEx_Exported_Functions_Group1 Initialization and Configuration functions
  55. * @brief Initialization and Configuration functions
  56. *
  57. @verbatim
  58. ===============================================================================
  59. ##### Initialization and Configuration functions #####
  60. ===============================================================================
  61. [..] This section provides functions allowing to:
  62. (+) Initialize and configure the LTDC
  63. @endverbatim
  64. * @{
  65. */
  66. #if defined(STM32F469xx) || defined(STM32F479xx)
  67. /**
  68. * @brief Retrieve common parameters from DSI Video mode configuration structure
  69. * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
  70. * the configuration information for the LTDC.
  71. * @param VidCfg pointer to a DSI_VidCfgTypeDef structure that contains
  72. * the DSI video mode configuration parameters
  73. * @note The implementation of this function is taking into account the LTDC
  74. * polarities inversion as described in the current LTDC specification
  75. * @retval HAL status
  76. */
  77. HAL_StatusTypeDef HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef* hltdc, DSI_VidCfgTypeDef *VidCfg)
  78. {
  79. /* Retrieve signal polarities from DSI */
  80. /* The following polarity is inverted:
  81. LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH */
  82. /* Note 1 : Code in line w/ Current LTDC specification */
  83. hltdc->Init.DEPolarity = (VidCfg->DEPolarity == DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
  84. hltdc->Init.VSPolarity = (VidCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AH : LTDC_VSPOLARITY_AL;
  85. hltdc->Init.HSPolarity = (VidCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AH : LTDC_HSPOLARITY_AL;
  86. /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
  87. /* hltdc->Init.DEPolarity = VidCfg->DEPolarity << 29;
  88. hltdc->Init.VSPolarity = VidCfg->VSPolarity << 29;
  89. hltdc->Init.HSPolarity = VidCfg->HSPolarity << 29; */
  90. /* Retrieve vertical timing parameters from DSI */
  91. hltdc->Init.VerticalSync = VidCfg->VerticalSyncActive - 1U;
  92. hltdc->Init.AccumulatedVBP = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch - 1U;
  93. hltdc->Init.AccumulatedActiveH = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + VidCfg->VerticalActive - 1U;
  94. hltdc->Init.TotalHeigh = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U;
  95. return HAL_OK;
  96. }
  97. /**
  98. * @brief Retrieve common parameters from DSI Adapted command mode configuration structure
  99. * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
  100. * the configuration information for the LTDC.
  101. * @param CmdCfg pointer to a DSI_CmdCfgTypeDef structure that contains
  102. * the DSI command mode configuration parameters
  103. * @note The implementation of this function is taking into account the LTDC
  104. * polarities inversion as described in the current LTDC specification
  105. * @retval HAL status
  106. */
  107. HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef* hltdc, DSI_CmdCfgTypeDef *CmdCfg)
  108. {
  109. /* Retrieve signal polarities from DSI */
  110. /* The following polarities are inverted:
  111. LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH
  112. LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH
  113. LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/
  114. /* Note 1 : Code in line w/ Current LTDC specification */
  115. hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
  116. hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH;
  117. hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH;
  118. /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
  119. /* hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29;
  120. hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29;
  121. hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29; */
  122. return HAL_OK;
  123. }
  124. #endif /* STM32F469xx || STM32F479xx */
  125. /**
  126. * @}
  127. */
  128. /**
  129. * @}
  130. */
  131. #endif /* HAL_DCMI_MODULE_ENABLED */
  132. /**
  133. * @}
  134. */
  135. /**
  136. * @}
  137. */
  138. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/