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:
630:825f75ca301e
Parent:
441:d2c15dda23c1
--- a/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_iwdg.c	Mon Sep 28 10:30:09 2015 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_iwdg.c	Mon Sep 28 10:45:10 2015 +0100
@@ -2,8 +2,8 @@
   ******************************************************************************
   * @file    stm32f0xx_hal_iwdg.c
   * @author  MCD Application Team
-  * @version V1.2.0
-  * @date    11-December-2014
+  * @version V1.3.0
+  * @date    26-June-2015
   * @brief   IWDG HAL module driver.
   *          This file provides firmware functions to manage the following 
   *          functionalities of the Independent Watchdog (IWDG) peripheral:
@@ -69,15 +69,15 @@
        
       (+) __HAL_IWDG_START: Enable the IWDG peripheral
       (+) __HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in the reload register    
-      (+) __HAL_IWDG_ENABLE_WRITE_ACCESS : Enable write access to IWDG_PR and IWDG_RLR registers
-      (+) __HAL_IWDG_DISABLE_WRITE_ACCESS : Disable write access to IWDG_PR and IWDG_RLR registers
+      (+) IWDG_ENABLE_WRITE_ACCESS : Enable write access to IWDG_PR and IWDG_RLR registers
+      (+) IWDG_DISABLE_WRITE_ACCESS : Disable write access to IWDG_PR and IWDG_RLR registers
       (+) __HAL_IWDG_GET_FLAG: Get the selected IWDG's flag status
 
   @endverbatim
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -101,8 +101,8 @@
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
-  ******************************************************************************  
-  */ 
+  ******************************************************************************
+  */
 
 /* Includes ------------------------------------------------------------------*/
 #include "stm32f0xx_hal.h"
