mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
369:2e96f1b71984
Parent:
226:b062af740e40
--- a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c	Mon Oct 27 08:00:06 2014 +0000
+++ b/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c	Mon Oct 27 09:45:07 2014 +0000
@@ -2,8 +2,8 @@
   ******************************************************************************
   * @file    stm32f4xx_hal_dma2d.c
   * @author  MCD Application Team
-  * @version V1.1.0RC2
-  * @date    14-May-2014
+  * @version V1.1.0
+  * @date    19-June-2014
   * @brief   DMA2D HAL module driver.
   *          This file provides firmware functions to manage the following 
   *          functionalities of the DMA2D peripheral:
@@ -46,8 +46,7 @@
 
          -@-   In Register-to-Memory transfer mode, the pdata parameter is the register
                color, in Memory-to-memory or memory-to-memory with pixel format
-               conversion the pdata is the source address and it is the color value 
-               for the A4 or A8 mode.
+               conversion the pdata is the source address.
 
          -@-   Configure the foreground source address, the background source address, 
                the Destination and data length and Enable the transfer using 
@@ -334,8 +333,7 @@
   * @param  pdata:      Configure the source memory Buffer address if 
   *                     the memory to memory or memory to memory with pixel format 
   *                     conversion DMA2D mode is selected, and configure 
-  *                     the color value if register to memory DMA2D mode is selected
-  *                     or the color value for the A4 or A8 mode.
+  *                     the color value if register to memory DMA2D mode is selected.
   * @param  DstAddress: The destination memory Buffer address.
   * @param  Width:      The width of data to be transferred from source to destination.
   * @param  Heigh:      The heigh of data to be transferred from source to destination.
@@ -372,8 +370,7 @@
   * @param  pdata:      Configure the source memory Buffer address if 
   *                     the memory to memory or memory to memory with pixel format 
   *                     conversion DMA2D mode is selected, and configure 
-  *                     the color value if register to memory DMA2D mode is selected
-  *                     or the color value for the A4 or A8 mode.
+  *                     the color value if register to memory DMA2D mode is selected.
   * @param  DstAddress: The destination memory Buffer address.
   * @param  Width:      The width of data to be transferred from source to destination.
   * @param  Heigh:      The heigh of data to be transferred from source to destination.
@@ -417,8 +414,7 @@
   * @param  hdma2d:      pointer to a DMA2D_HandleTypeDef structure that contains
   *                      the configuration information for the DMA2D.  
   * @param  SrcAddress1: The source memory Buffer address of the foreground layer.
-  * @param  SrcAddress2: The source memory Buffer address of the background layer
-  *                      or the color value for the A4 or A8 mode.
+  * @param  SrcAddress2: The source memory Buffer address of the background layer.
   * @param  DstAddress:  The destination memory Buffer address
   * @param  Width:       The width of data to be transferred from source to destination.
   * @param  Heigh:       The heigh of data to be transferred from source to destination.
@@ -439,15 +435,8 @@
   /* Disable the Peripheral */
   __HAL_DMA2D_DISABLE(hdma2d);
 
-  if((hdma2d->LayerCfg[0].InputColorMode == CM_A4) || (hdma2d->LayerCfg[0].InputColorMode == CM_A8))
-  {
-    hdma2d->Instance->BGCOLR = SrcAddress2;
-  }
-  else
-  {
   /* Configure DMA2D Stream source2 address */
   hdma2d->Instance->BGMAR = SrcAddress2;
-  }
 
   /* Configure the source, destination address and the data size */
   DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Heigh);
@@ -463,8 +452,7 @@
   * @param  hdma2d:     pointer to a DMA2D_HandleTypeDef structure that contains
   *                     the configuration information for the DMA2D.  
   * @param  SrcAddress1: The source memory Buffer address of the foreground layer.
-  * @param  SrcAddress2: The source memory Buffer address of the background layer
-  *                      or the color value for the A4 or A8 mode.
+  * @param  SrcAddress2: The source memory Buffer address of the background layer.
   * @param  DstAddress:  The destination memory Buffer address.
   * @param  Width:       The width of data to be transferred from source to destination.
   * @param  Heigh:       The heigh of data to be transferred from source to destination.
@@ -484,16 +472,9 @@
 
   /* Disable the Peripheral */
   __HAL_DMA2D_DISABLE(hdma2d);
-
-  if ((hdma2d->LayerCfg[0].InputColorMode == CM_A4) || (hdma2d->LayerCfg[0].InputColorMode == CM_A8))
-  {
-    hdma2d->Instance->BGCOLR = SrcAddress2;
-  }
-  else
-  {  
-    /* Configure DMA2D Stream source2 address */
-    hdma2d->Instance->BGMAR = SrcAddress2;
-  }
+ 
+  /* Configure DMA2D Stream source2 address */
+  hdma2d->Instance->BGMAR = SrcAddress2;
 
   /* Configure the source, destination address and the data size */
   DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Heigh);
