Beispiel #1
0
/**
  * @brief  DeInitializes the WWDG peripheral.
  * @param  hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
  *              the configuration information for the specified WWDG module.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg)
{
    /* Check the parameters */
    assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));

    /* Change WWDG peripheral state */
    hwwdg->State = HAL_WWDG_STATE_BUSY;

    /* DeInit the low level hardware */
    HAL_WWDG_MspDeInit(hwwdg);

    /* Reset WWDG Control register */
    hwwdg->Instance->CR  = (uint32_t)0x0000007F;

    /* Reset WWDG Configuration register */
    hwwdg->Instance->CFR = (uint32_t)0x0000007F;

    /* Reset WWDG Status register */
    hwwdg->Instance->SR  = 0;

    /* Change WWDG peripheral state */
    hwwdg->State = HAL_WWDG_STATE_RESET;

    /* Release Lock */
    __HAL_UNLOCK(hwwdg);

    /* Return function status */
    return HAL_OK;
}
/**
  * @brief  DeInitializes the WWDG peripheral.
  * @param  hwwdg : pointer to a WWDG_HandleTypeDef structure that contains
  *              the configuration information for the specified WWDG module.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg)
{
  /* Check the parameters */
  assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));

  /* Take lock and change peripheral state */
   __HAL_LOCK(hwwdg);
  hwwdg->State = HAL_WWDG_STATE_BUSY;

  /* DeInit the low level hardware */
  HAL_WWDG_MspDeInit(hwwdg);

  /* Reset WWDG Control, configuration and status  register */
  MODIFY_REG(hwwdg->Instance->CR, (WWDG_CR_T | WWDG_CR_WDGA),0x0000007F);
  MODIFY_REG(hwwdg->Instance->CFR, (WWDG_CFR_WDGTB | WWDG_CFR_W | WWDG_CFR_EWI),0x0000007F);
  MODIFY_REG(hwwdg->Instance->SR,WWDG_SR_EWIF,0x0);

  /* Change peripheral state and release lock*/
  hwwdg->State = HAL_WWDG_STATE_RESET;
  __HAL_UNLOCK(hwwdg);

  /* Return function status */
  return HAL_OK;
}