OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 956|回复: 6

WWDG 找不到HAL_WWDG_Start 和 HAL_WWDG_Start_IT

[复制链接]

2

主题

9

帖子

0

精华

新手上路

积分
28
金钱
28
注册时间
2020-10-24
在线时间
3 小时
发表于 2022-8-15 15:46:14 | 显示全部楼层 |阅读模式
1金钱


在官方的窗口看门狗例程中并没有发现使用HAL_WWDG_Start/HAL_WWDG_Start_IT函数,在stm32f4xx_hal_wwdg.c/.h中也没有找到这两个函数。

会是因为hal库的版本不对吗
使用的是提供的HAL库版本

百度没找到解答。
麻烦知道的,告诉一下。谢谢。

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

0

主题

668

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1926
金钱
1926
注册时间
2021-8-13
在线时间
262 小时
发表于 2022-8-15 16:24:40 | 显示全部楼层
回复

使用道具 举报

0

主题

7

帖子

0

精华

初级会员

Rank: 2

积分
70
金钱
70
注册时间
2022-6-27
在线时间
8 小时
发表于 2022-8-15 16:49:43 | 显示全部楼层
微信图片_20220815164801.png
额,我的有。我不知道你的是什么情况
回复

使用道具 举报

2

主题

9

帖子

0

精华

新手上路

积分
28
金钱
28
注册时间
2020-10-24
在线时间
3 小时
 楼主| 发表于 2022-8-15 17:25:32 | 显示全部楼层
yaowan 发表于 2022-8-15 16:49
额,我的有。我不知道你的是什么情况

我用的是提供的资料里面的STM32CubeF1固件库里面的文件
回复

使用道具 举报

2

主题

9

帖子

0

精华

新手上路

积分
28
金钱
28
注册时间
2020-10-24
在线时间
3 小时
 楼主| 发表于 2022-8-15 17:26:25 | 显示全部楼层
yaowan 发表于 2022-8-15 16:49
额,我的有。我不知道你的是什么情况

STM32Cube_FW_F4_V1.24.0
回复

使用道具 举报

2

主题

9

帖子

0

精华

新手上路

