📄 events.c
字号:
/** ###################################################################
** Filename : Events.C
** Project : NODE_A
** Processor : MC9S12C64CFA16
** Beantype : Events
** Version : Driver 01.04
** Compiler : Metrowerks HC12 C Compiler
** Date/Time : 2006-11-11, 13:11
** Abstract :
** This is user's event module.
** Put your event handler code here.
** Settings :
** Contents :
** CAN1_OnFullRxBuffer - void CAN1_OnFullRxBuffer(void);
** AS1_OnRxChar - void AS1_OnRxChar(void);
** TI1_OnInterrupt - void TI1_OnInterrupt(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"
#include "Com.h"
#pragma CODE_SEG DEFAULT
byte sci_command; //command received from SCI
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 ID;
byte i;
CAN1_ReadFrame(&can_messageID,&can_messageType,&can_messageFormat,&can_messageLength,can_messageData);
printf0("\n\tNew Message! \r");
printf0("\n\tMessage ID: \r");
/*ID = can_messageID&0xFF;
hex_asc(ID);
ID = (can_messageID>>8)&0xFF;
hex_asc(ID);
ID = (can_messageID>>16)&0xFF;
hex_asc(ID);
ID = (can_messageID>>24)&0xFF;
hex_asc(ID);
printf0("\n\tMessage Length: \r");
hex_asc(can_messageLength);
printf0("\n\tMessage Data: \r");
for(i=0;i<can_messageLength;i++)
{
hex_asc(can_messageData[i]);
}
*/
ID = can_messageID&0xFF;
tx_char0(ID);
ID = (can_messageID>>8)&0xFF;
tx_char0(ID);
ID = (can_messageID>>16)&0xFF;
tx_char0(ID);
ID = (can_messageID>>24)&0xFF;
tx_char0(ID);
printf0("\n\tMessage Length: \r");
tx_char0(can_messageLength);
printf0("\n\tMessage Data: \r");
for(i=0;i<can_messageLength;i++)
{
tx_char0(can_messageData[i]);
}
}
/*
** ===================================================================
** Event : AS1_OnRxChar (module Events)
**
** From bean : AS1 [AsynchroSerial]
** Description :
** This event is called after a correct character is
** received.
** DMA mode:
** If DMA controller is available on the selected CPU and
** the receiver is configured to use DMA controller then
** this event is disabled. Only OnFullRxBuf method can be
** used in DMA mode.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
void AS1_OnRxChar(void)
{
/* Write your code here ... */
byte bufferNum;
dword ID;
byte type;
byte length;
byte data[8];
if(CANTFLG_TXE0)
{
bufferNum = 0;
}
else if(CANTFLG_TXE1)
{
bufferNum = 1;
}
else if(CANTFLG_TXE2)
{
bufferNum = 2;
}
ID = 'A'; // Indicate the message is sent by Node A
type = DATA_FRAME;
length = 2;
data[0] = 'A'; //Node A
AS1_RecvChar(&sci_command);
switch(sci_command)
{
case '1':
case '2':
case '3':
case '4':
case '5':
data[1] = sci_command;
CAN1_SendFrame(bufferNum, ID, type, length, data);
break;
default:
printf0("\n\t Invaild Choice \r");
break;
}
printf0("\n\t Please choose the way of LED flashing in the Node B\r");
printf0("\n\t 1. Flash one by one \r");
printf0("\n\t 2. Odd is On, Even is Off \r");
printf0("\n\t 3. Shift \r");
printf0("\n\t 4. All are On \r");
printf0("\n\t 5. All are Off \r");
}
/*
** ===================================================================
** Event : TI1_OnInterrupt (module Events)
**
** From bean : TI1 [TimerInt]
** Description :
** When a timer interrupt occurs this event is called (only
** when the bean is enabled - "Enable" and the events are
** enabled - "EnableEvent").
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
void TI1_OnInterrupt(void)
{
/* Write your code here ... */
Bits1_NegBit(0); //inverts PT1
}
/* 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 + -