Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

interfaces.h

Go to the documentation of this file.
00001 /*============================================================================*
00002  * FILE:                      interfaces.h
00003  *============================================================================*
00004  *
00005  *                      COPYRIGHT (C) 2006  BY
00006  *          CONDOR ENGINEERING, INC., SANTA BARBARA, CALIFORNIA
00007  *          ALL RIGHTS RESERVED.
00008  *
00009  *          THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND
00010  *          COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH
00011  *          THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY
00012  *          OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
00013  *          AVAILABLE TO ANY OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE
00014  *          SOFTWARE IS HEREBY TRANSFERRED.
00015  *
00016  *          THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
00017  *          NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY CONDOR
00018  *          ENGINEERING.
00019  *
00020  *============================================================================*
00021  *
00022  * FUNCTION:    Function Descriptions that every CAN interface should have
00023  *
00024  * Author:      Christopher McKenzie
00025  * 
00026  * MAINTENANCE NOTES:
00027  * 
00028  *============================================================================*/
00029 #ifndef _CACEINTERFACES_H_
00030 #define _CACEINTERFACES_H_
00031 #include"../includes/defines.h"
00032 #include"../includes/canapi.h"
00033 //
00034 // Define what you have
00035 //
00036 #define CANBOARDXL      0
00037 //#define CARDONE       1
00038 //#define CARDTWO       2
00039 
00040 #define IF_SUCCESS      0
00041 #define IF_FAILURE      1
00042 
00043 #define IF_DEFAULT_RXQUEUE      256
00044 #define IF_DEFAULT_BAUD         500000
00045 
00046 struct _if_board
00047 {       unsigned short  boardtype;      //CANBOARDXL, BOARDONE, etc...
00048         unsigned int
00049                 hwType,
00050                 channelcount,
00051                 
00052                 index;  //index in the data structure
00053 
00054         unsigned short  //Although 11898-3 says that errors max at 256, who knows...
00055                 txErrorCounter,
00056                 rxErrorCounter,
00057                 status;         //Active/passive/off
00058 
00059         struct _if_channel*channel[32];
00060 };
00061 
00062 struct _if_channel
00063 {       struct _if_board*board; //The associated physical board
00064         
00065         unsigned char   
00066                 name[CAN_MAXBUFFER],
00067                 transceiverName[CAN_MAXBUFFER];
00068                 
00069         int isopen,
00070                 txerror,
00071                 rxerror,
00072                 baudrate,
00073                 rxqueuesize,
00074                 index;  //channel number in data structure
00075         
00076         struct can20bframe*previous[MAX_STACK];
00077 
00078         unsigned long
00079                 hwType,
00080                 hwIndex,        //channel number on board
00081                 hwChannel,
00082                 hwHandle,       //to talk to the vendor
00083                 
00084                 hwTransType,
00085                 hwTransState,
00086                 
00087                 hwChannelIndex,
00088                 
00089                 capabilities,
00090                 buscapabilities,
00091                 bustype,
00092 
00093                 serialNumber,
00094                 articleNumber,
00095 
00096                 rxqueue,
00097                 txqueue;
00098 
00099         void*blockinghandle;    //if blocking is not provided
00100         int blocktimeout;       //block a read/write (default: true)
00101 
00102         unsigned int    flags;  //vendor specific stuff
00103 
00104         struct
00105         {       int     last;
00106                 long    time;
00107                 //other metadata
00108         }error;
00109 
00110         as_ts lastsync;
00111 
00112         struct
00113         {       unsigned long
00114                         code,
00115                         mask;
00116                 char type;      //CAN 2.0 a or b
00117         }filter;
00118 };
00119 
00120 enum
00121 {       d_canboardxl,
00122         d_cardone,
00123         d_cardtwo
00124 };
00125 
00126 struct _s_interface
00127 {       int activecount;
00128         int     (*probefunction)();
00129         int     (*startupfunction)();
00130         int (*openchannelfunction)(int);
00131         int (*closechannelfunction)(int);
00132         int     (*shutdownfunction)();
00133         int     (*readfunction)(int,can_frame*);
00134         int (*writefunction)(int,can_frame*);
00135         int (*updatestatusfunction)(int);
00136         int (*changestatusfunction)(int,int,int);
00137 };
00138 
00139 int boardprobe();
00140 int boardopenchannel(int);
00141 int boardclosechannel(int);
00142 int boardread(int,can_frame*);
00143 int boardwrite(int,can_frame*);
00144 int boardupdatestatus(int which);
00145 int boardchangestatus(int,int,int);
00146 int boardshutdown(int);
00147 
00148 void boarddllmain();
00149 
00150 int fakecrc(unsigned char*,int*);
00151 #endif

Generated on Wed Feb 22 13:31:25 2006 for CANapi by  doxygen 1.4.4