error handler init, internal watchdog add

This commit is contained in:
2022-06-22 14:54:21 +02:00
parent 17ccf56463
commit 96b27b020b
15 changed files with 819 additions and 27 deletions

View File

@ -36,19 +36,19 @@
// Application
#include "VARH_VariableHandler.h"
#include "PECO_PeltierController.h"
#include "MAIN_MainApplication.h"
// Drivers
//#include "../Drivers/USFL_UserFlash.h"
#include "../Drivers/USFL_UserFlash.h"
#include "../Drivers/ANPI_AnalogPortsIn.h"
#include "../Drivers/ANPO_AnalogPortsOut.h"
#include "../Drivers/SPID_SpiDriver.h"
#include "../Drivers/DIPO_DigitalPorts.h"
#include "../Drivers/ADCD_AdcDriver.h"
#include "../Drivers/TEMP_Temperature.h"
#include "../Drivers/PECO_PeltierController.h"
#include "../Drivers/CAND_CanDriver.h"
#include "../Drivers/ERRH_ErrorHandler.h"
// Toolbox
#include "../Toolbox/UTIL_Utility.h"

View File

@ -41,7 +41,7 @@
#include "../Drivers/TEMP_Temperature.h"
#include "../Drivers/DIPO_DigitalPorts.h"
#include "../Drivers/CAND_CanDriver.h"
#include "../Drivers/PECO_PeltierController.h"
#include "PECO_PeltierController.h"
#include "../Drivers/ANPI_AnalogPortsIn.h"
// Toolbox
@ -229,12 +229,17 @@ PRIVATE VOID vTask( PVOID arg )
U8 u8Type = stMessage.u8Type;
if( u8Type == MESSAGE_TYPE_READ ){
VARH_UVariable uVariable = VARH_uGetVariableData(u8Register);
if( u8Register >= VARH_eNumberOfVariables ){
au8Buffer[0] = 0xFF;
CAND_boSendMessage( au8Buffer, 1 );
} else {
VARH_UVariable uVariable = VARH_uGetVariableData(u8Register);
au8Buffer[0] = u8Register;
UTIL_vMemCopy(&uVariable, &au8Buffer[1], 4);
au8Buffer[0] = u8Register;
UTIL_vMemCopy(&uVariable, &au8Buffer[1], 4);
CAND_boSendMessage( au8Buffer, 5 );
CAND_boSendMessage( au8Buffer, 5 );
}
} else if( u8Type == MESSAGE_TYPE_WRITE ){
VARH_UVariable uData;
UTIL_vMemCopy(&stMessage.au8Data[1], &uData, 4);

View File

@ -148,6 +148,7 @@ PRIVATE VOID vEventCallback( PVOID pvData );
// Description: Definition of external (global) variables.
//=================================================================================================
extern IWDG_HandleTypeDef hiwdg;
//=================================================================================================
// Section: GLOBAL FUNCTIONS
@ -241,6 +242,8 @@ VOID vTask( PVOID arg )
if( u32Flags & EVENT_TIMER_UPDATE )
{
HAL_IWDG_Refresh(&hiwdg);
if ( VARH_u32GetVariableData( VARH_eMode ) == PECO_eConstTemp )
{
// TODO: check the measurements, everything ok?
@ -248,7 +251,7 @@ VOID vTask( PVOID arg )
// PID Regelung
FLOAT kp = VARH_flGetVariableData( VARH_ePID_kp );
FLOAT kp = VARH_flGetVariableData( VARH_ePID_kp );
FLOAT ki = VARH_flGetVariableData( VARH_ePID_ki );
FLOAT kd = VARH_flGetVariableData( VARH_ePID_kd );
FLOAT max = VARH_flGetVariableData( VARH_ePID_Max );

View File

@ -0,0 +1,124 @@
//=================================================================================================
//
// Company: Paul Scherrer Institut
// 5232 Villigen PSI
// Switzerland
//
//-------------------------------------------------------------------------------------------------
//
// Project: Peltier Controller V2
// Author: Noah Piqué (noah.pique@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//
// Module: Error Handler
// Filename: ERRH_ErrorHandler.c
// Date: Handled by Subversion (version control system)
// Revision: Handled by Subversion (version control system)
// History: Handled by Subversion (version control system)
//
//-------------------------------------------------------------------------------------------------
//
// Description: This source file contains all functions dealing with internal Errors
//
//=================================================================================================
//=================================================================================================
// Section: INCLUDES
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "ERRH_ErrorHandler.h"
// Toolbox
#include "../Toolbox/UTIL_Utility.h"
// include STM32 drivers
#include "stm32l4xx_hal.h"
#include "cmsis_os2.h"
//=================================================================================================
// Section: DEFINITIONS
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: MACROS
// Description: Definition of local macros (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: ENUMERATIONS
// Description: Definition of local enumerations (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: STRUCTURES
// Description: Definition of local Structures (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: LOCAL VARIABLES
// Description: Definition of local variables (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: LOCAL CONSTANTS
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: LOCAL FUNCTIONS (PROTOTYPES)
// Description: Definition of local functions (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: GLOBAL FUNCTIONS
// Description: Definition (implementation) of global functions.
//=================================================================================================
//-------------------------------------------------------------------------------------------------
// Function: USFL_boInitializeModule
// Description: Initializes the module. Function must be called once immediately after power-up.
// Parameters: None
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL ERRH_boInitializeModule( VOID )
{
BOOL boOK = TRUE;
return( boOK );
}
//=================================================================================================
// Section: LOCAL FUNCTIONS
// Descriptionn: Definition (implementation) of local functions.
//=================================================================================================

View File

@ -0,0 +1,95 @@
//=================================================================================================
//
// Company: Paul Scherrer Institut
// 5232 Villigen PSI
// Switzerland
//
//-------------------------------------------------------------------------------------------------
//
// Project: Peltier Controller V2
// Author: Noah Piqué (noah.pique@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//
// Module: Error Handler
// Filename: ERRH_ErrorHandler.h
// Date: Handled by Subversion (version control system)
// Revision: Handled by Subversion (version control system)
// History: Handled by Subversion (version control system)
//
//-------------------------------------------------------------------------------------------------
#ifndef ERRH_ERRORHANDLER_H
#define ERRH_ERRORHANDLER_H
#ifdef __cplusplus
extern "C" {
#endif
//=================================================================================================
// Section: INCLUDES
// Description: List of required include files (visible by all modules).
//=================================================================================================
#include "../SDEF_StandardDefinitions.h"
//=================================================================================================
// Section: DEFINITIONS
// Description: Definition of global constants (visible by all modules).
//=================================================================================================
//=================================================================================================
// Section: MACROS
// Description: Definition of global macros (visible by all modules).
//=================================================================================================
//=================================================================================================
// Section: ENUMERATIONS
// Description: Definition of global enumerations (visible by all modules).
//=================================================================================================
//=================================================================================================
// Section: STRUCTURES
// Description: Definition of global Structures (visible by all modules).
//=================================================================================================
//=================================================================================================
// Section: GLOBAL VARIABLES
// Description: Definition of global variables (visible by all modules).
//=================================================================================================
//=================================================================================================
// Section: GLOBAL CONSTANTS
// Description: Definition of global constants (visible by all modules).
//=================================================================================================
//=================================================================================================
// Section: GLOBAL FUNCTIONS (PROTOTYPES)
// Description: Definition of global functions (visible by all modules).
//=================================================================================================
BOOL ERRH_boInitializeModule( VOID );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -66,7 +66,7 @@
#define STARTDEF 0xAA01F055
#define VARDEF 0xABCDEF00
#define VARDEF 0xABCDEF05
//=================================================================================================
// Section: MACROS
@ -115,6 +115,7 @@ __attribute__((__section__(".user_data"))) const U64 UserFlash[USERFLASHSIZE];
//=================================================================================================
BOOL vEreaseUserFlash( void );
U32 vFindNextFreePointer( void );
//=================================================================================================
// Section: GLOBAL FUNCTIONS
@ -149,7 +150,7 @@ BOOL USFL_boInitializeModule( VOID )
//=================================================================================================
//-------------------------------------------------------------------------------------------------
// Function: vEreaseUserFlash
// Function: vFindNextFreePointer
// Description: Ereases the User Flash Sector
// Parameters: None
// Returns: Boolean TRUE if successful

View File

@ -53,7 +53,7 @@
/*#define HAL_HASH_MODULE_ENABLED */
/*#define HAL_I2S_MODULE_ENABLED */
/*#define HAL_IRDA_MODULE_ENABLED */
/*#define HAL_IWDG_MODULE_ENABLED */
#define HAL_IWDG_MODULE_ENABLED
/*#define HAL_LTDC_MODULE_ENABLED */
/*#define HAL_LCD_MODULE_ENABLED */
/*#define HAL_LPTIM_MODULE_ENABLED */

View File

@ -56,6 +56,8 @@ DAC_HandleTypeDef hdac1;
I2C_HandleTypeDef hi2c1;
IWDG_HandleTypeDef hiwdg;
SPI_HandleTypeDef hspi1;
DMA_HandleTypeDef hdma_spi1_rx;
DMA_HandleTypeDef hdma_spi1_tx;
@ -80,6 +82,7 @@ static void MX_CAN1_Init(void);
static void MX_DAC1_Init(void);
static void MX_SPI1_Init(void);
static void MX_I2C1_Init(void);
static void MX_IWDG_Init(void);
void vDefaultTask(void *argument);
/* USER CODE BEGIN PFP */
@ -125,6 +128,7 @@ int main(void)
MX_DAC1_Init();
MX_SPI1_Init();
MX_I2C1_Init();
MX_IWDG_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@ -193,8 +197,9 @@ void SystemClock_Config(void)
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4;
@ -436,6 +441,35 @@ static void MX_I2C1_Init(void)
}
/**
* @brief IWDG Initialization Function
* @param None
* @retval None
*/
static 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_256;
hiwdg.Init.Window = 4095;
hiwdg.Init.Reload = 150;
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN IWDG_Init 2 */
/* USER CODE END IWDG_Init 2 */
}
/**
* @brief SPI1 Initialization Function
* @param None