训练营PLSR题目
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.
 
 
 
 
 
 

152 line
5.9 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. /* Note 1 : Code in line w/ Current LTDC specification */
  66. hltdc->Init.DEPolarity = (VidCfg->DEPolarity == \
  67. 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 + \
  78. VidCfg->VerticalActive - 1U;
  79. hltdc->Init.TotalHeigh = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \
  80. VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U;
  81. return HAL_OK;
  82. }
  83. /**
  84. * @brief Retrieve common parameters from DSI Adapted command mode configuration structure
  85. * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
  86. * the configuration information for the LTDC.
  87. * @param CmdCfg pointer to a DSI_CmdCfgTypeDef structure that contains
  88. * the DSI command mode configuration parameters
  89. * @note The implementation of this function is taking into account the LTDC
  90. * polarities inversion as described in the current LTDC specification
  91. * @retval HAL status
  92. */
  93. HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef *hltdc, DSI_CmdCfgTypeDef *CmdCfg)
  94. {
  95. /* Retrieve signal polarities from DSI */
  96. /* The following polarities are inverted:
  97. LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH
  98. LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH
  99. LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/
  100. /* Note 1 : Code in line w/ Current LTDC specification */
  101. hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == \
  102. DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
  103. hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH;
  104. hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH;
  105. /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
  106. /* hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29;
  107. hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29;
  108. hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29; */
  109. return HAL_OK;
  110. }
  111. /**
  112. * @}
  113. */
  114. /**
  115. * @}
  116. */
  117. /**
  118. * @}
  119. */
  120. #endif /* LTDC && DSI */
  121. #endif /* HAL_LTCD_MODULE_ENABLED && HAL_DSI_MODULE_ENABLED */
  122. /**
  123. * @}
  124. */