You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

163 lines
7.2 KiB

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