📄 init.c
字号:
/************************************************
*
* $Copyright 2001 Joseph J. Lemieux ALL RIGHTS RESERVED. $
*
* $Filename: C:\OSEKBook\src\CH05\src\init.c $
*
* Description: System Initialization Module
* This module provides the interfaces
* that may be used by the system to
* initialize either 16 or 32 bit
* memory mapped registers, and to
* initialize the system based upon the
* type of change.
*
************************************************/
#ifndef INITC
#define INITC
/************************************************
*
* Include files
*
************************************************/
#include "typedefs.h"
#include "os.h"
#include "init.h"
/************************************************
*
* Local macros
*
************************************************/
/************************************************
*
* Local Function Prototypes
*
************************************************/
/************************************************
*
* Local Variables
*
************************************************/
/************************************************
*
* Local Constants
*
************************************************/
/************************************************
*
* Functions
*
************************************************/
/************************************************
*
* 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 *list)
{
while(list->reg != NULL)
{
*list->reg = list->value;
list++;
}
}
/************************************************
*
* 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 *list)
{
while(list->reg != NULL)
{
*list->reg = list->value;
list++;
}
}
/************************************************
*
* 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)
{
/*****
*
* List to be navigated is always InitFunctionList, which
* is defined in init.cfg.
*
*****/
InitFunctionListType const *list = InitFunctionList;
while(list->initfunction != NULL)
{
list->initfunction(type);
list++;
}
}
/************************************************
*
* Task: InitAlarms
*
* Description: Initializes the alarms that are required
* to be automatically started when
* the OS is started.
*
************************************************/
TASK(InitAlarms)
{
InitAlarmType const *list = AlarmAutostartList;
UINT32 currentAppModeMask = ConvertAppMode(APP_MODE_MASK);
while(list->appmodemask != 0x00000000){
if((list->appmodemask & currentAppModeMask)!= 0){
if(list->alarmtype == ALARM_REL){
SetRelAlarm(list->alarm,list->start,list->cycle);
}
else{
SetAbsAlarm(list->alarm,list->start,list->cycle);
}
}
list++;
}
TerminateTask();
}
#endif /*INITC */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -