#include "t89c51cc02.h"
#include "datatypes.h"
Go to the source code of this file.
Defines | |
#define | BRP_500k 0x00 |
#define | SJW_500k 0x00 |
#define | PRS_500k 0x00 |
#define | PHS2_500k 0x07 |
#define | PHS1_500k 0x05 |
#define | BRP_250k 0x01 |
#define | PRS_250k 0x00 |
#define | PHS1_250k 0x05 |
#define | PHS2_250k 0x07 |
#define | SJW_250k 0x00 |
#define | MSK_CANGCON_ENA 0x02 |
#define | MSK_CANGCON_GRES 0x01 |
#define | DLC_MAX 8 |
#define | CH_DISABLE 0x00 |
#define | CH_RxENA 0x80 |
#define | CH_TxENA 0x40 |
#define | MSK_CANGIE_ENRX 0x20 |
#define | MSK_CANGIE_ENTX 0x10 |
#define | CAN_ACK 0x06 |
#define | CAN_NAK 0x15 |
#define | CAN_RECVID 0x400 |
#define | CAN_SENDID 0x401 |
#define | CAN_setchannel(ch) CANPAGE = (ch << 4) |
#define | CAN_enablechannel(ch) CANEN |= (1 << ch) |
Functions | |
void | CAN_init (void) |
initialize CAN Bus to receive and send packages | |
void | CAN_interrupt (void) interrupt 7 using 1 |
ISR for handling incoming CAN Bus messages. | |
void | CAN_SendACK (BYTE) |
acknowledge last recieved command via CAN Bus | |
void | CAN_SendMsg (BYTE) |
transmits a message over the CAN Bus | |
void | CAN_SendNAK (BYTE) |
reply when last command was accepted but could not be completed | |
Variables | |
volatile BYTE idata | can_data [8] |
data buffer to construct CAN messages to be send |
Definition in file can.h.
|
ASCII code for 'Acknowledge' Definition at line 32 of file can.h. Referenced by CAN_SendACK(). |
|
macro to activate one of the CAN channels Definition at line 44 of file can.h. Referenced by CAN_SendACK(), CAN_SendMsg(), CAN_SendNAK(), and main(). |
|
ASCII code for 'Negative acknowledge' Definition at line 34 of file can.h. Referenced by CAN_SendNAK(). |
|
we listen on this CAN ID |
|
we recieve data on this ID |
|
macro to select internal CAN channel Definition at line 42 of file can.h. Referenced by CAN_init(), CAN_interrupt(), CAN_SendACK(), CAN_SendMsg(), CAN_SendNAK(), and main(). |
|
maximum length of messages |
|
initialize CAN Bus to receive and send packages
CAN packets are recieved on CAN ID 0x400 (hardcoded into can.h) Definition at line 29 of file can.c. References CAN_setchannel, CH_DISABLE, and MSK_CANGCON_GRES. Referenced by main(). |
|
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. |
|
acknowledge last recieved command via CAN Bus The ACK message consists of the command byte to be acknowledged and an ASCII ACK
Definition at line 296 of file can.c. References CAN_ACK, CAN_enablechannel, CAN_setchannel, CH_DISABLE, and CH_TxENA. Referenced by CAN_interrupt(). |
|
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.
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(). |
|
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.
Definition at line 319 of file can.c. References CAN_enablechannel, CAN_NAK, CAN_setchannel, CH_DISABLE, and CH_TxENA. Referenced by CAN_interrupt(). |
|
data buffer to construct CAN messages to be send
The buffer resides in indirect addressable IRAM space of the T89C51CC02. Definition at line 19 of file can.c. Referenced by CAN_interrupt(), CAN_SendMsg(), and main(). |