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

📄 os.c

📁 《OSEK/VDX汽车电子嵌入式软件编程技术》中光盘的资料
💻 C
字号:
/************************************************
*
*	$Copyright    2001 Joseph J. Lemieux  ALL RIGHTS RESERVED. $
*
*	$Filename: C:\OSEKBook\src\CH13\src\os.c $
*
*	Description: Operating System Portability Module	
*
************************************************/
#ifndef OSC
#define OSC 1

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

#include "typedefs.h"
#include "os.h"
#include "init.h"

/************************************************
*
*	Local macros
*
************************************************/

/************************************************
*
*	Local type definitions
*
************************************************/

/************************************************
*
*	Local Function Prototypes
*
************************************************/

/************************************************
*
*	Local Variables
*
************************************************/
IntDescriptorType intNest;
UINT8 intNestDepth = 0;
/************************************************
*
*	Local Constants
*
************************************************/

/************************************************
*
*	Functions
*
************************************************/
/************************************************
*
*   Function:     OSInit
*
*   Inputs:       type - type of initialization occurring.
*
*   Outputs:      none
*
*   Returns:      void
*
*   Description:  OS Wrapper Initializer. Wraps implementation
*                 specific functions required to initialize
*                 the implementation.
*
************************************************/
void OSInit(InitType type)
{
	if(type==INIT_STARTUP)
   {
      RtcInit(1000000000/OSTICKDURATION,SYSTEM_COUNTER);
      intNestDepth = 0;
   }
}

/************************************************
*
*   Function:     ConvertAppMode
*
*   Inputs:       type - type of appmode conversion -
*                 either APP_MODE_MASK or APP_MODE_NUMBER
*
*   Outputs:      none
*
*   Returns:      UINT32 value either a mask of value from 0-31
*
*   Description:  Portability function to allow portable 
*                 mapping of application modes to either
*                 a scalar or a mask.
*
************************************************/
UINT32 ConvertAppMode(ConvertAppModeType type)
{
UINT32 value = 0x00000000;
ConvertAppModeListType const *list = AppModeList;
AppModeType currentMode = GetActiveApplicationMode();

   while(list->value != 0xFF){
      if(list->mode == currentMode){
         if(type == APP_MODE_MASK){
            value = 1<<list->value;
         }
         else{
            value = list->value;
         }
         break;
      }
      list++;
   }
   return value;
}

/************************************************
*
*   Function:     DisableAllInterrupts
*
*   Inputs:       void
*
*   Outputs:      Stores last in array for nesting.
*
*   Returns:      void
*
*   Description:  Nesting of interrupts is not allowed at this
*                 time in the specification.
*
************************************************/
void DisableAllInterrupts(void)
{
   if(intNestDepth == 0){
      GetInterruptDescriptor(&intNest);
      DisableInterrupt(ALL_INTERRUPTS);
      ++intNestDepth;
   }
}
/************************************************
*
*   Function:     EnableAllInterrupts
*
*   Inputs:       void
*
*   Outputs:      Restores last from array in nesting.
*
*   Returns:      void
*
*   Description:  Allows enabling of interrupts to state
*                 prior to the DisableAllInterrupts call.
*
************************************************/
void EnableAllInterrupts(void)
{
   if(intNestDepth >0){
      EnableInterrupt(intNest);
      --intNestDepth;
   }
}

extern BOOLEAN messageReceived;

TASK(SetNetworkFlag)
{
   messageReceived = TRUE;
   TerminateTask();
}
#endif /* OSC */

⌨️ 快捷键说明

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