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

📄 vtpos.c

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 C
字号:
/***************************
*      VTPos.c      ZTL    *
***************************/
#define  VTPOS_GLOBALS
#include "includes.h"
#include "bsp.h"
#include "Timetask.h"
#include "Public.h"
#include "Gpsrecer.h"
#include "VtPos.h"
#include "tools.h"
#include "zprint.h"
#include "almtask.h"
#include "message.h"
#include "debug.h"

#define  VTPOS_DEBUG  0

static TMR_TSK *VTCheckTmrID;
static TMR_TSK *VTDelayTmr;
static INT8U OverSpeedCount;
static INT8U DelayPeriod[4] = {1,1,2,2};
static INT8U COUNT;
#define VTCheckPeriod	SECOND,1
#define MAX_OVERSPEED_COUNT 5

static INT8U VTStatus;
#define OVERSPEED   0xAA

static INT8U Vector;

static void VTDelayProc(void)
{
     if (Vector > VTPosPara.LimitVector)
     {
          OverSpeedCount = 0;
    	  VTStatus=!OVERSPEED;
     }
     else
     {
         COUNT = 0;
         StopTmr(VTDelayTmr); 
     }
}
static void VTCheckTmr(void)
{
     StartTmr(VTCheckTmrID,VTCheckPeriod);
    
     if(VTPosPara.Status!=OPEN) return;

     #if VTPOS_DEBUG > 0
	  PrintFromUART(0x01,"\nVTCheckTmr");
     #endif

     Vector =GetVector();

     if(Vector>VTPosPara.LimitVector)
     {
	      OverSpeedCount++;
      
          if((VTStatus==(!OVERSPEED))&&(OverSpeedCount >= MAX_OVERSPEED_COUNT))
	      {
		   #if VTPOS_DEBUG > 0
		   PrintFromUART(0x01,"\n超速报警");
		   #endif
		 	OverSpeedCount = 0;
	 		VTStatus=OVERSPEED;
	 		
	 		if (COUNT<4)
	 		{
	 		    StartTmr(VTDelayTmr,MINUTE,DelayPeriod[COUNT++]);
	 		}
	 		else
	 		{
	 		    COUNT = 0; 
	 		}
	 		OSQPost(AlmTaskMsgQue, MSG_ALARM_OVERSPEED, VTPosPara.LimitVector, 0);
	 		
	      }
    }
    else
    {
    	 OverSpeedCount = 0;
    	 VTStatus=!OVERSPEED;
    }
}


BOOLEAN CheckVector(INT8U Node)
{
     Node=Node;
     if(!GpsDataValid()) return FALSE;
     if(GetVector()>VTPosPara.LimitVector){
     		return TRUE;
	}
     else return FALSE;

}
void VTPosInit(void)
{
   #if VTPOS_DEBUG > 0
	PrintFromUART(0x01,"\nVTPosInit");
	#endif
   VTStatus=!OVERSPEED;
   COUNT = 0;
   
   VTCheckTmrID=CreateTimer(VTCheckTmr,0);
   VTDelayTmr = CreateTimer(VTDelayProc,0);

   if(((VTPosPara.Status!=OPEN)&&(VTPosPara.Status!=CLOSE))||(!PubParaValid(VTPARA_)))
   {
      VTPosParaClear();
   }

   if(VTPosPara.Status==OPEN)
   {
       StartTmr(VTCheckTmrID,VTCheckPeriod);
   }
}

INT8U VTPosParaSet(INT8U *ParaSetPtr)
{
	#if VTPOS_DEBUG > 0
	PrintFromUART(0x01,"\nVTPosParaSet");
	#endif
   VTPosPara.LimitVector=*ParaSetPtr;
   VirStorePubPara(VTPARA_);
   return 1;
}

void VTPosParaClear(void)
{

   ClearPubPara(VTPARA_);
   VTPosPara.LimitVector=0xFF;

}

void VTPosStart(void)
{
	#if VTPOS_DEBUG > 0
	PrintFromUART(0x01,"\nVTPosStart");
	#endif
    VTStatus=!OVERSPEED;
    VTPosPara.Status=OPEN;
    OverSpeedCount = 0;
    StorePubPara(VTPARA_);
    StartTmr(VTCheckTmrID,VTCheckPeriod);
}

void VTPosStop(void)
{
   VTStatus=!OVERSPEED;
   VTPosPara.Status=CLOSE;
   StorePubPara(VTPARA_);
   StopTmr(VTCheckTmrID);
}

⌨️ 快捷键说明

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