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.
 
 

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