Добавлен watchdog таймер
This commit is contained in:
52
Core/Inc/iwdg.h
Normal file
52
Core/Inc/iwdg.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file iwdg.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the iwdg.c file
|
||||
******************************************************************************
|
||||
* @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 */
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __IWDG_H__
|
||||
#define __IWDG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_IWDG_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __IWDG_H__ */
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
//#define HAL_COMP_MODULE_ENABLED
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
//#define HAL_IWDG_MODULE_ENABLED
|
||||
#define HAL_IWDG_MODULE_ENABLED
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
//#define HAL_LPTIM_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef struct
|
||||
uint16_t Location;
|
||||
uint16_t ROM[4];
|
||||
uint16_t Resolution;
|
||||
uint16_t Enable;
|
||||
uint16_t Status;
|
||||
}MB_SensorParamsTypeDef;
|
||||
/**
|
||||
* @brief Регистры хранения
|
||||
@@ -124,7 +124,7 @@ typedef struct //MB_DataCoilsTypeDef
|
||||
#define C_CONTROL_QNT 3
|
||||
|
||||
#define C_FLAGS_ADDR 16
|
||||
#define C_FLAGS_QNT 5
|
||||
#define C_FLAGS_QNT 2
|
||||
|
||||
/** MODBUS_DATA_COILS_DEFINES
|
||||
* @}
|
||||
|
||||
55
Core/Src/iwdg.c
Normal file
55
Core/Src/iwdg.c
Normal 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 */
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user