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 19 /* Includes ------------------------------------------------------------------*/ 20 #include "stm32f4xx_hal.h" 21 22 /** @addtogroup STM32F4xx_HAL_Driver 23 * @{ 24 */ 25 26 #if defined(HAL_LTDC_MODULE_ENABLED) && defined(HAL_DSI_MODULE_ENABLED) 27 28 #if defined (LTDC) && defined (DSI) 29 30 /** @defgroup LTDCEx LTDCEx 31 * @brief LTDC HAL module driver 32 * @{ 33 */ 34 35 /* Private typedef -----------------------------------------------------------*/ 36 /* Private define ------------------------------------------------------------*/ 37 /* Private macro -------------------------------------------------------------*/ 38 /* Private variables ---------------------------------------------------------*/ 39 /* Private function prototypes -----------------------------------------------*/ 40 /* Exported functions --------------------------------------------------------*/ 41 42 /** @defgroup LTDCEx_Exported_Functions LTDC Extended Exported Functions 43 * @{ 44 */ 45 46 /** @defgroup LTDCEx_Exported_Functions_Group1 Initialization and Configuration functions 47 * @brief Initialization and Configuration functions 48 * 49 @verbatim 50 =============================================================================== 51 ##### Initialization and Configuration functions ##### 52 =============================================================================== 53 [..] This section provides functions allowing to: 54 (+) Initialize and configure the LTDC 55 56 @endverbatim 57 * @{ 58 */ 59 60 /** 61 * @brief Retrieve common parameters from DSI Video mode configuration structure 62 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains 63 * the configuration information for the LTDC. 64 * @param VidCfg pointer to a DSI_VidCfgTypeDef structure that contains 65 * the DSI video mode configuration parameters 66 * @note The implementation of this function is taking into account the LTDC 67 * polarities inversion as described in the current LTDC specification 68 * @retval HAL status 69 */ HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef * hltdc,DSI_VidCfgTypeDef * VidCfg)70HAL_StatusTypeDef HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef *hltdc, DSI_VidCfgTypeDef *VidCfg) 71 { 72 /* Retrieve signal polarities from DSI */ 73 74 /* The following polarity is inverted: 75 LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH */ 76 77 /* Note 1 : Code in line w/ Current LTDC specification */ 78 hltdc->Init.DEPolarity = (VidCfg->DEPolarity == \ 79 DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH; 80 hltdc->Init.VSPolarity = (VidCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AH : LTDC_VSPOLARITY_AL; 81 hltdc->Init.HSPolarity = (VidCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AH : LTDC_HSPOLARITY_AL; 82 83 /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */ 84 /* hltdc->Init.DEPolarity = VidCfg->DEPolarity << 29; 85 hltdc->Init.VSPolarity = VidCfg->VSPolarity << 29; 86 hltdc->Init.HSPolarity = VidCfg->HSPolarity << 29; */ 87 88 /* Retrieve vertical timing parameters from DSI */ 89 hltdc->Init.VerticalSync = VidCfg->VerticalSyncActive - 1U; 90 hltdc->Init.AccumulatedVBP = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch - 1U; 91 hltdc->Init.AccumulatedActiveH = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \ 92 VidCfg->VerticalActive - 1U; 93 hltdc->Init.TotalHeigh = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \ 94 VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U; 95 96 return HAL_OK; 97 } 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 */ HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef * hltdc,DSI_CmdCfgTypeDef * CmdCfg)109HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef *hltdc, DSI_CmdCfgTypeDef *CmdCfg) 110 { 111 /* Retrieve signal polarities from DSI */ 112 113 /* The following polarities are inverted: 114 LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH 115 LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH 116 LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/ 117 118 /* Note 1 : Code in line w/ Current LTDC specification */ 119 hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == \ 120 DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH; 121 hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH; 122 hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH; 123 124 /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */ 125 /* hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29; 126 hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29; 127 hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29; */ 128 129 return HAL_OK; 130 } 131 132 /** 133 * @} 134 */ 135 136 /** 137 * @} 138 */ 139 140 /** 141 * @} 142 */ 143 144 #endif /* LTDC && DSI */ 145 146 #endif /* HAL_LTCD_MODULE_ENABLED && HAL_DSI_MODULE_ENABLED */ 147 148 /** 149 * @} 150 */ 151 152