@@ -111,7 +111,7 @@
   * @{
   */
 
-/** @defgroup IWDG IWDG HAL module driver
+/** @defgroup IWDG IWDG
   * @brief IWDG HAL module driver.
   * @{
   */
@@ -120,7 +120,6 @@
 
 /* Private typedef -----------------------------------------------------------*/
 /* Private define ------------------------------------------------------------*/
-
 /** @defgroup IWDG_Private_Defines IWDG Private Defines
   * @{
   */
@@ -130,43 +129,42 @@
 /**
   * @}
   */
-
 /* Private macro -------------------------------------------------------------*/
 /* Private variables ---------------------------------------------------------*/
 /* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
+/* Exported functions --------------------------------------------------------*/
 
 /** @defgroup IWDG_Exported_Functions IWDG Exported Functions
   * @{
   */
 
 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and de-initialization functions 
- *  @brief    Initialization and Configuration functions. 
+ *  @brief    Initialization and Configuration functions.
  *
-@verbatim    
+@verbatim
  ===============================================================================
-              ##### Initialization functions #####
+          ##### Initialization and de-initialization functions #####
  ===============================================================================
     [..]  This section provides functions allowing to:
-      (+) Initialize the IWDG according to the specified parameters 
+      (+) Initialize the IWDG according to the specified parameters
           in the IWDG_InitTypeDef and create the associated handle
       (+) Manage Window option
       (+) Initialize the IWDG MSP
-      (+) DeInitialize IWDG MSP 
- 
+      (+) DeInitialize the IWDG MSP 
+
 @endverbatim
   * @{
   */
 
 /**
-  * @brief  Initializes the IWDG according to the specified
-  *         parameters in the IWDG_InitTypeDef and creates the associated handle.
+  * @brief  Initialize the IWDG according to the specified
+  *         parameters in the IWDG_InitTypeDef and initialize the associated handle.
   * @param  hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
   *                the configuration information for the specified IWDG module.
   * @retval HAL status
   */
 HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg)
-{ 
+{
   uint32_t tickstart = 0;
 
   /* Check the IWDG handle allocation */
@@ -174,7 +172,7 @@
   {
     return HAL_ERROR;
   }
-  
+
   /* Check the parameters */
   assert_param(IS_IWDG_ALL_INSTANCE(hiwdg->Instance));
   assert_param(IS_IWDG_PRESCALER(hiwdg->Init.Prescaler));
@@ -188,24 +186,27 @@
   {
     return HAL_ERROR;
   }
-  
+
   if(hiwdg->State == HAL_IWDG_STATE_RESET)
-  { 
-  /* Init the low level hardware */
-  HAL_IWDG_MspInit(hiwdg);
+  {
+    /* Allocate lock resource and initialize it */
+    hiwdg->Lock = HAL_UNLOCKED;
+
+    /* Init the low level hardware */
+    HAL_IWDG_MspInit(hiwdg);
   }
 
   /* Change IWDG peripheral state */
   hiwdg->State = HAL_IWDG_STATE_BUSY;
 
-  /* Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers */  
-  /* by writing 0x5555 in KR */  
-  __HAL_IWDG_ENABLE_WRITE_ACCESS(hiwdg);
-  
+  /* Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers */
+  /* by writing 0x5555 in KR */
+  IWDG_ENABLE_WRITE_ACCESS(hiwdg);
+
   /* Write to IWDG registers the IWDG_Prescaler & IWDG_Reload values to work with */
   MODIFY_REG(hiwdg->Instance->PR, IWDG_PR_PR, hiwdg->Init.Prescaler);
   MODIFY_REG(hiwdg->Instance->RLR, IWDG_RLR_RL, hiwdg->Init.Reload);
- 
+
   /* check if window option is enabled */
   if (((hiwdg->Init.Window) != IWDG_WINDOW_DISABLE) || ((hiwdg->Instance->WINR) != IWDG_WINDOW_DISABLE))
   {
@@ -214,34 +215,34 @@
      /* Wait for register to be updated */
     while((uint32_t)(hiwdg->Instance->SR) != RESET)
     {
-      if((HAL_GetTick() - tickstart) > HAL_IWDG_DEFAULT_TIMEOUT)
-      { 
+      if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT)
+      {
         /* Set IWDG state */
         hiwdg->State = HAL_IWDG_STATE_TIMEOUT;
         return HAL_TIMEOUT;
-      } 
+      }
     }
 
     /* Write to IWDG WINR the IWDG_Window value to compare with */
     MODIFY_REG(hiwdg->Instance->WINR, IWDG_WINR_WIN, hiwdg->Init.Window);
+  }
 
-  } 
   /* Change IWDG peripheral state */
   hiwdg->State = HAL_IWDG_STATE_READY;
- 
+
   /* Return function status */
   return HAL_OK;
 }
 
 /**
-  * @brief  Initializes the IWDG MSP.
+  * @brief  Initialize the IWDG MSP.
   * @param  hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
   *                the configuration information for the specified IWDG module.
   * @retval None
   */
 __weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg)
 {
-  /* NOTE : This function Should not be modified, when the callback is needed,
+  /* NOTE : This function should not be modified, when the callback is needed,
             the HAL_IWDG_MspInit could be implemented in the user file
    */
 }
@@ -253,10 +254,10 @@
 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions  
  *  @brief   IO operation functions  
  *
-@verbatim   
+@verbatim
  ===============================================================================
                       ##### IO operation functions #####
- ===============================================================================  
+ ===============================================================================
     [..]  This section provides functions allowing to:
       (+) Start the IWDG.
       (+) Refresh the IWDG.
@@ -266,82 +267,83 @@
   */
 
 /**
-  * @brief  Starts the IWDG.
+  * @brief  Start the IWDG.
   * @param  hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
   *                the configuration information for the specified IWDG module.
   * @retval HAL status
   */
 HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg)
