?? can81c9x.h
字號:
//****************************************************************************
// @Module Standalone Full-CAN Controller SAE 81C90/91
// @Filename CAN80C9x.H
// @Project Hands on Training for the kitCON CAN/LCD Module
//----------------------------------------------------------------------------
// @Controller Siemens C16x
//
// @Compiler Tasking C166 V5.0
// Keil C166 V3.00
//
// @Author Michael Knese
//
// @Description This file contains all function prototypes and macros for CAN
//
//
//----------------------------------------------------------------------------
// @Date 11/16/98 12:45:00 PM
//
//****************************************************************************
//****************************************************************************
// @Definition of a structure for the CAN data
//****************************************************************************
// The following data type serves as a software message object. Each access to
// a hardware message object has to be made by forward a pointer to a software
// message object (TCAN_Obj). The data type has the following fields:
//
// ubMsgCfg:
// this byte has the same structure as the message configuration register of a
// hardware message object. It contains the "Data Lenght Code" (DLC),
// and the "Message Direction" (DIR, read only access).
//
// 7 6 5 4 3 2 1 0
// |-----------------------------------------------|
// | | DIR | DLC |
// |-----------------------------------------------|
//
// ulArbitr:
// this field is four bytes long and contains either the 11-bit identifier
//
// ubData[8]:
// 8 bytes containing the data of a frame
//
// uwTsr:
// this filed contained the time at wish a specific messeage was received
//
typedef struct
{
ubyte ubMsgCfg; // 8-bit Message Configuration Register
uword uwArbitr; // standard (11-bit) identifier
ubyte ubData[8]; // 8-bit Data Bytes
uword uwTsr; // Time-Stamp (only for the first 8 message objects 0-7)
}TCAN81C9x_Obj;
//****************************************************************************
// @Prototypes of global functions
//****************************************************************************
void CAN81C9x_vInit(void);
void CAN81C9x_vTransmit(ubyte ConNr, ubyte ObjNr);
// USER CODE BEGIN (CANHeader,1)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// Structure for a single CAN controller
#define CAN_OFFSET_81 0xFD00
struct can_con_81
{
ubyte BL1; //Bit-length register
ubyte BL2; //
ubyte OC; //Output-control register
ubyte BRPR; //Baud-rate prescaler
ubyte RRR1; //Receive-ready register
ubyte RRR2; //
ubyte RIMR1; //Receive-interrupt-mask register
ubyte RIMR2; //
ubyte TRSR1; //Transmit-request-set register
ubyte TRSR2; //
ubyte IMSK; //Interrupt-mask register
ubyte res0B; //
ubyte res0C; //
ubyte res0D; //
ubyte res0E; //
ubyte res0F; //
ubyte MOD; //Mode/status register
ubyte INT; //Interrupt register
ubyte CTRL; //Control register
ubyte res13; //
ubyte CC; //Clock-control register
ubyte TCD; //Transmit-check data register
ubyte res17; //
ubyte TRR1; //Transmit-request-reset register
ubyte TRR2; //
ubyte RRPR1; //Remote-request-pending register
ubyte RRPR2; //
ubyte TSCH; //Time-Stamp counter
ubyte TSCL; //
ubyte res1E; //
ubyte res1F; //
ubyte res20; //
ubyte res21; //
ubyte res22; //
ubyte res23; //
ubyte res24; //
ubyte res25; //
ubyte res26; //
ubyte res27; //
struct {
ubyte PDR; //port-direction register
ubyte PR; //pin register
ubyte LR; //latch register
ubyte resP; //
}Port[2]; //
struct {
ubyte H;
ubyte L;
}TSR[8]; //Time-Stamp Register
struct {
ubyte H;
ubyte L;
}DR[16]; //Descriptor Register
ubyte res60_7F[32];
struct {
ubyte Data[8];
}MsgObj[16]; //Data Register
};
#define CAN_CON ((struct can_con_81 volatile xdata *) (CAN_OFFSET_81))
// USER CODE BEGIN (CANHeader,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
//****************************************************************************
// @Function diverse Macros
//
//----------------------------------------------------------------------------
// @Description These macros can be used for checking the status of the
// SAE 81C90/91 (read only)
// CAN81C9x_BusState: BS = MOD.2
// 0: Normal Mode
// 1: Bus Off state, the IC does not
// participate in bus activities.
// ReceiverWarning: RWL = MOD.3
// 0: Receive-error counter below 96.
// 1: Receive-error counter >= 96.
// TransmitWarning: TWL = MOD.4
// 0: Transmit-error counter below 96.
// 1: Transmit-error counter >= 96.
// TransmissionComplete: TC = MOD.5
// 0: The last transmission request is
// not yet executed successfully.
// 1: The last transmission request was
// executed successfully.
// ReceiveState: RS = MOD.6
// 0: No reception active.
// 1: Currently the SAE 81C90/91 is in
// receive mode.
//
//----------------------------------------------------------------------------
// @Returnvalue status of the corresponding bit (see above)
//
//----------------------------------------------------------------------------
// @Parameters Number of the CAN - Controller (0-1)
//
//----------------------------------------------------------------------------
// @Date 11/2/98 4:50:26 PM
//
//****************************************************************************
#define CAN81C9x_BusState(ConNr) ( (CAN_CON[ConNr].MOD >> 2) & 0x1 )
#define CAN81C9x_ReceiverWarning(ConNr) ( (CAN_CON[ConNr].MOD >> 3) & 0x1 )
#define CAN81C9x_TransmitWarning(ConNr) ( (CAN_CON[ConNr].MOD >> 4) & 0x1 )
#define CAN81C9x_TransmissionComplete(ConNr) ( (CAN_CON[ConNr].MOD >> 5) & 0x1 )
#define CAN81C9x_ReceiveState(ConNr) ( (CAN_CON[ConNr].MOD >> 6) & 0x1 )
// USER CODE BEGIN (CANHeader,3)
// USER CODE END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -