⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.h

📁 《OSEK/VDX汽车电子嵌入式软件编程技术》中光盘的资料
💻 H
字号:
/************************************************
*
*	$Copyright    2001 Joseph J. Lemieux  ALL RIGHTS RESERVED. $
*
*	$Filename: C:\OSEKBook\src\CH11\inc\init.h $
*
*   Description:  Header file for the register
*                 initialization module.
*
************************************************/
#ifndef INITH
#define INITH

/************************************************
*
*   Include files
*
************************************************/

#include "typedefs.h"
#include "register.h"

/************************************************
*
*   Public macros
*
************************************************/

/*********************
*
*   16 bit register file definition macros.
*   Used in init.cfg to define registers. See
*   .cfg file for usage description.
*
*********************/
#ifdef INITC

#define START_INIT_REG16_LIST(name,size) \
   InitReg16ListType const name[size+1] = {
#define ADD_INIT_REG16_LIST(reg,value) \
   {reg,(UINT16)value},
#define END_INIT_REG16_LIST \
   NULL,0};

#else /* INITC */

#define START_INIT_REG16_LIST(name,size) \
extern InitReg16ListType const name[size+1];
#define ADD_INIT_REG16_LIST(reg,value)
#define END_INIT_REG16_LIST

#endif /* INITC */

/*********************
*
*   32 bit register file definition macros
*   Used in init.cfg to define registers. See
*   .cfg file for usage description.
*
*********************/
#ifdef INITC

#define START_INIT_REG32_LIST(name,size) \
   InitReg32ListType const name[size+1] = {
#define ADD_INIT_REG32_LIST(reg,value) \
   {reg,(UINT32)value},
#define END_INIT_REG32_LIST \
   NULL,0};

#else /* INITC */

#define START_INIT_REG32_LIST(name,size) \
extern InitReg32ListType const name[size+1];
#define ADD_INIT_REG32_LIST(reg,value)
#define END_INIT_REG32_LIST

#endif /* INITC */

/*********************
*
*   Initialize Function Definition Macros
*   Used in init.cfg to define registers. See
*   .cfg file for usage description.
*
*********************/
#ifdef INITC

#define START_INIT_FUNCTION_LIST(name,size) \
   InitFunctionListType const name[size+1] = {
#define ADD_INIT_FUNCTION_LIST(function) \
   {function},
#define END_INIT_FUNCTION_LIST \
   NULL};

#else /* INITC */

#define START_INIT_FUNCTION_LIST(name,size) \
extern InitFunctionListType const name[size+1];
#define ADD_INIT_FUNCTION_LIST(function)
#define END_INIT_FUNCTION_LIST

#endif /* INITC */

/*********************
*
*   Alarm Autostart Definition Macros
*   Used in init.cfg to define alarms. See
*   .cfg file for usage description.
*
*********************/
#ifdef INITC

#define START_ALARM_AUTOSTART_LIST(name,size) \
   InitAlarmType const name[size+1] = {
#define ADD_ALARM_AUTOSTART_LIST(alarm,alarmtype,start,cycle,appmodemask) \
   {alarm,alarmtype,start,cycle,appmodemask},
#define END_ALARM_AUTOSTART_LIST \
   (AlarmType)0,ALARM_ABS,0,0,0};

#else /* INITC */

#define START_ALARM_AUTOSTART_LIST(name,size) \
extern InitAlarmType const name[size+1];
#define ADD_ALARM_AUTOSTART_LIST(alarm,alarmtype,start,cycle,appmodemask)
#define END_ALARM_AUTOSTART_LIST

#endif /* INITC */
#define ALARM_ALL_MODES 0xFFFFFFFF
/************************************************
*
*   Typedefs
*
************************************************/

/*********************
*
*   16 bit register init structures
*
*********************/
typedef struct InitReg16ListTypetag {
   UINT16 volatile * reg;
   UINT16 value;
   }InitReg16ListType;

/*********************
*
*   32 bit register init structures
*
*********************/
typedef struct InitReg32ListTypetag {
   UINT32 volatile * reg;
   UINT32 value;
   }InitReg32ListType;

/*********************
*
*   Types of valid initializations.
*   Enumeration of valid initialization types that can
*   be sent to InitSystem.
*
*********************/
typedef enum InitTypetag {
   INIT_RESET,
   INIT_STARTUP,
   INIT_SHUTDOWN
   }InitType;

/*********************
*
*   Initialize Functions Typedef
*
*********************/
typedef struct InitFunctionListTypetag {
   void ((*initfunction)(InitType));
   }InitFunctionListType;

typedef enum AlarmFunctionTypetag {
   ALARM_REL,
   ALARM_ABS
   }AlarmFunctionType;

/*********************
*
*   Initialize Functions Typedef
*
*********************/
typedef struct InitAlarmTypetag {
   AlarmType alarm;
   AlarmFunctionType alarmtype;
   TickType start;
   TickType cycle;
   UINT32 appmodemask;
   }InitAlarmType;

/************************************************
*
*   Public Interfaces
*
************************************************/

/************************************************
*
*   Function:     InitReg16
*
*   Inputs:       list - pointer to the null terminated list of 
*                 register:value pairs.
*
*   Outputs:      All registers in list are set to value.
*
*   Returns:      None.
*
*   Description:  This routine navigates a list of 16 bit
*                 registers and set them to a default value.
*                 Terminates when it hits a NULL pointer.
*
************************************************/
void InitReg16(InitReg16ListType const *);

/************************************************
*
*   Function:     InitReg32
*
*   Inputs:       list - pointer to the null terminated list of 
*                 register:value pairs.
*
*   Outputs:      All registers in list are set to value.
*
*   Returns:      None.
*
*   Description:  This routine navigates a list of 32 bit
*                 registers and set them to a default value.
*                 Terminates when it hits a NULL pointer.
*
************************************************/
void InitReg32(InitReg32ListType const *);

/************************************************
*
*   Function:     InitSPR
*
*   Inputs:       none
*
*   Outputs:      SPRs are set as required
*
*   Returns:      none
*
*   Description:  Sets the Special Purpose Registers
*
************************************************/
void InitSPR(void);

/************************************************
*
*   Function:     InitSystem
*
*   Inputs:       type - type of initialization occurring.
*
*   Outputs:      none
*
*   Returns:      none
*
*   Description:  Calls all functions in the list to initialize
*                 the application. Terminates when it hits a NULL 
*                 pointer.
*
************************************************/
void InitSystem(InitType type);

/************************************************
*
*   Public Constants
*
*   All public constants are defined in the .cfg
*   header files
*
************************************************/
#include "init.cfg"

#endif /* INITH */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -