iwdg.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #include "App_guardian.h"
  24. /* USER CODE END 0 */
  25. IWDG_HandleTypeDef hiwdg1;
  26. /* IWDG1 init function */
  27. void MX_IWDG1_Init(void)
  28. {
  29. /* USER CODE BEGIN IWDG1_Init 0 */
  30. #if !GUARD_ENABLE
  31. return; /* 守护关闭: IWDG 从未启动 (启动后无法关闭, 只能复位) */
  32. #endif
  33. /* USER CODE END IWDG1_Init 0 */
  34. /* USER CODE BEGIN IWDG1_Init 1 */
  35. /* USER CODE END IWDG1_Init 1 */
  36. hiwdg1.Instance = IWDG1;
  37. hiwdg1.Init.Prescaler = IWDG_PRESCALER_32;
  38. hiwdg1.Init.Window = 4095;
  39. hiwdg1.Init.Reload = 3000;
  40. if (HAL_IWDG_Init(&hiwdg1) != HAL_OK)
  41. {
  42. Error_Handler();
  43. }
  44. /* USER CODE BEGIN IWDG1_Init 2 */
  45. /* USER CODE END IWDG1_Init 2 */
  46. }
  47. /* USER CODE BEGIN 1 */
  48. /* USER CODE END 1 */