-{ 
+{
   uint32_t tickstart = 0;
 
-  /* Process Locked */
+  /* Process locked */
   __HAL_LOCK(hiwdg); 
-                  
-    /* Change IWDG peripheral state */  
+
+    /* Change IWDG peripheral state */
   hiwdg->State = HAL_IWDG_STATE_BUSY;
-                   
+
   /* Reload IWDG counter with value defined in the RLR register */
   if ((hiwdg->Init.Window) == IWDG_WINDOW_DISABLE)
   {
-  __HAL_IWDG_RELOAD_COUNTER(hiwdg);
+    __HAL_IWDG_RELOAD_COUNTER(hiwdg);
   }
 
-  /* Enable the IWDG peripheral */
+  /* Start the IWDG peripheral */
   __HAL_IWDG_START(hiwdg);
 
   tickstart = HAL_GetTick();
 
   /* Wait until PVU, RVU, WVU flag are RESET */
   while( (__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_PVU) != RESET)
-        &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET)
-        &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_WVU) != RESET) )
+         &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET)
+         &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_WVU) != RESET) )
   {
-    if((HAL_GetTick() - tickstart) > HAL_IWDG_DEFAULT_TIMEOUT)
-    { 
+    
+    if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT)
+    {
       /* Set IWDG state */
       hiwdg->State = HAL_IWDG_STATE_TIMEOUT;
- 
-       /* Process unlocked */
+      
+      /* Process unlocked */
       __HAL_UNLOCK(hiwdg);
-
+      
       return HAL_TIMEOUT;
-    } 
+    }
   }
 
-  /* Change IWDG peripheral state */    
-  hiwdg->State = HAL_IWDG_STATE_READY; 
-                  
+  /* Change IWDG peripheral state */
+  hiwdg->State = HAL_IWDG_STATE_READY;
+
   /* Process Unlocked */
   __HAL_UNLOCK(hiwdg);
-  
+
   /* Return function status */
   return HAL_OK;
 }
 
 /**
-  * @brief  Refreshes the IWDG.
+  * @brief  Refresh the IWDG.
   * @param  hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
   *                the configuration information for the specified IWDG module.
   * @retval HAL status
   */
 HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
-  {
+{
   uint32_t tickstart = 0;
 
   /* Process Locked */
-  __HAL_LOCK(hiwdg); 
-                  
-    /* Change IWDG peripheral state */  
+  __HAL_LOCK(hiwdg);
+
+    /* Change IWDG peripheral state */
   hiwdg->State = HAL_IWDG_STATE_BUSY;
-  
+
   tickstart = HAL_GetTick();
 
   /* Wait until RVU flag is RESET */
   while(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET)
   {
-    if((HAL_GetTick() - tickstart) > HAL_IWDG_DEFAULT_TIMEOUT)
-    { 
+    if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT)
+    {
       /* Set IWDG state */
       hiwdg->State = HAL_IWDG_STATE_TIMEOUT;
 
@@ -349,18 +351,18 @@
       __HAL_UNLOCK(hiwdg);
 
       return HAL_TIMEOUT;
-    } 
+    }
   }
 
   /* Reload IWDG counter with value defined in the reload register */
   __HAL_IWDG_RELOAD_COUNTER(hiwdg);
-  
-  /* Change IWDG peripheral state */    
-  hiwdg->State = HAL_IWDG_STATE_READY; 
-                  
+
+  /* Change IWDG peripheral state */
+  hiwdg->State = HAL_IWDG_STATE_READY;
+
   /* Process Unlocked */
   __HAL_UNLOCK(hiwdg);
-  
+
   /* Return function status */
   return HAL_OK;
 }
@@ -370,28 +372,28 @@
   */
 
 /** @defgroup IWDG_Exported_Functions_Group3 Peripheral State functions 
- *  @brief    Peripheral State functions. 
+ *  @brief    Peripheral State functions.
  *
-@verbatim   
+@verbatim
  ===============================================================================
                       ##### Peripheral State functions #####
- ===============================================================================  
+ ===============================================================================
     [..]
-    This subsection permits to get in run-time the status of the peripheral 
-    and the data flow.
+    This subsection permits to get in run-time the status of the peripheral.
 
 @endverbatim
   * @{
   */
 
 /**
-  * @brief  Returns the IWDG state.
+  * @brief  Return the IWDG handle state.
   * @param  hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
   *                the configuration information for the specified IWDG module.
   * @retval HAL state
   */
 HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg)
 {
+  /* Return IWDG handle state */
   return hiwdg->State;
 }