STM32L4xx_HAL_Driver  1.14.0
DMA2D Private Functions

Functions

static void DMA2D_SetConfig (DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
 Set the DMA2D transfer parameters. More...
 

Detailed Description

Function Documentation

◆ DMA2D_SetConfig()

static void DMA2D_SetConfig ( DMA2D_HandleTypeDef hdma2d,
uint32_t  pdata,
uint32_t  DstAddress,
uint32_t  Width,
uint32_t  Height 
)
static

Set the DMA2D transfer parameters.

Parameters
hdma2dPointer to a DMA2D_HandleTypeDef structure that contains the configuration information for the specified DMA2D.
pdataThe source memory Buffer address
DstAddressThe destination memory Buffer address
WidthThe width of data to be transferred from source to destination.
HeightThe height of data to be transferred from source to destination.
Return values
HALstatus

Definition at line 1933 of file stm32l4xx_hal_dma2d.c.

1934 {
1935  uint32_t tmp;
1936  uint32_t tmp1;
1937  uint32_t tmp2;
1938  uint32_t tmp3;
1939  uint32_t tmp4;
1940 
1941  /* Configure DMA2D data size */
1942  MODIFY_REG(hdma2d->Instance->NLR, (DMA2D_NLR_NL|DMA2D_NLR_PL), (Height| (Width << DMA2D_NLR_PL_Pos)));
1943 
1944  /* Configure DMA2D destination address */
1945  WRITE_REG(hdma2d->Instance->OMAR, DstAddress);
1946 
1947  /* Register to memory DMA2D mode selected */
1948  if (hdma2d->Init.Mode == DMA2D_R2M)
1949  {
1950  tmp1 = pdata & DMA2D_OCOLR_ALPHA_1;
1951  tmp2 = pdata & DMA2D_OCOLR_RED_1;
1952  tmp3 = pdata & DMA2D_OCOLR_GREEN_1;
1953  tmp4 = pdata & DMA2D_OCOLR_BLUE_1;
1954 
1955  /* Prepare the value to be written to the OCOLR register according to the color mode */
1956  if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_ARGB8888)
1957  {
1958  tmp = (tmp3 | tmp2 | tmp1| tmp4);
1959  }
1960  else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_RGB888)
1961  {
1962  tmp = (tmp3 | tmp2 | tmp4);
1963  }
1964  else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_RGB565)
1965  {
1966  tmp2 = (tmp2 >> 19U);
1967  tmp3 = (tmp3 >> 10U);
1968  tmp4 = (tmp4 >> 3U );
1969  tmp = ((tmp3 << 5U) | (tmp2 << 11U) | tmp4);
1970  }
1971  else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_ARGB1555)
1972  {
1973  tmp1 = (tmp1 >> 31U);
1974  tmp2 = (tmp2 >> 19U);
1975  tmp3 = (tmp3 >> 11U);
1976  tmp4 = (tmp4 >> 3U );
1977  tmp = ((tmp3 << 5U) | (tmp2 << 10U) | (tmp1 << 15U) | tmp4);
1978  }
1979  else /* Dhdma2d->Init.ColorMode = DMA2D_OUTPUT_ARGB4444 */
1980  {
1981  tmp1 = (tmp1 >> 28U);
1982  tmp2 = (tmp2 >> 20U);
1983  tmp3 = (tmp3 >> 12U);
1984  tmp4 = (tmp4 >> 4U );
1985  tmp = ((tmp3 << 4U) | (tmp2 << 8U) | (tmp1 << 12U) | tmp4);
1986  }
1987  /* Write to DMA2D OCOLR register */
1988  WRITE_REG(hdma2d->Instance->OCOLR, tmp);
1989  }
1990  else /* M2M, M2M_PFC or M2M_Blending DMA2D Mode */
1991  {
1992  /* Configure DMA2D source address */
1993  WRITE_REG(hdma2d->Instance->FGMAR, pdata);
1994  }
1995 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)