STM32L4xx_HAL_Driver  1.14.0
LTDC Private Functions

Functions

static void LTDC_SetConfig (LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
 Configure the LTDC peripheral. More...
 

Detailed Description

Function Documentation

◆ LTDC_SetConfig()

static void LTDC_SetConfig ( LTDC_HandleTypeDef hltdc,
LTDC_LayerCfgTypeDef pLayerCfg,
uint32_t  LayerIdx 
)
static

Configure the LTDC peripheral.

Parameters
hltdcPointer to a LTDC_HandleTypeDef structure that contains the configuration information for the LTDC.
pLayerCfgPointer LTDC Layer Configuration structure
LayerIdxLTDC Layer index. This parameter can be one of the following values: LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
Return values
None

Definition at line 2076 of file stm32l4xx_hal_ltdc.c.

2077 {
2078  uint32_t tmp;
2079  uint32_t tmp1;
2080  uint32_t tmp2;
2081 
2082  /* Configure the horizontal start and stop position */
2083  tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U)) << 16U);
2084  LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
2085  LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U) + 1U) | tmp);
2086 
2087  /* Configure the vertical start and stop position */
2088  tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16U);
2089  LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
2090  LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1U) | tmp);
2091 
2092  /* Specifies the pixel format */
2093  LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
2094  LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
2095 
2096  /* Configure the default color values */
2097  tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8U);
2098  tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16U);
2099  tmp2 = (pLayerCfg->Alpha0 << 24U);
2100  LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
2101  LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
2102 
2103  /* Specifies the constant alpha value */
2104  LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
2105  LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
2106 
2107  /* Specifies the blending factors */
2108  LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
2109  LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
2110 
2111  /* Configure the color frame buffer start address */
2112  LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
2113  LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
2114 
2115  if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
2116  {
2117  tmp = 4U;
2118  }
2119  else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
2120  {
2121  tmp = 3U;
2122  }
2123  else if ((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
2124  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
2125  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
2126  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
2127  {
2128  tmp = 2U;
2129  }
2130  else
2131  {
2132  tmp = 1U;
2133  }
2134 
2135  /* Configure the color frame buffer pitch in byte */
2136  LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
2137  LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16U) | (((pLayerCfg->WindowX1 - pLayerCfg->WindowX0) * tmp) + 3U));
2138  /* Configure the frame buffer line number */
2139  LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
2140  LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
2141 
2142  /* Enable LTDC_Layer by setting LEN bit */
2143  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
2144 }
LTDC_ColorTypeDef Backcolor