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

📄 shuffle.c

📁 《OSEK/VDX汽车电子嵌入式软件编程技术》中光盘的资料
💻 C
字号:
/************************************************
*
*	$Copyright    2001 Joseph J. Lemieux  ALL RIGHTS RESERVED. $
*
*	$Filename: C:\OSEKBook\src\CH05\src\shuffle.c $
*
*	Description: Processing Program for Shuffling Switch	
*
************************************************/
#ifndef SHUFFLEC
#define SHUFFLEC

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

#include "typedefs.h"
#include "os.h"
#include "init.h"
#include "hw.h"
#include "dispdrv.h"
#include "shuffle.h"
/************************************************
*
*	Local macros
*
************************************************/

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

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

/************************************************
*
*	Local Variables
*
************************************************/
enum ShuffleStatetag {
   SHUFFLE_HIGH,
   SHUFFLE_LOW
   }ShuffleState;
/************************************************
*
*	Local Constants
*
************************************************/

/************************************************
*
*	Functions
*
************************************************/
/************************************************
*
*   Function:     InitShuffleSwitch
*
*   Inputs:       type - type of initialization occurring.
*
*   Outputs:      none
*
*   Returns:      void
*
*   Description:  Initialize the Shuffle Switch counter.
*
************************************************/
void InitShuffleSwitch(InitType type)
{
   if(type==INIT_STARTUP)
   {
      InitCounter(SHUFFLE_COUNTER,0);
   }
   ShuffleState = SHUFFLE_LOW;
}

/************************************************
*
*   Task:         IOSampleShuffleSwitch
*
*   Description:  Samples shuffling switch, debounces,
*                 and increments counters.
*
************************************************/
TASK(IOSampleShuffleSwitch)
{
static UINT8 timeout;
TickType tick;

   switch(ShuffleState){
      case SHUFFLE_HIGH:
         if(HWGetValue(&SHUFFLESWITCH)==INACTIVE){
            ShuffleState = SHUFFLE_LOW;
         }
         break;
      case SHUFFLE_LOW:
         if(HWGetValue(&SHUFFLESWITCH)==ACTIVE){
            timeout = SHUFFLE_SWITCH_OFF;
            if(GetAlarm(ShuffleAlarm,(TickRefType)tick) == E_OS_NOFUNC){
               SetAbsAlarm(ShuffleAlarm,5,3);
               strcpy(displayBuffer,"\fSHUFFLING -");
               ActivateTask(OutputDisplay);
            }
            ShuffleState = SHUFFLE_HIGH;
            IncrCounter(SHUFFLE_COUNTER);
         }
         else{
				if(timeout!=0){
               if(--timeout == 0){
                  CancelAlarm(ShuffleAlarm);
                  CancelAlarm(SampleShuffleSwitchAlarm);
                  ActivateTask(ShufflingComplete);
               }
            }
         }
         break;
   }
   TerminateTask();
}

#endif /* SHUFFLEC */

⌨️ 快捷键说明

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