STM32L4xx_HAL_Driver  1.14.0
Peripheral Control functions

Peripheral Control functions. More...

Functions

HAL_StatusTypeDef HAL_DMA2D_ConfigLayer (DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
 Configure the DMA2D Layer according to the specified parameters in the DMA2D_HandleTypeDef. More...
 
HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT (DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
 Configure the DMA2D CLUT Transfer. More...
 
HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent (DMA2D_HandleTypeDef *hdma2d, uint32_t Line)
 Configure the line watermark. More...
 
HAL_StatusTypeDef HAL_DMA2D_EnableDeadTime (DMA2D_HandleTypeDef *hdma2d)
 Enable DMA2D dead time feature. More...
 
HAL_StatusTypeDef HAL_DMA2D_DisableDeadTime (DMA2D_HandleTypeDef *hdma2d)
 Disable DMA2D dead time feature. More...
 
HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime (DMA2D_HandleTypeDef *hdma2d, uint8_t DeadTime)
 Configure dead time. More...
 

Detailed Description

Peripheral Control functions.

 ===============================================================================
                    ##### Peripheral Control functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Configure the DMA2D foreground or background layer parameters.
      (+) Configure the DMA2D CLUT transfer.
      (+) Configure the line watermark
      (+) Configure the dead time value.
      (+) Enable or disable the dead time value functionality.

Function Documentation

◆ HAL_DMA2D_ConfigCLUT()

HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT ( DMA2D_HandleTypeDef hdma2d,
DMA2D_CLUTCfgTypeDef  CLUTCfg,
uint32_t  LayerIdx 
)

Configure the DMA2D CLUT Transfer.

Parameters
hdma2dPointer to a DMA2D_HandleTypeDef structure that contains the configuration information for the DMA2D.
CLUTCfgPointer to a DMA2D_CLUTCfgTypeDef structure that contains the configuration information for the color look up table.
LayerIdxDMA2D Layer index. This parameter can be one of the following values: DMA2D_BACKGROUND_LAYER(0) / DMA2D_FOREGROUND_LAYER(1)
Return values
HALstatus

Definition at line 1708 of file stm32l4xx_hal_dma2d.c.

1709 {
1710  /* Check the parameters */
1711  assert_param(IS_DMA2D_LAYER(LayerIdx));
1712  assert_param(IS_DMA2D_CLUT_CM(CLUTCfg.CLUTColorMode));
1713  assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg.Size));
1714 
1715  /* Process locked */
1716  __HAL_LOCK(hdma2d);
1717 
1718  /* Change DMA2D peripheral state */
1719  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1720 
1721  /* Configure the CLUT of the background DMA2D layer */
1722  if(LayerIdx == DMA2D_BACKGROUND_LAYER)
1723  {
1724  /* Write background CLUT memory address */
1725  WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg.pCLUT);
1726 
1727  /* Write background CLUT size and CLUT color mode */
1728  MODIFY_REG(hdma2d->Instance->BGPFCCR, (DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM),
1729  ((CLUTCfg.Size << DMA2D_BGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_BGPFCCR_CCM_Pos)));
1730  }
1731  /* Configure the CLUT of the foreground DMA2D layer */
1732  else
1733  {
1734  /* Write foreground CLUT memory address */
1735  WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg.pCLUT);
1736 
1737  /* Write foreground CLUT size and CLUT color mode */
1738  MODIFY_REG(hdma2d->Instance->FGPFCCR, (DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM),
1739  ((CLUTCfg.Size << DMA2D_FGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_FGPFCCR_CCM_Pos)));
1740  }
1741 
1742  /* Set the DMA2D state to Ready*/
1743  hdma2d->State = HAL_DMA2D_STATE_READY;
1744 
1745  /* Process unlocked */
1746  __HAL_UNLOCK(hdma2d);
1747 
1748  return HAL_OK;
1749 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_DMA2D_StateTypeDef State
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_DMA2D_ConfigDeadTime()

HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime ( DMA2D_HandleTypeDef hdma2d,
uint8_t  DeadTime 
)

Configure dead time.

Note
The dead time value represents the guaranteed minimum number of cycles between two consecutive transactions on the AHB bus.
Parameters
hdma2dDMA2D handle.
DeadTimedead time value.
Return values
HALstatus

Definition at line 1849 of file stm32l4xx_hal_dma2d.c.

