STM32L486xx HAL User Manual
stm32l4xx_hal_ltdc_ex.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_ltdc_ex.c
00004   * @author  MCD Application Team
00005   * @brief   LTDC Extension HAL module driver.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00010   *
00011   * Redistribution and use in source and binary forms, with or without modification,
00012   * are permitted provided that the following conditions are met:
00013   *   1. Redistributions of source code must retain the above copyright notice,
00014   *      this list of conditions and the following disclaimer.
00015   *   2. Redistributions in binary form must reproduce the above copyright notice,
00016   *      this list of conditions and the following disclaimer in the documentation
00017   *      and/or other materials provided with the distribution.
00018   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00019   *      may be used to endorse or promote products derived from this software
00020   *      without specific prior written permission.
00021   *
00022   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00026   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032   *
00033   ******************************************************************************
00034   */
00035 
00036 /* Includes ------------------------------------------------------------------*/
00037 #include "stm32l4xx_hal.h"
00038 
00039 /** @addtogroup STM32L4xx_HAL_Driver
00040   * @{
00041   */
00042 
00043 #if defined (LTDC) && defined (DSI)
00044 
00045 /** @defgroup LTDCEx LTDCEx
00046   * @brief LTDC HAL module driver
00047   * @{
00048   */
00049 
00050 #if defined(HAL_LTDC_MODULE_ENABLED) && defined(HAL_DSI_MODULE_ENABLED)
00051 
00052 /* Private typedef -----------------------------------------------------------*/
00053 /* Private define ------------------------------------------------------------*/
00054 /* Private macro -------------------------------------------------------------*/
00055 /* Private variables ---------------------------------------------------------*/
00056 /* Private function prototypes -----------------------------------------------*/
00057 /* Exported functions --------------------------------------------------------*/
00058 
00059 /** @defgroup LTDCEx_Exported_Functions LTDC Extended Exported Functions
00060   * @{
00061   */
00062 
00063 /** @defgroup LTDCEx_Exported_Functions_Group1 Initialization and Configuration functions
00064  *  @brief   Initialization and Configuration functions
00065  *
00066 @verbatim
00067  ===============================================================================
00068                 ##### Initialization and Configuration functions #####
00069  ===============================================================================
00070     [..]  This section provides functions allowing to:
00071       (+) Initialize and configure the LTDC
00072 
00073 @endverbatim
00074   * @{
00075   */
00076 
00077 /**
00078   * @brief  Retrieve common parameters from DSI Video mode configuration structure
00079   * @param  hltdc   pointer to a LTDC_HandleTypeDef structure that contains
00080   *                 the configuration information for the LTDC.
00081   * @param  VidCfg  pointer to a DSI_VidCfgTypeDef structure that contains
00082   *                 the DSI video mode configuration parameters
00083   * @note   The implementation of this function is taking into account the LTDC
00084   *         polarities inversion as described in the current LTDC specification
00085   * @retval HAL status
00086   */
00087 HAL_StatusTypeDef HAL_LTDCEx_StructInitFromVideoConfig(LTDC_HandleTypeDef* hltdc, DSI_VidCfgTypeDef *VidCfg)
00088 {
00089   /* Retrieve signal polarities from DSI */
00090 
00091   /* The following polarity is inverted:
00092                      LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH */
00093 
00094   /* Note 1 : Code in line w/ Current LTDC specification */
00095   hltdc->Init.DEPolarity = (VidCfg->DEPolarity == DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
00096   hltdc->Init.VSPolarity = (VidCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AH : LTDC_VSPOLARITY_AL;
00097   hltdc->Init.HSPolarity = (VidCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AH : LTDC_HSPOLARITY_AL;
00098 
00099   /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
00100   /* hltdc->Init.DEPolarity = VidCfg->DEPolarity << 29;
00101      hltdc->Init.VSPolarity = VidCfg->VSPolarity << 29;
00102      hltdc->Init.HSPolarity = VidCfg->HSPolarity << 29; */
00103 
00104   /* Retrieve vertical timing parameters from DSI */
00105   hltdc->Init.VerticalSync       = VidCfg->VerticalSyncActive - 1U;
00106   hltdc->Init.AccumulatedVBP     = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch - 1U;
00107   hltdc->Init.AccumulatedActiveH = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + VidCfg->VerticalActive - 1U;
00108   hltdc->Init.TotalHeigh         = VidCfg->VerticalSyncActive + VidCfg->VerticalBackPorch + VidCfg->VerticalActive + VidCfg->VerticalFrontPorch - 1U;
00109 
00110   return HAL_OK;
00111 }
00112 
00113 /**
00114   * @brief  Retrieve common parameters from DSI Adapted command mode configuration structure
00115   * @param  hltdc   pointer to a LTDC_HandleTypeDef structure that contains
00116   *                 the configuration information for the LTDC.
00117   * @param  CmdCfg  pointer to a DSI_CmdCfgTypeDef structure that contains
00118   *                 the DSI command mode configuration parameters
00119   * @note   The implementation of this function is taking into account the LTDC
00120   *         polarities inversion as described in the current LTDC specification
00121   * @retval HAL status
00122   */
00123 HAL_StatusTypeDef HAL_LTDCEx_StructInitFromAdaptedCommandConfig(LTDC_HandleTypeDef* hltdc, DSI_CmdCfgTypeDef *CmdCfg)
00124 {
00125   /* Retrieve signal polarities from DSI */
00126 
00127   /* The following polarities are inverted:
00128                      LTDC_DEPOLARITY_AL <-> LTDC_DEPOLARITY_AH
00129                      LTDC_VSPOLARITY_AL <-> LTDC_VSPOLARITY_AH
00130                      LTDC_HSPOLARITY_AL <-> LTDC_HSPOLARITY_AH)*/
00131 
00132   /* Note 1 : Code in line w/ Current LTDC specification */
00133   hltdc->Init.DEPolarity = (CmdCfg->DEPolarity == DSI_DATA_ENABLE_ACTIVE_HIGH) ? LTDC_DEPOLARITY_AL : LTDC_DEPOLARITY_AH;
00134   hltdc->Init.VSPolarity = (CmdCfg->VSPolarity == DSI_VSYNC_ACTIVE_HIGH) ? LTDC_VSPOLARITY_AL : LTDC_VSPOLARITY_AH;
00135   hltdc->Init.HSPolarity = (CmdCfg->HSPolarity == DSI_HSYNC_ACTIVE_HIGH) ? LTDC_HSPOLARITY_AL : LTDC_HSPOLARITY_AH;
00136 
00137   /* Note 2: Code to be used in case LTDC polarities inversion updated in the specification */
00138   /* hltdc->Init.DEPolarity = CmdCfg->DEPolarity << 29;
00139      hltdc->Init.VSPolarity = CmdCfg->VSPolarity << 29;
00140      hltdc->Init.HSPolarity = CmdCfg->HSPolarity << 29; */
00141 
00142   return HAL_OK;
00143 }
00144 
00145 /**
00146   * @}
00147   */
00148 
00149 /**
00150   * @}
00151   */
00152 
00153 #endif /* HAL_LTCD_MODULE_ENABLED && HAL_DSI_MODULE_ENABLED */
00154 
00155 /**
00156   * @}
00157   */
00158 
00159 #endif /* LTDC && DSI */
00160 
00161 /**
00162   * @}
00163   */
00164 
00165 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/