update headers

This commit is contained in:
2022-07-07 18:00:11 +02:00
parent 11e6c6a0fc
commit 8cced68543
23 changed files with 134 additions and 673 deletions

View File

@ -31,7 +31,6 @@
//=================================================================================================
#include "../SDEF_StandardDefinitions.h"
#include "../PDEF_ProjectDefinitions.h"
#include "INIT_Initialization.h"
// Application
@ -161,23 +160,20 @@ PRIVATE VOID vTask( PVOID arg )
//boOK &= USFL_boInitializeModule();
boOK &= VARH_boInitializeModule();
boOK &= DIPO_boInitializeModule();
boOK &= DIPO_boInitializeModule();
boOK &= ANPI_boInitializeModule();
boOK &= ANPO_boInitializeModule();
boOK &= SPID_boInitializeModule();
boOK &= ADCD_boInitializeModule();
boOK &= TEMP_boInitializeModule();
boOK &= PECO_boInitializeModule();
boOK &= CAND_boInitializeModule();
boOK &= PECO_boInitializeModule();
boOK &= MAIN_boInitializeModule();
if( !boOK ){
osKernelLock(); // lock kernel to prevent task switch
while( 1 ){
while( 1 ){ // Toggle Error LED fast
DIPO_vToggleOutput( DIPO_eLED );
DELAY_MS( 100 );
}

View File

@ -30,17 +30,16 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "MAIN_MainApplication.h"
// Application
#include "VARH_VariableHandler.h"
#include "PECO_PeltierController.h"
// Drivers
#include "../Drivers/TEMP_Temperature.h"
#include "../Drivers/DIPO_DigitalPorts.h"
#include "../Drivers/CAND_CanDriver.h"
#include "PECO_PeltierController.h"
#include "../Drivers/ANPI_AnalogPortsIn.h"
// Toolbox
@ -126,12 +125,11 @@ LOCAL CONST osThreadAttr_t stTaskAttribute =
0, // size of provided memory for control block
NULL, // memory for stack
1024, // size of stack
osPriorityNormal, // initial thread priority (default: osPriorityNormal)
osPriorityAboveNormal1, // initial thread priority (default: osPriorityNormal)
0, // TrustZone module identifier
0, // reserved (must be 0)
};
LOCAL CONST osMessageQueueAttr_t stCANRxMsgQueueAttribute =
{
"MAIN_CAN_Rx_Queue", // name of the message queue
@ -142,8 +140,6 @@ LOCAL CONST osMessageQueueAttr_t stCANRxMsgQueueAttribute =
0, // size of provided memory for data storage
};
LOCAL CONST osEventFlagsAttr_t stEventAttribute =
{
"MAIN_Event_Flags", // name of the event flags
@ -232,34 +228,35 @@ PRIVATE VOID vTask( PVOID arg )
while( TRUE )
{
u32Flags = osEventFlagsWait( m_pstEventID, EVENT_FLAGS_ALL, osFlagsWaitAny, osWaitForever );
u32Flags = osEventFlagsWait( m_pstEventID, EVENT_FLAGS_ALL, osFlagsWaitAny, osWaitForever ); // wait until flags getting triggered
if( u32Flags & EVENT_NEW_MESSAGE ) {
if( u32Flags & EVENT_NEW_MESSAGE ) { // New message from CAN
CAND_Message stMessage;
osMessageQueueGet( m_pstCANRxMsgQueueID, &stMessage, NULL, 0 );
osMessageQueueGet( m_pstCANRxMsgQueueID, &stMessage, NULL, 0 ); // get message from queue
U8 u8Register = stMessage.au8Data[0];
U8 u8Type = stMessage.u8Type;
if( u8Type == MESSAGE_TYPE_READ ){
if( u8Register >= VARH_eNumberOfVariables ){
au8Buffer[0] = 0xFF;
if( u8Type == MESSAGE_TYPE_READ ){ // Message type read
if( u8Register >= VARH_eNumberOfVariables ){ // check register
// send register not found
au8Buffer[0] = 0xFF;
CAND_boSendMessage( au8Buffer, 1 );
} else {
VARH_UVariable uVariable = VARH_uGetVariableData(u8Register);
VARH_UVariable uVariable = VARH_uGetVariableData(u8Register); // get data
au8Buffer[0] = u8Register;
UTIL_vMemCopy(&uVariable, &au8Buffer[1], 4);
UTIL_vMemCopy(&uVariable, &au8Buffer[1], 4); // copy data in buffer
CAND_boSendMessage( au8Buffer, 5 );
}
} else if( u8Type == MESSAGE_TYPE_WRITE ){
} else if( u8Type == MESSAGE_TYPE_WRITE ){ // Message type write
VARH_UVariable uData;
UTIL_vMemCopy(&stMessage.au8Data[1], &uData, 4);
VARH_vSetVariableData(u8Register, uData);
} else if( u8Type == MESSAGE_TYPE_COMMAND ){
} else if( u8Type == MESSAGE_TYPE_COMMAND ){ // Message type command
switch (u8Register)
{
@ -271,7 +268,7 @@ PRIVATE VOID vTask( PVOID arg )
PECO_Enable( FALSE );
break;
case COMMAND_WATCHDOG:
osTimerStart( m_pstWatchdogTimer, WATCHDOG )
osTimerStart( m_pstWatchdogTimer, WATCHDOG );
break;
default:
break;

View File

@ -30,7 +30,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "PECO_PeltierController.h"
//Application

View File

@ -7,7 +7,7 @@
//-------------------------------------------------------------------------------------------------
//
// Project: Peltier Controller V2
// Author: Noah Piqu<EFBFBD> (noah.pique@psi.ch)
// Author: Noah Piqué (noah.pique@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//

View File

@ -28,7 +28,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "VARH_VariableHandler.h"
// Toolbox
@ -72,7 +71,7 @@ LOCAL osMutexId_t m_pstMutexID = NULL;
LOCAL CONST VARH_StVarInfo m_astVarInfo[VARH_eNumberOfVariables] =
{
{ VARH_FLAGINFO_BOOL, (VARH_UVariable)(U32)1, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)1}, // VARH_eMode
{ VARH_FLAGINFO_NONE, (VARH_UVariable)(U32)1, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)1}, // VARH_eMode
{ VARH_FLAGINFO_FLOAT, (VARH_UVariable)0.0f, (VARH_UVariable)-2.0f, (VARH_UVariable)12.0f}, // VARH_eControlVoltage

View File

@ -30,7 +30,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "ADCD_AdcDriver.h"
// Drivers

View File

@ -28,11 +28,8 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "ANPI_AnalogPortsIn.h"
//Application
#include "../Application/VARH_VariableHandler.h"

View File

@ -30,7 +30,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "ANPO_AnalogPortsOut.h"
// Toolbox

View File

@ -30,7 +30,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "CAND_CanDriver.h"
// Toolbox

View File

@ -7,7 +7,7 @@
//-------------------------------------------------------------------------------------------------
//
// Project: Peltier Controller V2
// Author: Noah Piqu<EFBFBD> (noah.pique@psi.ch)
// Author: Noah Piqué (noah.pique@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//
@ -34,7 +34,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "DIPO_DigitalPorts.h"
//Application

View File

@ -30,7 +30,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "ERRH_ErrorHandler.h"
// Toolbox

View File

@ -30,7 +30,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "SPID_SpiDriver.h"
// Application

View File

@ -28,7 +28,6 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "TEMP_Temperature.h"
// Application
@ -38,7 +37,7 @@
#include "../Toolbox/UTIL_Utility.h"
// Drivers
#include "ADCD_ADCDriver.h"
#include "ADCD_AdcDriver.h"
// include STM32 drivers
#include "stm32l4xx_hal.h"

View File

@ -45,11 +45,10 @@
// Description: List of required include files.
//=================================================================================================
#include "../PDEF_ProjectDefinitions.h"
#include "USFL_UserFlash.h"
// Toolbox
#include "../Toolbox/UTIL_Utility.h"
#include "../Application/VARH_VariableHandler.h"
// include STM32 drivers
#include "stm32l4xx_hal.h"
@ -64,9 +63,11 @@
#define USERFLASHSIZE (2000/4) // Bytes -> 64 Bits
#define USERFLASHPAGE (63)
#define STARTDEF 0xAA01F055
#define VARDEF 0xABCDEF
#define STARTDEF (((U64)0xAA01F055 << 32) + (VARDEF << 2))
#define VARDEF 0xABCDEF00
//=================================================================================================
// Section: MACROS
@ -100,7 +101,7 @@ FLASH_EraseInitTypeDef stEreaseInit = {
// Description: Definition of local variables (visible by this module only).
//=================================================================================================
U32 u32VarPointer = 0;
//=================================================================================================
// Section: LOCAL CONSTANTS
@ -116,6 +117,8 @@ __attribute__((__section__(".user_data"))) const U64 UserFlash[USERFLASHSIZE];
BOOL vEreaseUserFlash( void );
U32 vFindNextFreePointer( void );
U32 u32FindLastPointer( void );
U8 u8ConvertWordsToDoubleWords( U8 u8Words );
//=================================================================================================
// Section: GLOBAL FUNCTIONS
@ -142,6 +145,14 @@ BOOL USFL_boInitializeModule( VOID )
return( boOK );
}
VARH_UVariable USFL_uGetVariable ( void ){
if( u32VarPointer == 0 ) u32VarPointer = u32FindLastPointer();
}
//=================================================================================================
@ -150,27 +161,27 @@ BOOL USFL_boInitializeModule( VOID )
//=================================================================================================
//-------------------------------------------------------------------------------------------------
// Function: vFindNextFreePointer
// Description: Ereases the User Flash Sector
// Function: u32FindNextFreePointer
// Description: Finds the next free sector in the flash for saving variables
// Parameters: None
// Returns: Boolean TRUE if successful
// Returns: U32 next free pointer
//-------------------------------------------------------------------------------------------------
U32 vFindNextFreePointer( void ){
U32 u32FindNextFreePointer( void ){
BOOL boFound = FALSE;
U32 u32Pointer = 1; // 0 is StartDef
U32 u32Pointer = u32VarPointer;
while(!boFound){
if( (UserFlash[u32Pointer] & 0xFFFFFF00) == VARDEF ){
if( ( ( UserFlash[u32Pointer] >> 8 ) & 0xFFFFFF ) == VARDEF ){
U8 u8Size = UserFlash[u32Pointer] & 0xFF;
if( u8Size == 0 ){
boFound = TRUE;
} else {
u32Pointer += u8Size + 1;
u32Pointer += u8ConvertWordsToDoubleWords(u8Size);
}
} else {
return 0;
u32Pointer += 1;
}
if( u32Pointer >= USERFLASHSIZE ){
@ -182,6 +193,58 @@ U32 vFindNextFreePointer( void ){
}
//-------------------------------------------------------------------------------------------------
// Function: u32FindLastPointer
// Description: Finds the next free sector in the flash for saving variables
// Parameters: None
// Returns: U32 next free pointer
//-------------------------------------------------------------------------------------------------
U32 u32FindLastPointer( void ){
BOOL boFound = FALSE;
U32 u32Pointer = 0;
U8 u8LastSize = 0;
while(!boFound){
if( ( UserFlash[u32Pointer] >> 40) == VARDEF ){
U8 u8Size = UserFlash[u32Pointer] & 0xFF;
if( u8Size == 0 ){
boFound = TRUE;
u32Pointer -= u8ConvertWordsToDoubleWords(u8LastSize);
} else {
u32Pointer += u8ConvertWordsToDoubleWords(u8Size);
u8LastSize = u8Size;
}
} else {
u32Pointer += 1;
}
if( u32Pointer >= USERFLASHSIZE ){
u32Pointer = 1;
break;
}
}
return u32Pointer;
}
//-------------------------------------------------------------------------------------------------
// Function: u8ConvertWordsToDoubleWords
// Description: Converts 32Bit Word size to 64 Bit Double Word size for saving Vars
// Parameters: U8 u8Words
// Returns: U8 Double Words
//-------------------------------------------------------------------------------------------------
U8 u8ConvertWordsToDoubleWords( U8 u8Words ) {
U8 u8DWords;
u8Words += 1; // + VARDEF
u8DWords = u8Words / 2;
u8DWords += u8Words % 2;
return u8DWords;
}
//-------------------------------------------------------------------------------------------------
// Function: vEreaseUserFlash
// Description: Ereases the User Flash Sector
@ -191,10 +254,19 @@ U32 vFindNextFreePointer( void ){
BOOL vEreaseUserFlash( void ){
uint32_t u32PageError = 0;
if( HAL_FLASHEx_Erase(&stEreaseInit, &u32PageError) != HAL_OK ){
BOOL boOK = TRUE;
HAL_FLASH_Unlock();
boOK &= HAL_FLASHEx_Erase(&stEreaseInit, &u32PageError) == HAL_OK ? TRUE : FALSE;
if( !boOK ){
return FALSE;
}
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, (U32) &UserFlash[0], STARTDEF);
HAL_FLASH_Lock();
return TRUE;
}

View File

@ -1,147 +0,0 @@
//=================================================================================================
//
// Company: Paul Scherrer Institut
// 5232 Villigen PSI
// Switzerland
//
//-------------------------------------------------------------------------------------------------
//
// Project: High Stability Current Source
// Author: Lukas Kuenzi (lukas.kuenzi@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//
// Module: Project definitions
// Filename: PDEF_ProjectDefinitions.h
// Date: Handled by Subversion (version control system)
// Revision: Handled by Subversion (version control system)
// History: Handled by Subversion (version control system)
//
//-------------------------------------------------------------------------------------------------
//
// Description: Project definitions
//
//=================================================================================================
#ifndef PDEF_PROJECT_DEFINITIONS_H
#define PDEF_PROJECT_DEFINITIONS_H
#ifdef __cplusplus
extern "C" {
#endif
//=================================================================================================
// Section: INCLUDES
// Description: List of required include files (visible by all modules).
//=================================================================================================
//=================================================================================================
// Section: DEFINITIONS
// Description: Definition of global constants (visible by all modules).
//=================================================================================================
// Firmare version:
// example: "1.1.2"
// 1. Digit: Major number for big changes = "01" and up
// 2. Digit: Minor number for small changes = "1" and up
// 3. Digit: Development version number = "1" and up
#define PDEF_FW_VERSION_HEX 0x0001 // coding: 0xUVW
// U: major number,
// V: minor number,
// W: development version
// Compiler switches
#define PDEF_FUNCTION_PARAMETER_CHECK_ENABLED FALSE
#define PDEF_USE_ASSERTION TRUE
#define PDEF_USE_STM32_FULL_ASSERT FALSE
// definie interrupt priorities
//-------------------------------------------------------------------------------------------------
// preemption priority range: 0-15
// sub priority range: no subpriority
// 0: highest priority, 15: lowest priority
// same priorities are allowed
#define PDEF_NVIC_PRIORITY_GROUPING NVIC_PRIORITYGROUP_4
#define PDEF_MSCB_IRQ_PREEMPT_PRIO 0
#define PDEF_MSCB_IRQ_SUB_PRIO 0
#define PDEF_RS485_IRQ_PREMPT_PRIO 0
#define PDEF_RS485_IRQ_SUB_PRIO 0
#define PDEF_EXTI_IRQ_PREEMPT_PRIO 1
#define PDEF_EXTI_IRQ_SUB_PRIO 0
#define PDEF_ADCS_SPI_IRQ_PREEMPT_PRIO 1
#define PDEF_ADCS_SPI_IRQ_SUB_PRIO 0
#define PDEF_DACS_SPI_IRQ_PREEMPT_PRIO 1
#define PDEF_DACS_SPI_IRQ_SUB_PRIO 0
#define PDEF_CHARGE_PUMP_DAC_SPI_IRQ_PREEMPT_PRIO 1
#define PDEF_CHARGE_PUMP_DAC_SPI_IRQ_SUB_PRIO 0
#define PDEF_CRC_DMA_IRQ_PREEMPT_PRIO 1
#define PDEF_CRC_DMA_IRQ_SUB_PRIO 0
#define PDEF_FLASH_IRQ_PREEMPT_PRIO 1
#define PDEF_FLASH_IRQ_SUB_PRIO 0
#define PDEF_SVC_IRQ_PREEMPT_PRIO 14 // must be one preempt prio higher than PendSV
#define PDEF_SVC_IRQ_SUB_PRIO 0
#define PDEF_PENDSV_IRQ_PREEMPT_PRIO 15 // lowest priority = same as systick
#define PDEF_PENDSV_IRQ_SUB_PRIO 0
//=================================================================================================
// 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).
//=================================================================================================
#ifdef __cplusplus
}
#endif
#endif

View File

@ -7,7 +7,7 @@
//-------------------------------------------------------------------------------------------------
//
// Project: Peltier Controller V2
// Author: Noah Piqu<EFBFBD> (noah.pique@psi.ch)
// Author: Noah Piqué (noah.pique@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//

View File

@ -1,136 +0,0 @@
//=================================================================================================
//
// Company: Paul Scherrer Institut
// 5232 Villigen PSI
// Switzerland
//
//-------------------------------------------------------------------------------------------------
//
// Project: SCS-3000
// Author: Lukas Kuenzi (lukas.kuenzi@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//
// Module: Template source file
// Filename: TMPL_Template.c
// Date: Handled by Subversion (version control system)
// Revision: Handled by Subversion (version control system)
// History: Handled by Subversion (version control system)
//
//-------------------------------------------------------------------------------------------------
//
// Description: Source file template
//
//=================================================================================================
//=================================================================================================
// Section: INCLUDES
// Description: List of required include files.
//=================================================================================================
#include "TMPL_Template.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).
//=================================================================================================
typedef enum
{
eX = 0,
eY
} EnExample;
//=================================================================================================
// Section: STRUCTURES
// Description: Definition of local Structures (visible by this module only).
//=================================================================================================
typedef struct
{
U32 u32X;
BOOL boY;
} StExample;
//=================================================================================================
// 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: EXTERNAL FUNCTIONS
// Description: Definition of external (global) functions.
//=================================================================================================
//=================================================================================================
// Section: EXTERNAL VARIABLES
// Description: Definition of external (global) variables.
//=================================================================================================
//=================================================================================================
// Section: GLOBAL FUNCTIONS
// Description: Definition (implementation) of global functions.
//=================================================================================================
//-------------------------------------------------------------------------------------------------
// Function: TMPL_boInitializeModule
// Description: Initializes the module. Function must be called once immediately after power-up.
// Parameters: None
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL TMPL_boInitializeModule( VOID )
{
return( FALSE );
}
//=================================================================================================
// Section: LOCAL FUNCTIONS
// Descriptionn: Definition (implementation) of local functions.
//=================================================================================================

View File

@ -1,105 +0,0 @@
//=================================================================================================
//
// Company: Paul Scherrer Institut
// 5232 Villigen PSI
// Switzerland
//
//-------------------------------------------------------------------------------------------------
//
// Project: SCS-3000
// Author: Lukas Kuenzi (lukas.kuenzi@psi.ch)
//
//-------------------------------------------------------------------------------------------------
//
// Module: Header File Template
// Filename: TMPL_Template.h
// Date: Handled by Subversion (version control system)
// Revision: Handled by Subversion (version control system)
// History: Handled by Subversion (version control system)
//
//-------------------------------------------------------------------------------------------------
#ifndef TMPL_TEMPLATE_H
#define TMPL_TEMPLATE_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).
//=================================================================================================
typedef enum
{
TMPL_eX = 0,
TMPL_eY
} TMPL_EnExample;
//=================================================================================================
// Section: STRUCTURES
// Description: Definition of global Structures (visible by all modules).
//=================================================================================================
typedef struct
{
U32 u32X;
BOOL boY;
} TMPL_StExample;
//=================================================================================================
// 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 TMPL_boInitializeModule( VOID );
#ifdef __cplusplus
}
#endif
#endif