Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:08

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_ltdc_ex.c
0004   * @author  MCD Application Team
0005   * @brief   LTDC Extension HAL module driver.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file
0013   * in the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   *
0016   ******************************************************************************
0017   */
0018 
0019 /* Includes ------------------------------------------------------------------*/
0020 #include "stm32h7xx_hal.h"
0021 
0022 /** @addtogroup STM32H7xx_HAL_Driver
0023   * @{
0024   */
0025 
0026 #if defined(HAL_LTDC_MODULE_ENABLED) && defined(HAL_DSI_MODULE_ENABLED)
0027 
0028 #if defined (LTDC) && defined (DSI)
0029 
0030 /** @defgroup LTDCEx LTDCEx
0031   * @ingroup RTEMSBSPsARMSTM32H7
0032   * @brief LTDC HAL module driver
0033   * @{
0034   */
0035 
0036 /* Private typedef -----------------------------------------------------------*/
0037 /* Private define ------------------------------------------------------------*/
0038 /* Private macro -------------------------------------------------------------*/
0039 /* Private variables ---------------------------------------------------------*/
0040 /* Private function prototypes -----------------------------------------------*/
0041 /* Exported functions --------------------------------------------------------*/
0042 
0043 /** @defgroup LTDCEx_Exported_Functions LTDC Extended Exported Functions
0044   * @ingroup RTEMSBSPsARMSTM32H7
0045   * @{
0046   */
0047 
0048 /** @defgroup LTDCEx_Exported_Functions_Group1 Initialization and Configuration functions
0049   * @ingroup RTEMSBSPsARMSTM32H7
0050   *  @brief   Initialization and Configuration functions
0051   *
0052 @verbatim
0053  ===============================================================================
0054                 ##### Initialization and Configuration functions #####
0055  ===============================================================================
0056     [..]  This section provides functions allowing to:
0057       (+) Initialize and configure the LTDC
0058 
0059 @endverbatim
0060   * @{
0061   */
0062 
0063 /**
0064   * @brief  Retrieve common parameters from DSI Video mode configuration structure
0065   * @param  hltdc   pointer to a LTDC_HandleTypeDef structure that contains
0066   *                 the configuration information for the LTDC.
0067   * @param  VidCfg  pointer to a DSI_VidCfgTypeDef structure that contains
0068   *                 the DSI video mode configuration parameters
0069   * @note   The implementation of this function is taking into account the LTDC
0070   *         polarities inversion as described in the current LTDC specification
0071   * @retval HAL status
0072   */
0073 HAL_StatusTypeDef HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef *hltdc, DSI_VidCfgTypeDef *VidCfg)
0074 {
0075   /* Retrieve signal polarities from DSI */
0076 
0077   /* The following polarity is inverted:
0078                      LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH */
0079 
0080 #if !defined(POLARITIES_INVERSION_UPDATED)
0081   /* Note 1 : Code in line w/ Current LTDC specification */
0082   hltdc->Init.DEPolarity = (VidCfg->DEPolarity == \
0083                             DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
0084   hltdc->Init.VSPolarity = (VidCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AH : LTDC_VSPOLARITY_AL;
0085   hltdc->Init.HSPolarity = (VidCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AH : LTDC_HSPOLARITY_AL;
0086 #else
0087   /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
0088   hltdc->Init.DEPolarity = VidCfg->DEPolarity << 29;
0089   hltdc->Init.VSPolarity = VidCfg->VSPolarity << 29;
0090   hltdc->Init.HSPolarity = VidCfg->HSPolarity << 29;
0091 #endif /* POLARITIES_INVERSION_UPDATED */
0092 
0093   /* Retrieve vertical timing parameters from DSI */
0094   hltdc->Init.VerticalSync       = VidCfg->VerticalSyncActive - 1U;
0095   hltdc->Init.AccumulatedVBP     = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch - 1U;
0096   hltdc->Init.AccumulatedActiveH = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \
0097                                    VidCfg->VerticalActive - 1U;
0098   hltdc->Init.TotalHeigh         = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + \
0099                                    VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U;
0100 
0101   return HAL_OK;
0102 }
0103 
0104 /**
0105   * @brief  Retrieve common parameters from DSI Adapted command mode configuration structure
0106   * @param  hltdc   pointer to a LTDC_HandleTypeDef structure that contains
0107   *                 the configuration information for the LTDC.
0108   * @param  CmdCfg  pointer to a DSI_CmdCfgTypeDef structure that contains
0109   *                 the DSI command mode configuration parameters
0110   * @note   The implementation of this function is taking into account the LTDC
0111   *         polarities inversion as described in the current LTDC specification
0112   * @retval HAL status
0113   */
0114 HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef *hltdc, DSI_CmdCfgTypeDef *CmdCfg)
0115 {
0116   /* Retrieve signal polarities from DSI */
0117 
0118   /* The following polarities are inverted:
0119                      LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH
0120                      LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH
0121                      LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/
0122 
0123 #if !defined(POLARITIES_INVERSION_UPDATED)
0124   /* Note 1 : Code in line w/ Current LTDC specification */
0125   hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == \
0126                             DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
0127   hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH;
0128   hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH;
0129 #else
0130   /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
0131   hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29;
0132   hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29;
0133   hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29;
0134 #endif /* POLARITIES_INVERSION_UPDATED */
0135   return HAL_OK;
0136 }
0137 
0138 /**
0139   * @}
0140   */
0141 
0142 /**
0143   * @}
0144   */
0145 
0146 /**
0147   * @}
0148   */
0149 
0150 #endif /* LTDC && DSI */
0151 
0152 #endif /* HAL_LTCD_MODULE_ENABLED && HAL_DSI_MODULE_ENABLED */
0153 
0154 /**
0155   * @}
0156   */
0157