mbed library sources
Fork of mbed-src by
Diff: targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c
- Revision:
- 369:2e96f1b71984
- Parent:
- 226:b062af740e40
--- a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c Mon Oct 27 08:00:06 2014 +0000 +++ b/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c Mon Oct 27 09:45:07 2014 +0000 @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_wwdg.c * @author MCD Application Team - * @version V1.1.0RC2 - * @date 14-May-2014 + * @version V1.1.0 + * @date 19-June-2014 * @brief WWDG HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Window Watchdog (WWDG) peripheral: @@ -62,9 +62,9 @@ Below the list of most used macros in WWDG HAL driver. (+) __HAL_WWDG_ENABLE: Enable the WWDG peripheral - (+) __HAL_IWDG_GET_FLAG: Get the selected WWDG's flag status - (+) __HAL_IWDG_CLEAR_FLAG: Clear the WWDG's pending flags - (+) __HAL_IWDG_RELOAD_COUNTER: Enables the WWDG early wakeup interrupt + (+) __HAL_WWDG_GET_FLAG: Get the selected WWDG's flag status + (+) __HAL_WWDG_CLEAR_FLAG: Clear the WWDG's pending flags + (+) __HAL_WWDG_ENABLE_IT: Enables the WWDG early wakeup interrupt @endverbatim ****************************************************************************** @@ -150,15 +150,14 @@ */ HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg) { - uint32_t tmp = 0; - /* Check the WWDG handle allocation */ - if(hwwdg == NULL) + if(hwwdg == HAL_NULL) { return HAL_ERROR; } - + /* Check the parameters */ + assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance)); assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler)); assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window)); assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter)); @@ -173,31 +172,10 @@ hwwdg->State = HAL_WWDG_STATE_BUSY; /* Set WWDG Prescaler and Window */ - /* Get the CFR register value */ - tmp = hwwdg->Instance->CFR; - - /* Clear WDGTB[1:0] and W[6:0] bits */ - tmp &= ((uint32_t)~(WWDG_CFR_WDGTB | WWDG_CFR_W)); - - /* Prepare the WWDG Prescaler and Window parameters */ - tmp |= hwwdg->Init.Prescaler | hwwdg->Init.Window; - - /* Write to WWDG CFR */ - hwwdg->Instance->CFR = tmp; - + MODIFY_REG(hwwdg->Instance->CFR, (WWDG_CFR_WDGTB | WWDG_CFR_W), (hwwdg->Init.Prescaler | hwwdg->Init.Window)); /* Set WWDG Counter */ - /* Get the CR register value */ - tmp = hwwdg->Instance->CR; - - /* Clear T[6:0] bits */ - tmp &= ((uint32_t)~(WWDG_CR_T)); - - /* Prepare the WWDG Counter parameter */ - tmp |= (hwwdg->Init.Counter); - - /* Write to WWDG CR */ - hwwdg->Instance->CR = tmp; - + MODIFY_REG(hwwdg->Instance->CR, WWDG_CR_T, hwwdg->Init.Counter); + /* Change WWDG peripheral state */ hwwdg->State = HAL_WWDG_STATE_READY; @@ -212,7 +190,16 @@ * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg) -{ +{ + /* Check the WWDG handle allocation */ + if(hwwdg == HAL_NULL) + { + return HAL_ERROR; + } + + /* Check the parameters */ + assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance)); + /* Change WWDG peripheral state */ hwwdg->State = HAL_WWDG_STATE_BUSY; @@ -319,19 +306,19 @@ * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg) -{ +{ /* Process Locked */ __HAL_LOCK(hwwdg); - + /* Change WWDG peripheral state */ hwwdg->State = HAL_WWDG_STATE_BUSY; - + /* Enable the Early Wakeup Interrupt */ __HAL_WWDG_ENABLE_IT(WWDG_IT_EWI); /* Enable the peripheral */ __HAL_WWDG_ENABLE(hwwdg); - + /* Return function status */ return HAL_OK; } @@ -340,6 +327,7 @@ * @brief Refreshes the WWDG. * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains * the configuration information for the specified WWDG module. + * @param Counter: value of counter to put in WWDG counter * @retval HAL status */ HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter) @@ -354,7 +342,7 @@ assert_param(IS_WWDG_COUNTER(Counter)); /* Write to WWDG CR the WWDG Counter value to refresh with */ - MODIFY_REG(hwwdg->Instance->CR, WWDG_CR_T, Counter); + MODIFY_REG(hwwdg->Instance->CR, (uint32_t)WWDG_CR_T, Counter); /* Change WWDG peripheral state */ hwwdg->State = HAL_WWDG_STATE_READY;