can.c File Reference

#include "t89c51cc02.h"
#include "datatypes.h"
#include "can.h"
#include "command.h"

Go to the source code of this file.

Functions

void CAN_init ()
 initialize CAN Bus to receive and send packages
void CAN_interrupt (void)
 ISR for handling incoming CAN Bus messages.
void CAN_SendACK (BYTE cmd)
 acknowledge last recieved command via CAN Bus
void CAN_SendNAK (BYTE cmd)
 reply when last command was accepted but could not be completed
void CAN_SendMsg (BYTE length)
 transmits a message over the CAN Bus

Variables

volatile BYTE idata can_data [8]
 data buffer to construct CAN messages to be send


Detailed Description

Definition in file can.c.


Function Documentation

void CAN_init void   ) 
 

initialize CAN Bus to receive and send packages

CAN packets are recieved on CAN ID 0x400 (hardcoded into can.h)
CAN packets are transmitted on CAN ID 0x401
The bus is put into 250kbps mode.

Definition at line 29 of file can.c.

References CAN_setchannel, CH_DISABLE, and MSK_CANGCON_GRES.

Referenced by main().

void CAN_interrupt void   ) 
 

ISR for handling incoming CAN Bus messages.

A small implicit state machine is used to decode valid CAN messages.

Definition at line 119 of file can.c.

References can_data, CAN_SendACK(), CAN_SendMsg(), CAN_SendNAK(), CAN_setchannel, Command_CheckTime, Command_ClearMonitor, Command_ClearRead, Command_DisableMonitor(), Command_DisableReport, COMMAND_EEPROM_CLEAR, COMMAND_EEPROM_SAVEMONITOR, Command_EnableMonitor(), Command_EnableReport(), COMMAND_MONITOR, COMMAND_MONITORSTATUS, COMMAND_READ, COMMAND_RECALLMONITOR, COMMAND_REPORT, COMMAND_RESET, Command_SetRead(), COMMAND_STOPALLMONITORS, COMMAND_STOPMONITOR, COMMAND_STOPREPORT, COMMAND_TIMECHECK_DISABLE, COMMAND_TIMECHECK_ENABLE, Command_TimecheckDisable, Command_TimecheckEnable, COMMAND_TIMECHECKSTATUS, monitor, read_eeprom_config, and write_eeprom_config.

void CAN_SendACK BYTE  cmd  ) 
 

acknowledge last recieved command via CAN Bus

The ACK message consists of the command byte to be acknowledged and an ASCII ACK

Parameters:
cmd numerical representation of last CAN command to be acknowledged

Definition at line 296 of file can.c.

References CAN_ACK, CAN_enablechannel, CAN_setchannel, CH_DISABLE, and CH_TxENA.

Referenced by CAN_interrupt().

void CAN_SendMsg BYTE  length  ) 
 

transmits a message over the CAN Bus

The message content has to be specified in can_data and the data length code has to be given.
Transmission of the message is suspended as long as there is a message transmission in progress.
During transfer of the buffer contents to the CAN controller the CAN interrupt is disabled.

Parameters:
length length of data package

Definition at line 344 of file can.c.

References can_data, CAN_enablechannel, CAN_setchannel, CH_DISABLE, and CH_TxENA.

Referenced by CAN_interrupt(), and main().

void CAN_SendNAK BYTE  cmd  ) 
 

reply when last command was accepted but could not be completed

The function works similar to CAN_SendACK but a NAK is send instead of the ACK to signal an imcomplete command or wrong data format.

Parameters:
cmd numerical representation of last CAN command for which the NAK answer is valid

Definition at line 319 of file can.c.

References CAN_enablechannel, CAN_NAK, CAN_setchannel, CH_DISABLE, and CH_TxENA.

Referenced by CAN_interrupt().


Variable Documentation

volatile BYTE idata can_data[8]
 

data buffer to construct CAN messages to be send

The buffer resides in indirect addressable IRAM space of the T89C51CC02.
The buffer is shared for both recieving and sending therefor disabling the CAN interrupt is advisable before sending.

Definition at line 19 of file can.c.

Referenced by CAN_interrupt(), CAN_SendMsg(), and main().


Generated on Wed Oct 24 12:57:24 2007 for SensorControl by  doxygen 1.4.6