Добавлен watchdog таймер

This commit is contained in:
2025-03-04 09:39:24 +03:00
parent 324c26e559
commit a5a14679f3
8 changed files with 183 additions and 39 deletions

55
Core/Src/iwdg.c Normal file
View File

@@ -0,0 +1,55 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file iwdg.c
* @brief This file provides code for the configuration
* of the IWDG instances.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "iwdg.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
IWDG_HandleTypeDef hiwdg;
/* IWDG init function */
void MX_IWDG_Init(void)
{
/* USER CODE BEGIN IWDG_Init 0 */
/* USER CODE END IWDG_Init 0 */
/* USER CODE BEGIN IWDG_Init 1 */
/* USER CODE END IWDG_Init 1 */
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_32;
hiwdg.Init.Reload = 100;
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN IWDG_Init 2 */
/* USER CODE END IWDG_Init 2 */
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

View File

@@ -25,6 +25,7 @@
#include "gpio.h"
#include "tim.h"
#include "usart.h"
#include "iwdg.h"
#include "pch_sensors.h"
#include "rs_message.h"
@@ -49,6 +50,7 @@ int main(void)
/* System clock configuration */
APP_SystemClockConfig();
MX_IWDG_Init();
MX_GPIO_Init();
MX_TIM1_Init();
MX_TIM14_Init();

View File

@@ -66,12 +66,13 @@ void SVC_Handler(void)
void PendSV_Handler(void)
{
}
#include "iwdg.h"
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
HAL_IWDG_Refresh(&hiwdg);
HAL_IncTick();
}