?? task_mycan.c
字號:
#include "Includes.h"
#include "PortAB.h"
#include "Types.h"
#include "JCanCntrl.h"
#include "J1939PGN.h"
#include "J1939TRA.h"
#include "J1939CFG.h"
#include "J1939EXT.h"
static OS_STK Task_MyCAN_STK[OS_STK_DEFAULT_SIZE];
#define TASK_MyCAN_PRIO 0x17 //priority
#define MyCANBAUD_RATE 5 /* for 250 kb seet table in "canxxx.c" */
void Task_MyCAN(void *pdata)
{
gMyCan_CntrlInit(MyCANBAUD_RATE);
while(1)
{
gCB_Init();
InitMyCANPGs();
/*handle received PG of MyCAN */
if (gRxMyPG.mEnable) /* Process PG */
{
if (gRxMyPG.mPGState == PG_RX_FULL) /* PG received? */
{
gRxMyPG.mTimer = Tim_GetCurrentTime(); /* Reset Timer */
gRxMyPG.mPGState = PG_RX_FREE; /* Free buffer */
break;
}
else if (gRxMyPG.mTransType == TT_CYCLIC) /* Cyclic reception */
{
if (Tim_CheckTimeOut(gRxMyPG.mTimer,Tim_GetCurrentTime(),gRxMyPG.mTransRate)) /* Timeout? */
{
gRxMyPG.mTimer = Tim_GetCurrentTime(); /* Reset Timer */
/* break; */ /* No break because of a missing PG would stop whole reception */
}
}
}
/*handle sended PG of MyCAN */
if (gTxMyPG.mEnable) /* Process PG? */
{
if (gTxMyPG.mTransType == TT_CYCLIC) /* Cyclic trasmission */
{
if ((Tim_CheckTimeOut(gTxMyPG.mTimer,Tim_GetCurrentTime(),gTxMyPG.mTransRate))
&& (gTxMyPG.mPGState == PG_TX_REQ))
/* Check timer */
{
gCB_SendUserPG(&gTxMyPG);
break;
}
else if(gTxMyPG.mPGState == PG_TX_XMT)
{
/* transmission delayed */
/* UserFunctionTransmissionDelay() */
}
else if (gTxMyPG.mPGState == PG_TX_TX)
{
gTxMyPG.mPGState = PG_TX_REQ; /* Free buffer */
gTxMyPG.mTimer = Tim_GetCurrentTime(); /* Reset Timer */
break;
}
}
}
OSTimeDly(1);
}/*while(1)*/
}
void Task_MyCAN_Create(void)
{
#if OS_TASK_CREATE_EXT_EN==1
OSTaskCreateExt(Task_MyCAN,
(void*)0,
&Task_MyCAN_STK[OS_STK_DEFAULT_SIZE-1],
TASK_MyCAN_PRIO,
TASK_MyCAN_PRIO,
&Task_MyCAN_STK[0],
OS_STK_DEFAULT_SIZE,
(void*) 0,
OS_TASK_OPT_STK_CHK|OS_TASK_OPT_STK_CLR);
#else
OSTaskCreate(Task_MyCAN,
(void*)0,
&Task_MyCAN_STK[OS_STK_DEFAULT_SIZE-1],
TASK_MyCAN_PRIO);
#endif
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -