iwdg.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file iwdg.c
  5. * @brief This file provides code for the configuration
  6. * of the IWDG instances.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2026 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "iwdg.h"
  22. /* USER CODE BEGIN 0 */
  23. /* USER CODE END 0 */
  24. IWDG_HandleTypeDef hiwdg;
  25. /* IWDG init function */
  26. void MX_IWDG_Init(void)
  27. {
  28. /* USER CODE BEGIN IWDG_Init 0 */
  29. #if defined(MINI7_V2_DEBUG)
  30. return ;
  31. #endif
  32. /* USER CODE END IWDG_Init 0 */
  33. /* USER CODE BEGIN IWDG_Init 1 */
  34. /* USER CODE END IWDG_Init 1 */
  35. hiwdg.Instance = IWDG;
  36. hiwdg.Init.Prescaler = IWDG_PRESCALER_64;
  37. hiwdg.Init.Reload = 1230;
  38. if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
  39. {
  40. Error_Handler();
  41. }
  42. /* USER CODE BEGIN IWDG_Init 2 */
  43. /* USER CODE END IWDG_Init 2 */
  44. }
  45. /* USER CODE BEGIN 1 */
  46. void Refresh_IWDG(void){
  47. #if defined(MINI7_V2_DEBUG)
  48. return ;
  49. #endif
  50. HAL_IWDG_Refresh(&hiwdg);
  51. }
  52. unsigned int CheckIsIwdgReset()
  53. {
  54. if(__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)){
  55. __HAL_RCC_CLEAR_RESET_FLAGS();
  56. return 1;
  57. }
  58. return 0;
  59. }
  60. /* USER CODE END 1 */