linserviceroutinetemplate.c

来自「这是关于基于philips的764单片机的LIN程序设计」· C语言 代码 · 共 77 行

C
77
字号
#include "TJA1020.h"
#include "LinCmpSl.h"
#include "Relpc764.h"

char* data LinDataPtr;

//only for example
char aktTemp;

void LinServiceRoutine() 
{
//**do not delete**
 asm{0xC0, 0xD0}; //Push PSW
 asm{0xC0, 0xE0}; //Push ACC
 asm{0xC0, 0x00}; //Push AR0
//*****************
 
 if (LinError==0) //Test if LinError is '0'
   {
    if (LinFrameOk) 
      {
 //process here all IDs, the node should receive
 //e.g.
       if (LinID==0x14)
       	aktTemp=LinDataPtr[0];
      }
    else if (LinIDreceived)
      {
//process here all IDs, the node should send
//e.g.
       if (LinID==0x10)
       	{
       	  LinDataPtr[0]=0x08;
       	  TI=1;
       	 }
       else if (LinID==0x11)
         {
       	 LinDataPtr[0]=0x15;
       	 TI=1;
       	}
       else if (LinID==0x12)
         {
       	 LinDataPtr[0]=0x47;
       	 TI=1;
       	}
       else if (LinID==0x13)
         {
       	 LinDataPtr[0]=0x11;
       	 TI=1;
       	}		
      } 
   }
  else
   {
//process here the reaction on a Lin error
    LinError=0;
   }
   
//**do not delete**
 asm{0xD0, 0x00}; //Push AR0  
 asm{0xD0, 0xE0}; //Push ACC
 asm{0xD0, 0xD0}; //Push PSW  
//***************** 
 return;
} 



void main()
 {
  LinDataPtr=&LinData;
  InitTranceiver();
  InitLinMac();
  
  while(1){};
 }

⌨️ 快捷键说明

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