1850 {
1851  /* Process Locked */
1852  __HAL_LOCK(hdma2d);
1853 
1854  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1855 
1856  /* Set DMA2D_AMTCR DT field */
1857  MODIFY_REG(hdma2d->Instance->AMTCR, DMA2D_AMTCR_DT, (((uint32_t) DeadTime) << DMA2D_AMTCR_DT_Pos));
1858 
1859  hdma2d->State = HAL_DMA2D_STATE_READY;
1860 
1861  /* Process Unlocked */
1862  __HAL_UNLOCK(hdma2d);
1863 
1864  return HAL_OK;
1865 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_DMA2D_StateTypeDef State
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ HAL_DMA2D_ConfigLayer()

HAL_StatusTypeDef HAL_DMA2D_ConfigLayer ( DMA2D_HandleTypeDef hdma2d,
uint32_t  LayerIdx 
)

Configure the DMA2D Layer according to the specified parameters in the DMA2D_HandleTypeDef.

Parameters
hdma2dPointer to a DMA2D_HandleTypeDef structure that contains the configuration information for the DMA2D.
LayerIdxDMA2D Layer index. This parameter can be one of the following values: DMA2D_BACKGROUND_LAYER(0) / DMA2D_FOREGROUND_LAYER(1)
Return values
HALstatus

Definition at line 1614 of file stm32l4xx_hal_dma2d.c.

1615 {
1616  DMA2D_LayerCfgTypeDef *pLayerCfg;
1617  uint32_t regMask, regValue;
1618 
1619  /* Check the parameters */
1620  assert_param(IS_DMA2D_LAYER(LayerIdx));
1621  assert_param(IS_DMA2D_OFFSET(hdma2d->LayerCfg[LayerIdx].InputOffset));
1622  if(hdma2d->Init.Mode != DMA2D_R2M)
1623  {
1624  assert_param(IS_DMA2D_INPUT_COLOR_MODE(hdma2d->LayerCfg[LayerIdx].InputColorMode));
1625  if(hdma2d->Init.Mode != DMA2D_M2M)
1626  {
1627  assert_param(IS_DMA2D_ALPHA_MODE(hdma2d->LayerCfg[LayerIdx].AlphaMode));
1628  }
1629  }
1630  assert_param(IS_DMA2D_ALPHA_INVERTED(hdma2d->LayerCfg[LayerIdx].AlphaInverted));
1631  assert_param(IS_DMA2D_RB_SWAP(hdma2d->LayerCfg[LayerIdx].RedBlueSwap));
1632 
1633  /* Process locked */
1634  __HAL_LOCK(hdma2d);
1635 
1636  /* Change DMA2D peripheral state */
1637  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1638 
1639  pLayerCfg = &hdma2d->LayerCfg[LayerIdx];
1640 
1641  /* Prepare the value to be written to the BGPFCCR or FGPFCCR register */
1642  regValue = pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << DMA2D_BGPFCCR_AM_Pos) |\
1643  (pLayerCfg->AlphaInverted << DMA2D_BGPFCCR_AI_Pos) | (pLayerCfg->RedBlueSwap << DMA2D_BGPFCCR_RBS_Pos);
1644  regMask = (DMA2D_BGPFCCR_CM | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_ALPHA | DMA2D_BGPFCCR_AI | DMA2D_BGPFCCR_RBS);
1645 
1646 
1647  if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1648  {
1649  regValue |= (pLayerCfg->InputAlpha & DMA2D_BGPFCCR_ALPHA);
1650  }
1651  else
1652  {
1653  regValue |= (pLayerCfg->InputAlpha << DMA2D_BGPFCCR_ALPHA_Pos);
1654  }
1655 
1656  /* Configure the background DMA2D layer */
1657  if(LayerIdx == DMA2D_BACKGROUND_LAYER)
1658  {
1659  /* Write DMA2D BGPFCCR register */
1660  MODIFY_REG(hdma2d->Instance->BGPFCCR, regMask, regValue);
1661 
1662  /* DMA2D BGOR register configuration -------------------------------------*/
1663  WRITE_REG(hdma2d->Instance->BGOR, pLayerCfg->InputOffset);
1664 
1665  /* DMA2D BGCOLR register configuration -------------------------------------*/
1666  if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1667  {
1668  WRITE_REG(hdma2d->Instance->BGCOLR, pLayerCfg->InputAlpha & (DMA2D_BGCOLR_BLUE|DMA2D_BGCOLR_GREEN|DMA2D_BGCOLR_RED));
1669  }
1670  }
1671  /* Configure the foreground DMA2D layer */
1672  else
1673  {
1674 
1675 
1676  /* Write DMA2D FGPFCCR register */
1677  MODIFY_REG(hdma2d->Instance->FGPFCCR, regMask, regValue);
1678 
1679  /* DMA2D FGOR register configuration -------------------------------------*/
1680  WRITE_REG(hdma2d->Instance->FGOR, pLayerCfg->InputOffset);
1681 
1682  /* DMA2D FGCOLR register configuration -------------------------------------*/
1683  if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1684  {
1685  WRITE_REG(hdma2d->Instance->FGCOLR, pLayerCfg->InputAlpha & (DMA2D_FGCOLR_BLUE|DMA2D_FGCOLR_GREEN|DMA2D_FGCOLR_RED));
1686  }
1687  }
1688  /* Initialize the DMA2D state*/
1689  hdma2d->State = HAL_DMA2D_STATE_READY;
1690 
1691  /* Process unlocked */
1692  __HAL_UNLOCK(hdma2d);
1693 
1694  return HAL_OK;
1695 }
DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER]
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
DMA2D Layer structure definition.
__IO HAL_DMA2D_StateTypeDef State
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_DMA2D_DisableDeadTime()

HAL_StatusTypeDef HAL_DMA2D_DisableDeadTime ( DMA2D_HandleTypeDef hdma2d)

Disable DMA2D dead time feature.

Parameters
hdma2dDMA2D handle.
Return values
HALstatus

Definition at line 1823 of file stm32l4xx_hal_dma2d.c.

1824 {
1825  /* Process Locked */
1826  __HAL_LOCK(hdma2d);
1827 
1828  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1829 
1830  /* Clear DMA2D_AMTCR EN bit */
1831  CLEAR_BIT(hdma2d->Instance->AMTCR, DMA2D_AMTCR_EN);
1832 
1833  hdma2d->State = HAL_DMA2D_STATE_READY;
1834 
1835  /* Process Unlocked */
1836  __HAL_UNLOCK(hdma2d);
1837 
1838  return HAL_OK;
1839 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_DMA2D_StateTypeDef State

◆ HAL_DMA2D_EnableDeadTime()

HAL_StatusTypeDef HAL_DMA2D_EnableDeadTime ( DMA2D_HandleTypeDef hdma2d)

Enable DMA2D dead time feature.

Parameters
hdma2dDMA2D handle.
Return values
HALstatus

Definition at line 1800 of file stm32l4xx_hal_dma2d.c.

1801 {
1802  /* Process Locked */
1803  __HAL_LOCK(hdma2d);
1804 
1805  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1806 
1807  /* Set DMA2D_AMTCR EN bit */
1808  SET_BIT(hdma2d->Instance->AMTCR, DMA2D_AMTCR_EN);
1809 
1810  hdma2d->State = HAL_DMA2D_STATE_READY;
1811 
1812  /* Process Unlocked */
1813  __HAL_UNLOCK(hdma2d);
1814 
1815  return HAL_OK;
1816 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_DMA2D_StateTypeDef State

◆ HAL_DMA2D_ProgramLineEvent()

HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent ( DMA2D_HandleTypeDef hdma2d,
uint32_t  Line 
)

Configure the line watermark.

Parameters
hdma2dPointer to a DMA2D_HandleTypeDef structure that contains the configuration information for the DMA2D.
LineLine Watermark configuration (maximum 16-bit long value expected).
Note
HAL_DMA2D_ProgramLineEvent() API enables the transfer watermark interrupt.
The transfer watermark interrupt is disabled once it has occurred.
Return values
HALstatus

Definition at line 1762 of file stm32l4xx_hal_dma2d.c.

1763 {
1764  /* Check the parameters */
1765  assert_param(IS_DMA2D_LINEWATERMARK(Line));
1766 
1767  if (Line > DMA2D_LWR_LW)
1768  {
1769  return HAL_ERROR;
1770  }
1771  else
1772  {
1773  /* Process locked */
1774  __HAL_LOCK(hdma2d);
1775 
1776  /* Change DMA2D peripheral state */
1777  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1778 
1779  /* Sets the Line watermark configuration */
1780  WRITE_REG(hdma2d->Instance->LWR, Line);
1781 
1782  /* Enable the Line interrupt */
1783  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TW);
1784 
1785  /* Initialize the DMA2D state*/
1786  hdma2d->State = HAL_DMA2D_STATE_READY;
1787 
1788  /* Process unlocked */
1789  __HAL_UNLOCK(hdma2d);
1790 
1791  return HAL_OK;
1792  }
1793 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_DMA2D_StateTypeDef State
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))