积分
28
金钱
28
注册时间
2020-10-24
在线时间
3 小时
 楼主| 发表于 2022-8-15 17:29:25 | 显示全部楼层
  1. /**
  2.   ******************************************************************************
  3.   * [url=home.php?mod=space&uid=175224]@file[/url]    stm32f4xx_hal_wwdg.c
  4.   * [url=home.php?mod=space&uid=90321]@Author[/url]  MCD Application Team
  5.   * @brief   WWDG HAL module driver.
  6.   *          This file provides firmware functions to manage the following
  7.   *          functionalities of the Window Watchdog (WWDG) peripheral:
  8.   *           + Initialization and Configuration functions
  9.   *           + IO operation functions
  10.   @verbatim
  11.   ==============================================================================
  12.                       ##### WWDG Specific features #####
  13.   ==============================================================================
  14.   [..]
  15.     Once enabled the WWDG generates a system reset on expiry of a programmed
  16.     time period, unless the program refreshes the counter (T[6;0] downcounter)
  17.     before reaching 0x3F value (i.e. a reset is generated when the counter
  18.     value rolls down from 0x40 to 0x3F).

  19.     (+) An MCU reset is also generated if the counter value is refreshed
  20.         before the counter has reached the refresh window value. This
  21.         implies that the counter must be refreshed in a limited window.
  22.     (+) Once enabled the WWDG cannot be disabled except by a system reset.
  23.     (+) WWDGRST flag in RCC CSR register can be used to inform when a WWDG
  24.         reset occurs.
  25.     (+) The WWDG counter input clock is derived from the APB clock divided
  26.         by a programmable prescaler.
  27.     (+) WWDG clock (Hz) = PCLK1 / (4096 * Prescaler)
  28.     (+) WWDG timeout (mS) = 1000 * (T[5;0] + 1) / WWDG clock (Hz)
  29.         where T[5;0] are the lowest 6 bits of Counter.
  30.     (+) WWDG Counter refresh is allowed between the following limits :
  31.         (++) min time (mS) = 1000 * (Counter - Window) / WWDG clock
  32.         (++) max time (mS) = 1000 * (Counter - 0x40) / WWDG clock
  33.     (+) Typical values:
  34.         (++) Counter min (T[5;0] = 0x00) @56MHz (PCLK1) with zero prescaler:
  35.              max timeout before reset: ~73.14祍
  36.         (++) Counter max (T[5;0] = 0x3F) @56MHz (PCLK1) with prescaler dividing by 128:
  37.              max timeout before reset: ~599.18ms

  38.   ==============================================================================
  39.                      ##### How to use this driver #####
  40.   ==============================================================================
  41.   [..]
  42.     *** Common driver usage ***
  43.     ===========================
  44.     (+) Enable WWDG APB1 clock using __HAL_RCC_WWDG_CLK_ENABLE().
  45.     (+) Set the WWDG prescaler, refresh window and counter value
  46.         using HAL_WWDG_Init() function.
  47.     (+) Start the WWDG using HAL_WWDG_Start() function.
  48.         When the WWDG is enabled the counter value should be configured to
  49.         a value greater than 0x40 to prevent generating an immediate reset.
  50.     (+) Optionally you can enable the Early Wakeup Interrupt (EWI) which is
  51.         generated when the counter reaches 0x40, and then start the WWDG using
  52.         HAL_WWDG_Start_IT(). At EWI HAL_WWDG_WakeupCallback is executed and user can
  53.         add his own code by customization of callback HAL_WWDG_WakeupCallback.
  54.         Once enabled, EWI interrupt cannot be disabled except by a system reset.
  55.     (+) Then the application program must refresh the WWDG counter at regular
  56.         intervals during normal operation to prevent an MCU reset, using
  57.         HAL_WWDG_Refresh() function. This operation must occur only when
  58.         the counter is lower than the refresh window value already programmed.

  59.   [..]
  60.     *** Callback registration ***
  61.     =============================
  62.     The compilation define  USE_HAL_WWDG_REGISTER_CALLBACKS when set to 1 allows
  63.     the user to configure dynamically the driver callbacks. Use Functions
  64.     @ref HAL_WWDG_RegisterCallback() to register a user callback.

  65.     (+) Function @ref HAL_WWDG_RegisterCallback() allows to register following
  66.         callbacks:
  67.         (++) EwiCallback : callback for Early WakeUp Interrupt.
  68.         (++) MspInitCallback : WWDG MspInit.
  69.     This function takes as parameters the HAL peripheral handle, the Callback ID
  70.     and a pointer to the user callback function.

  71.     (+) Use function @ref HAL_WWDG_UnRegisterCallback() to reset a callback to
  72.     the default weak (surcharged) function. @ref HAL_WWDG_UnRegisterCallback()
  73.     takes as parameters the HAL peripheral handle and the Callback ID.
  74.     This function allows to reset following callbacks:
  75.         (++) EwiCallback : callback for  Early WakeUp Interrupt.
  76.         (++) MspInitCallback : WWDG MspInit.

  77.     When calling @ref HAL_WWDG_Init function, callbacks are reset to the
  78.     corresponding legacy weak (surcharged) functions:
  79.     @ref HAL_WWDG_EarlyWakeupCallback() and HAL_WWDG_MspInit() only if they have
  80.     not been registered before.

  81.     When compilation define USE_HAL_WWDG_REGISTER_CALLBACKS is set to 0 or
  82.     not defined, the callback registering feature is not available
  83.     and weak (surcharged) callbacks are used.

  84.     *** WWDG HAL driver macros list ***
  85.     ===================================
  86.     [..]
  87.       Below the list of most used macros in WWDG HAL driver.
  88.       (+) __HAL_WWDG_ENABLE: Enable the WWDG peripheral
  89.       (+) __HAL_WWDG_GET_FLAG: Get the selected WWDG's flag status
  90.       (+) __HAL_WWDG_CLEAR_FLAG: Clear the WWDG's pending flags
  91.       (+) __HAL_WWDG_ENABLE_IT: Enable the WWDG early wakeup interrupt

  92.   @endverbatim
  93.   ******************************************************************************
  94.   * @attention
  95.   *
  96.   * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  97.   * All rights reserved.</center></h2>
  98.   *
  99.   * This software component is licensed by ST under BSD 3-Clause license,
  100.   * the "License"; You may not use this file except in compliance with the
  101.   * License. You may obtain a copy of the License at:
  102.   *                        opensource.org/licenses/BSD-3-Clause
  103.   *
  104.   ******************************************************************************
  105.   */

  106. /* Includes ------------------------------------------------------------------*/
  107. #include "stm32f4xx_hal.h"

  108. /** @addtogroup STM32F4xx_HAL_Driver
  109.   * @{
  110.   */

  111. #ifdef HAL_WWDG_MODULE_ENABLED
  112. /** @defgroup WWDG WWDG
  113.   * @brief WWDG HAL module driver.
  114.   * @{
  115.   */

  116. /* Private typedef -----------------------------------------------------------*/
  117. /* Private define ------------------------------------------------------------*/
  118. /* Private macro -------------------------------------------------------------*/
  119. /* Private variables ---------------------------------------------------------*/
  120. /* Private function prototypes -----------------------------------------------*/
  121. /* Exported functions --------------------------------------------------------*/

  122. /** @defgroup WWDG_Exported_Functions WWDG Exported Functions
  123.   * @{
  124.   */

  125. /** @defgroup WWDG_Exported_Functions_Group1 Initialization and Configuration functions
  126. *  @brief    Initialization and Configuration functions.
  127. *
  128. @verbatim
  129.   ==============================================================================
  130.           ##### Initialization and Configuration functions #####
  131.   ==============================================================================
  132.   [..]
  133.     This section provides functions allowing to:
  134.       (+) Initialize and start the WWDG according to the specified parameters
  135.           in the WWDG_InitTypeDef of associated handle.
  136.       (+) Initialize the WWDG MSP.

  137. @endverbatim
  138.   * @{
  139.   */

  140. /**
  141.   * @brief  Initialize the WWDG according to the specified.
  142.   *         parameters in the WWDG_InitTypeDef of  associated handle.
  143.   * @param  hwwdg  pointer to a WWDG_HandleTypeDef structure that contains
  144.   *                the configuration information for the specified WWDG module.
  145.   * @retval HAL status
  146.   */
  147. HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg)
  148. {
  149.   /* Check the WWDG handle allocation */
  150.   if (hwwdg == NULL)
  151.   {
  152.     return HAL_ERROR;
  153.   }

  154.   /* Check the parameters */
  155.   assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));
  156.   assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler));
  157.   assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window));
  158.   assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter));
  159.   assert_param(IS_WWDG_EWI_MODE(hwwdg->Init.EWIMode));

  160. #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
  161.   /* Reset Callback pointers */
  162.   if(hwwdg->EwiCallback == NULL)
  163.   {
  164.     hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
  165.   }

  166.   if(hwwdg->MspInitCallback == NULL)
  167.   {
  168.     hwwdg->MspInitCallback = HAL_WWDG_MspInit;
  169.   }

  170.   /* Init the low level hardware */
  171.   hwwdg->MspInitCallback(hwwdg);
  172. #else
  173.   /* Init the low level hardware */
  174.   HAL_WWDG_MspInit(hwwdg);
  175. #endif

  176.   /* Set WWDG Counter */
  177.   WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter));

  178.   /* Set WWDG Prescaler and Window */
  179.   WRITE_REG(hwwdg->Instance->CFR, (hwwdg->Init.EWIMode | hwwdg->Init.Prescaler | hwwdg->Init.Window));

  180.   /* Return function status */
  181.   return HAL_OK;
  182. }


  183. /**
  184.   * @brief  Initialize the WWDG MSP.
  185.   * @param  hwwdg  pointer to a WWDG_HandleTypeDef structure that contains
  186.   *                the configuration information for the specified WWDG module.
  187.   * @note   When rewriting this function in user file, mechanism may be added
  188.   *         to avoid multiple initialize when HAL_WWDG_Init function is called
  189.   *         again to change parameters.
  190.   * @retval None
  191.   */
  192. __weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
  193. {
  194.   /* Prevent unused argument(s) compilation warning */
  195.   UNUSED(hwwdg);

  196.   /* NOTE: This function should not be modified, when the callback is needed,
  197.            the HAL_WWDG_MspInit could be implemented in the user file
  198.    */
  199. }


  200. #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
  201. /**
  202.   * @brief  Register a User WWDG Callback
  203.   *         To be used instead of the weak (surcharged) predefined callback
  204.   * @param  hwwdg WWDG handle
  205.   * @param  CallbackID ID of the callback to be registered
  206.   *         This parameter can be one of the following values:
  207.   *           @arg @ref HAL_WWDG_EWI_CB_ID Early WakeUp Interrupt Callback ID
  208.   *           @arg @ref HAL_WWDG_MSPINIT_CB_ID MspInit callback ID
  209.   * @param  pCallback pointer to the Callback function
  210.   * @retval status
  211.   */
  212. HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID, pWWDG_CallbackTypeDef pCallback)
  213. {
  214.   HAL_StatusTypeDef status = HAL_OK;

  215.   if(pCallback == NULL)
  216.   {
  217.     status = HAL_ERROR;
  218.   }
  219.   else
  220.   {
  221.     switch(CallbackID)
  222.     {
  223.       case HAL_WWDG_EWI_CB_ID:
  224.         hwwdg->EwiCallback = pCallback;
  225.         break;

  226.       case HAL_WWDG_MSPINIT_CB_ID:
  227.         hwwdg->MspInitCallback = pCallback;
  228.         break;

  229.       default:
  230.         status = HAL_ERROR;
  231.         break;
  232.     }
  233.   }

  234.   return status;
  235. }


  236. /**
  237.   * @brief  Unregister a WWDG Callback
  238.   *         WWDG Callback is redirected to the weak (surcharged) predefined callback
  239.   * @param  hwwdg WWDG handle
  240.   * @param  CallbackID ID of the callback to be registered
  241.   *         This parameter can be one of the following values:
  242.   *           @arg @ref HAL_WWDG_EWI_CB_ID Early WakeUp Interrupt Callback ID
  243.   *           @arg @ref HAL_WWDG_MSPINIT_CB_ID MspInit callback ID
  244.   * @retval status
  245.   */
  246. HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID)
  247. {
  248.   HAL_StatusTypeDef status = HAL_OK;

  249.   switch(CallbackID)
  250.   {
  251.     case HAL_WWDG_EWI_CB_ID:
  252.       hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
  253.       break;

  254.     case HAL_WWDG_MSPINIT_CB_ID:
  255.       hwwdg->MspInitCallback = HAL_WWDG_MspInit;
  256.       break;

  257.     default:
  258.       status = HAL_ERROR;
  259.       break;
  260.   }

  261.   return status;
  262. }
  263. #endif

  264. /**
  265.   * @}
  266.   */

  267. /** @defgroup WWDG_Exported_Functions_Group2 IO operation functions
  268. *  @brief    IO operation functions
  269. *
  270. @verbatim
  271.   ==============================================================================
  272.                       ##### IO operation functions #####
  273.   ==============================================================================
  274.   [..]
  275.     This section provides functions allowing to:
  276.     (+) Refresh the WWDG.
  277.     (+) Handle WWDG interrupt request and associated function callback.

  278. @endverbatim
  279.   * @{
  280.   */

  281. /**
  282.   * @brief  Refresh the WWDG.
  283.   * @param  hwwdg  pointer to a WWDG_HandleTypeDef structure that contains
  284.   *                the configuration information for the specified WWDG module.
  285.   * @retval HAL status
  286.   */
  287. HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg)
  288. {
  289.   /* Write to WWDG CR the WWDG Counter value to refresh with */
  290.   WRITE_REG(hwwdg->Instance->CR, (hwwdg->Init.Counter));

  291.   /* Return function status */
  292.   return HAL_OK;
  293. }

  294. /**
  295.   * @brief  Handle WWDG interrupt request.
  296.   * @note   The Early Wakeup Interrupt (EWI) can be used if specific safety operations
  297.   *         or data logging must be performed before the actual reset is generated.
  298.   *         The EWI interrupt is enabled by calling HAL_WWDG_Init function with
  299.   *         EWIMode set to WWDG_EWI_ENABLE.
  300.   *         When the downcounter reaches the value 0x40, and EWI interrupt is
  301.   *         generated and the corresponding Interrupt Service Routine (ISR) can
  302.   *         be used to trigger specific actions (such as communications or data
  303.   *         logging), before resetting the device.
  304.   * @param  hwwdg  pointer to a WWDG_HandleTypeDef structure that contains
  305.   *                the configuration information for the specified WWDG module.
  306.   * @retval None
  307.   */
  308. void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg)
  309. {
  310.   /* Check if Early Wakeup Interrupt is enable */
  311.   if (__HAL_WWDG_GET_IT_SOURCE(hwwdg, WWDG_IT_EWI) != RESET)
  312.   {
  313.     /* Check if WWDG Early Wakeup Interrupt occurred */
  314.     if (__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET)
  315.     {
  316.       /* Clear the WWDG Early Wakeup flag */
  317.       __HAL_WWDG_CLEAR_FLAG(hwwdg, WWDG_FLAG_EWIF);

  318. #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
  319.       /* Early Wakeup registered callback */
  320.       hwwdg->EwiCallback(hwwdg);
  321. #else
  322.       /* Early Wakeup callback */
  323.       HAL_WWDG_EarlyWakeupCallback(hwwdg);
  324. #endif
  325.     }
  326.   }
  327. }


  328. /**
  329.   * @brief  WWDG Early Wakeup callback.
  330.   * @param  hwwdg  pointer to a WWDG_HandleTypeDef structure that contains
  331.   *                the configuration information for the specified WWDG module.
  332.   * @retval None
  333.   */
  334. __weak void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg)
  335. {
  336.   /* Prevent unused argument(s) compilation warning */
  337.   UNUSED(hwwdg);

  338.   /* NOTE: This function should not be modified, when the callback is needed,
  339.            the HAL_WWDG_EarlyWakeupCallback could be implemented in the user file
  340.    */
  341. }

  342. /**
  343.   * @}
  344.   */

  345. /**
  346.   * @}
  347.   */

  348. #endif /* HAL_WWDG_MODULE_ENABLED */
  349. /**
  350.   * @}
  351.   */

  352. /**
  353.   * @}
  354.   */

  355. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
复制代码
回复

使用道具 举报

0

主题

7

帖子

0

精华

初级会员

Rank: 2

积分
70
金钱
70
注册时间
2022-6-27
在线时间
8 小时
发表于 2022-8-19 15:43:58 | 显示全部楼层

QQ图片20220819154201.png 我的是这个的,和你的不一样,也不知道为啥你没有,看门狗实验能使用吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-5-8 21:14

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表