@@ -521,18 +502,18 @@
   */
 HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d)
 {
-  uint32_t timeout = 0x00;
+  uint32_t tickstart = 0;
 
   /* Disable the DMA2D */
   __HAL_DMA2D_DISABLE(hdma2d);
 
-  /* Get timeout */
-  timeout = HAL_GetTick() + HAL_TIMEOUT_DMA2D_ABORT;
+  /* Get tick */
+  tickstart = HAL_GetTick();
 
   /* Check if the DMA2D is effectively disabled */
   while((hdma2d->Instance->CR & DMA2D_CR_START) != 0)
   {
-    if(HAL_GetTick() >= timeout)
+    if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DMA2D_ABORT)
     {
       /* Update error code */
       hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
@@ -563,18 +544,18 @@
   */
 HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d)
 {
-  uint32_t timeout = 0x00;
+  uint32_t tickstart = 0;
 
   /* Suspend the DMA2D transfer */
   hdma2d->Instance->CR |= DMA2D_CR_SUSP;
 
-  /* Get timeout */
-  timeout = HAL_GetTick() + HAL_TIMEOUT_DMA2D_SUSPEND;
+  /* Get tick */
+  tickstart = HAL_GetTick();
 
   /* Check if the DMA2D is effectively suspended */
   while((hdma2d->Instance->CR & DMA2D_CR_SUSP) != DMA2D_CR_SUSP)
   {
-    if(HAL_GetTick() >= timeout)
+    if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DMA2D_SUSPEND)
     {
       /* Update error code */
       hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
@@ -618,13 +599,13 @@
 HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout)
 {
   uint32_t tmp, tmp1;
-  uint32_t timeout = 0x00;
+  uint32_t tickstart = 0;
 
   /* Polling for DMA2D transfer */
   if((hdma2d->Instance->CR & DMA2D_CR_START) != 0)
   {
-    /* Get timeout */
-    timeout = HAL_GetTick() + Timeout;
+   /* Get tick */
+   tickstart = HAL_GetTick();
 
     while(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) == RESET)
     {
@@ -648,7 +629,7 @@
       /* Check for the Timeout */
       if(Timeout != HAL_MAX_DELAY)
       {
-        if(HAL_GetTick() >= timeout)
+        if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
         {
           /* Process unlocked */
           __HAL_UNLOCK(hdma2d);
@@ -667,8 +648,8 @@
   /* Polling for CLUT loading */
   if((hdma2d->Instance->FGPFCCR & DMA2D_FGPFCCR_START) != 0)
   {
-    /* Get timeout */
-    timeout = HAL_GetTick() + Timeout;
+    /* Get tick */
+    tickstart = HAL_GetTick();
    
     while(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CTC) == RESET)
     {
@@ -685,7 +666,7 @@
       /* Check for the Timeout */
       if(Timeout != HAL_MAX_DELAY)
       {
-        if(HAL_GetTick() >= timeout)
+        if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
         {
           /* Update error code */
           hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
@@ -855,7 +836,6 @@
     if(hdma2d->Init.Mode != DMA2D_M2M)
     {
       assert_param(IS_DMA2D_ALPHA_MODE(pLayerCfg->AlphaMode));
-      assert_param(IS_DMA2D_ALPHA_VALUE(pLayerCfg->InputAlpha));
     }
   }
   
@@ -869,8 +849,16 @@
     /* Clear Input color mode, alpha value and alpha mode bits */
     tmp &= (uint32_t)~(DMA2D_BGPFCCR_CM | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_ALPHA); 
     
-    /* Prepare the value to be wrote to the BGPFCCR register */
-    tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
+    if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
+    {
+      /* Prepare the value to be wrote to the BGPFCCR register */
+      tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | ((pLayerCfg->InputAlpha) & 0xFF000000));
+    }
+    else
+    {
+      /* Prepare the value to be wrote to the BGPFCCR register */
+      tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
+    }
     
     /* Write to DMA2D BGPFCCR register */
     hdma2d->Instance->BGPFCCR = tmp; 
@@ -887,6 +875,15 @@
     
     /* Write to DMA2D BGOR register */
     hdma2d->Instance->BGOR = tmp;
+    
+    if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
+    {
+      /* Prepare the value to be wrote to the BGCOLR register */
+      tmp |= ((pLayerCfg->InputAlpha) & 0x00FFFFFF);
+    
+      /* Write to DMA2D BGCOLR register */
+      hdma2d->Instance->BGCOLR = tmp;
+    }    
   }
   /* Configure the foreground DMA2D layer */
   else
@@ -898,8 +895,16 @@
     /* Clear Input color mode, alpha value and alpha mode bits */
     tmp &= (uint32_t)~(DMA2D_FGPFCCR_CM | DMA2D_FGPFCCR_AM | DMA2D_FGPFCCR_ALPHA); 
     
-    /* Prepare the value to be wrote to the FGPFCCR register */
-    tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
+    if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
+    {
+      /* Prepare the value to be wrote to the FGPFCCR register */
+      tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | ((pLayerCfg->InputAlpha) & 0xFF000000));
+    }
+    else
+    {
+      /* Prepare the value to be wrote to the FGPFCCR register */
+      tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
+    }
     
     /* Write to DMA2D FGPFCCR register */
     hdma2d->Instance->FGPFCCR = tmp; 
@@ -916,6 +921,15 @@
     
     /* Write to DMA2D FGOR register */
     hdma2d->Instance->FGOR = tmp;
+   
+    if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
+    {
+      /* Prepare the value to be wrote to the FGCOLR register */
+      tmp |= ((pLayerCfg->InputAlpha) & 0x00FFFFFF);
+    
+      /* Write to DMA2D FGCOLR register */
+      hdma2d->Instance->FGCOLR = tmp;
+    }   
   }    
   /* Initialize the DMA2D state*/
   hdma2d->State  = HAL_DMA2D_STATE_READY;
@@ -1212,11 +1226,7 @@
     }    
     /* Write to DMA2D OCOLR register */
     hdma2d->Instance->OCOLR = tmp;
-  }
-  else if ((hdma2d->LayerCfg[1].InputColorMode == CM_A4) || (hdma2d->LayerCfg[1].InputColorMode == CM_A8))
-  {
-    hdma2d->Instance->FGCOLR = pdata;
-  }  
+  } 
   else /* M2M, M2M_PFC or M2M_Blending DMA2D Mode */
   {
     /* Configure DMA2D source address */