1 /** 2 ****************************************************************************** 3 * @file stm32l4xx_hal_ltdc_ex.c 4 * @author MCD Application Team 5 * @brief LTDC Extension HAL module driver. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2017 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 "stm32l4xx_hal.h" 21 22 /** @addtogroup STM32L4xx_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 #if !defined(POLARITIES_INVERSION_UPDATED) 78 /* Note 1 : Code in line w/ Current LTDC specification */ 79 hltdc->Init.DEPolarity = (VidCfg->DEPolarity == \ 80 DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH; 81 hltdc->Init.VSPolarity = (VidCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AH : LTDC_VSPOLARITY_AL; 82 hltdc->Init.HSPolarity = (VidCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AH : LTDC_HSPOLARITY_AL; 83 #else 84 /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */ 85 hltdc->Init.DEPolarity = VidCfg->DEPolarity << 29; 86 hltdc->Init.VSPolarity = VidCfg->VSPolarity << 29; 87 hltdc->Init.HSPolarity = VidCfg->HSPolarity << 29; 88 #endif /* POLARITIES_INVERSION_UPDATED */ 89 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 + \ 94 VidCfg->VerticalActive - 1U; 95 hltdc->Init.TotalHeigh = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \ 96 VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U; 97 98 return HAL_OK; 99 } 100 101 /** 102 * @brief Retrieve common parameters from DSI Adapted command mode configuration structure 103 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains 104 * the configuration information for the LTDC. 105 * @param CmdCfg pointer to a DSI_CmdCfgTypeDef structure that contains 106 * the DSI command mode configuration parameters 107 * @note The implementation of this function is taking into account the LTDC 108 * polarities inversion as described in the current LTDC specification 109 * @retval HAL status 110 */ HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef * hltdc,DSI_CmdCfgTypeDef * CmdCfg)111HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef *hltdc, DSI_CmdCfgTypeDef *CmdCfg) 112 { 113 /* Retrieve signal polarities from DSI */ 114 115 /* The following polarities are inverted: 116 LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH 117 LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH 118 LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/ 119 120 #if !defined(POLARITIES_INVERSION_UPDATED) 121 /* Note 1 : Code in line w/ Current LTDC specification */ 122 hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == \ 123 DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH; 124 hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH; 125 hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH; 126 #else 127 /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */ 128 hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29; 129 hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29; 130 hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29; 131 #endif /* POLARITIES_INVERSION_UPDATED */ 132 return HAL_OK; 133 } 134 135 /** 136 * @} 137 */ 138 139 /** 140 * @} 141 */ 142 143 /** 144 * @} 145 */ 146 147 #endif /* LTDC && DSI */ 148 149 #endif /* HAL_LTCD_MODULE_ENABLED && HAL_DSI_MODULE_ENABLED */ 150 151 /** 152 * @} 153 */ 154