STM32H735xx HAL User Manual
stm32h7xx_hal_ltdc_ex.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_hal_ltdc_ex.c
00004   * @author  MCD Application Team
00005   * @brief   LTDC Extension HAL module driver.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Includes ------------------------------------------------------------------*/
00020 #include "stm32h7xx_hal.h"
00021 
00022 /** @addtogroup STM32H7xx_HAL_Driver
00023   * @{
00024   */
00025 
00026 #if defined(HAL_LTDC_MODULE_ENABLED) && defined(HAL_DSI_MODULE_ENABLED)
00027 
00028 #if defined (LTDC) && defined (DSI)
00029 
00030 /** @defgroup LTDCEx LTDCEx
00031   * @brief LTDC HAL module driver
00032   * @{
00033   */
00034 
00035 /* Private typedef -----------------------------------------------------------*/
00036 /* Private define ------------------------------------------------------------*/
00037 /* Private macro -------------------------------------------------------------*/
00038 /* Private variables ---------------------------------------------------------*/
00039 /* Private function prototypes -----------------------------------------------*/
00040 /* Exported functions --------------------------------------------------------*/
00041 
00042 /** @defgroup LTDCEx_Exported_Functions LTDC Extended Exported Functions
00043   * @{
00044   */
00045 
00046 /** @defgroup LTDCEx_Exported_Functions_Group1 Initialization and Configuration functions
00047   *  @brief   Initialization and Configuration functions
00048   *
00049 @verbatim
00050  ===============================================================================
00051                 ##### Initialization and Configuration functions #####
00052  ===============================================================================
00053     [..]  This section provides functions allowing to:
00054       (+) Initialize and configure the LTDC
00055 
00056 @endverbatim
00057   * @{
00058   */
00059 
00060 /**
00061   * @brief  Retrieve common parameters from DSI Video mode configuration structure
00062   * @param  hltdc   pointer to a LTDC_HandleTypeDef structure that contains
00063   *                 the configuration information for the LTDC.
00064   * @param  VidCfg  pointer to a DSI_VidCfgTypeDef structure that contains
00065   *                 the DSI video mode configuration parameters
00066   * @note   The implementation of this function is taking into account the LTDC
00067   *         polarities inversion as described in the current LTDC specification
00068   * @retval HAL status
00069   */
00070 HAL_StatusTypeDef HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef *hltdc, DSI_VidCfgTypeDef *VidCfg)
00071 {
00072   /* Retrieve signal polarities from DSI */
00073 
00074   /* The following polarity is inverted:
00075                      LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH */
00076 
00077   /* Note 1 : Code in line w/ Current LTDC specification */
00078   hltdc->Init.DEPolarity = (VidCfg->DEPolarity == DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
00079   hltdc->Init.VSPolarity = (VidCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AH : LTDC_VSPOLARITY_AL;
00080   hltdc->Init.HSPolarity = (VidCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AH : LTDC_HSPOLARITY_AL;
00081 
00082   /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
00083   /* hltdc->Init.DEPolarity = VidCfg->DEPolarity << 29;
00084      hltdc->Init.VSPolarity = VidCfg->VSPolarity << 29;
00085      hltdc->Init.HSPolarity = VidCfg->HSPolarity << 29; */
00086 
00087   /* Retrieve vertical timing parameters from DSI */
00088   hltdc->Init.VerticalSync       = VidCfg->VerticalSyncActive - 1U;
00089   hltdc->Init.AccumulatedVBP     = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch - 1U;
00090   hltdc->Init.AccumulatedActiveH = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + VidCfg->VerticalActive - 1U;
00091   hltdc->Init.TotalHeigh         = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U;
00092 
00093   return HAL_OK;
00094 }
00095 
00096 /**
00097   * @brief  Retrieve common parameters from DSI Adapted command mode configuration structure
00098   * @param  hltdc   pointer to a LTDC_HandleTypeDef structure that contains
00099   *                 the configuration information for the LTDC.
00100   * @param  CmdCfg  pointer to a DSI_CmdCfgTypeDef structure that contains
00101   *                 the DSI command mode configuration parameters
00102   * @note   The implementation of this function is taking into account the LTDC
00103   *         polarities inversion as described in the current LTDC specification
00104   * @retval HAL status
00105   */
00106 HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef *hltdc, DSI_CmdCfgTypeDef *CmdCfg)
00107 {
00108   /* Retrieve signal polarities from DSI */
00109 
00110   /* The following polarities are inverted:
00111                      LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH
00112                      LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH
00113                      LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/
00114 
00115   /* Note 1 : Code in line w/ Current LTDC specification */
00116   hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
00117   hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH;
00118   hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH;
00119 
00120   /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
00121   /* hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29;
00122      hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29;
00123      hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29; */
00124 
00125   return HAL_OK;
00126 }
00127 
00128 /**
00129   * @}
00130   */
00131 
00132 /**
00133   * @}
00134   */
00135 
00136 /**
00137   * @}
00138   */
00139 
00140 #endif /* LTDC && DSI */
00141 
00142 #endif /* HAL_LTCD_MODULE_ENABLED && HAL_DSI_MODULE_ENABLED */
00143 
00144 /**
00145   * @}
00146   */