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

📄 events.c

📁 基于MC9S12C64的CAN总线通讯源程序
💻 C
字号:
/** ###################################################################
**     Filename  : Events.C
**     Project   : Node_B
**     Processor : MC9S12C64CFA16
**     Beantype  : Events
**     Version   : Driver 01.04
**     Compiler  : Metrowerks HC12 C Compiler
**     Date/Time : 2006-11-11, 15:02
**     Abstract  :
**         This is user's event module.
**         Put your event handler code here.
**     Settings  :
**     Contents  :
**         CAN1_OnFullRxBuffer - void CAN1_OnFullRxBuffer(void);
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2005
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/
/* MODULE Events */


#include "Cpu.h"
#include "Events.h"

#pragma CODE_SEG DEFAULT

dword can_messageID;
byte  can_messageType;
byte  can_messageFormat;
byte  can_messageLength;
byte  can_messageData[8];

/*
** ===================================================================
**     Event       :  CAN1_OnFullRxBuffer (module Events)
**
**     From bean   :  CAN1 [FreescaleCAN]
**     Description :
**         This event is called when the receive buffer is full
**         after a successful reception of a message.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void CAN1_OnFullRxBuffer(void)
{
  /* Write your code here ... */
  byte bufferNum;
  dword ID;
  byte type;
  byte length;
  byte data[8];
  
  CAN1_ReadFrame(&can_messageID,&can_messageType,&can_messageFormat,&can_messageLength,can_messageData);
  
  
  if(CANTFLG_TXE0) 
  {
    bufferNum = 0;
  }
  else if(CANTFLG_TXE1) 
  {
    bufferNum = 1;
  }
  else if(CANTFLG_TXE2) 
  {
    bufferNum = 2;
  }
  
  ID = 'B'; // Indicate the message is sent by Node B
  type = DATA_FRAME;
  length = 8;
  data[0] = 'A';
  data[1] = 'c';
  data[2] = 'k';
  data[3] = 'f';
  data[4] = 'r';
  data[5] = 'o';
  data[6] = 'm';
  data[7] = 'B';
  CAN1_SendFrame(bufferNum, ID, type, length, data);
  
}

/* END Events */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 2.96 [03.76]
**     for the Freescale HCS12 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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