1 /******************************************************************************
3 Cl2.H - PCAN and VCAN cards hardware access library
5 (C) Copyright 1997 Unicontrols a.s.
9 FIRMA : CVUT FEL, Dept. of Measurement
10 PORTING : Adapted for LinCAN driver by Pavel Pisa, OCERA team member
16 Revision 1.1 2004/03/13 23:13:31 ppisa
17 Interconnected OCERA configuration options with LinCAN boardlist.c compilation.
20 27.1.1999 - corected value of CL2_ERROR_WARNING and CL2_ERROR_BUS_OFF constants
22 12.12.2000 - CL2_STATUS_RESET_CARD, CL2_ERROR_RESET_CARD added
23 fields of sCAN_MESSAGE aligned
25 10.8.2001 - PCI PCAN ID registers content defined
26 - cl2_find_card function prototype added
27 - cl2_get_ID function prototype added
29 10.2.2004 - Start of PCAN support porting to RT-Linux and Linux environment
31 ===============================================================================
35 ******************************************************************************/
41 /****** includes ******/
43 #ifndef __INC_ANCTYPES_H
47 /****** Definitions of constants ******/
49 /* PCI card Configuration Space Constants */
50 #define PCANDeviceID 0x0101
51 #define PCANVendorID 0xFA3C
52 #define PCANSubsystemID 0x0001
53 #define PCANSubsystemVendorID 0x7A52
56 /* Description of card and card registers location. Registers location are
57 * mapped relative to card base address (BA) */
59 #define CL2_RAM_SIZE 0x1000 /* size of dual-port RAM */
60 #define CL2_RX_BUFFER_DEFAULT 0x800 /* off(BA->rx buffer) */
61 #define CL2_SYNC_BUFFER_DEFAULT 0x400 /* off(BA->sync buffer) */
62 #define CL2_ASYNC_BUFFER_DEFAULT 0x600 /* off(BA->async buffer) */
63 #define CL2_COMMAND_REGISTER 0x3FE /* off(BA->command register )*/
64 #define CL2_VERSION_REGISTER 0x3F6 /* off(BA->version register )*/
65 #define CL2_ID_REGISTER 0x3EE /* off(BA->ID register) */
66 #define CL2_GEN_INT_REGISTER 0x3E4 /* off(BA->generate interrupt reg.)*/
67 #define CL2_CLEAR_INT_REGISTER 0x3E2 /* off(BA->clear interrupt reg)*/
68 #define CL2_RESET_REGISTER 0x3E0 /* off(BA->reset register)*/
69 #define CL2_ERROR_REGISTER 0x3F8 /* off(BA->error register)*/
70 #define CL2_TIME_REGISTER 0x3FC /* currently not used */
71 #define CL2_START_IT_REGISTER 0x3E6 /* off(BA->start inhibit time reg.) */
72 #define CL2_STATUS_REGISTER 0x3FA /* off(BA->status register)*/
73 #define CL2_VME_INT_VECTOR 0x3F0
74 #define CL2_DATA_BUFFER 0x100 /* off(BA->data buffer)*/
76 /* Default sizes of buffers (in messages)
77 * FYI: 1 message needs 16 bytes to be stored */
78 #define CL2_RX_BUFFER_SIZE 128 /* size of receive (rx) buffer */
79 #define CL2_TX_SYNC_BUFFER_SIZE 32 /* size of synchronnous buffer */
80 #define CL2_TX_ASYNC_BUFFER_SIZE 32 /* size of asynchronnous buffer*/
82 /* Command valid flag */
83 #define CL2_COMMAND_VALID 0x0080
86 #define CL2_MESSAGE_VALID 0x0001
89 #define CL2_DATA_IN_RBUF 0x0001 /* message is in rx buffer*/
90 #define CL2_X_DATA_IN_RBUF 0x0002 /* more than LIMIT messages are in
92 #define CL2_RBUF_OVERFLOW 0x0004 /* owerflow of rx buffer, some
94 #define CL2_SYNC_QUEUE_EMPTY 0x0010 /* sync queue is empty */
95 #define CL2_ASYNC_QUEUE_EMPTY 0x0020 /* async queue is empty */
96 #define CL2_CARD_ERROR 0x0040 /* card reports an error */
97 #define CL2_STATUS_VALID_FLAG 0x0080 /* bit indicating that status
98 * register contains valid data*/
99 #define CL2_CARD_READY 0x0100 /* card is ready */
100 #define CL2_SYNC_PASSIVE 0x0200 /* passive SYNC mode */
101 #define CL2_SYNC_ACTIVE 0x0400 /* active SYNC mode */
102 #define CL2_RTR_LIST 0x0800 /* RTR list sending */
103 #define CL2_STATUS_RESET_CARD 0x8000 /* card reset occurred */
106 #define CL2_ERROR_LL 0x0007 /* */
107 #define CL2_ERROR_WARNING 0x0040 /* bus warning detected */
108 #define CL2_ERROR_BUS_OFF 0x0080 /* bus error detected */
109 #define CL2_ERROR_RESET_CARD 0x0100 /* card reset occurred */
\r
110 #define CL2_ERROR_FIRMWARE 0x1000 /* firmware error detected */
111 #define CL2_ERROR_DPRAM 0x2000 /* dual port RAM error detected */
112 #define CL2_ERROR_RAM 0x4000 /* internal RAM error detected */
113 #define CL2_ERROR_CAN 0x8000 /* CAN controller error detected */
115 /* interrupt generation */
116 #define INT_MODE_RX 0x01 /* if data are in receive buffer*/
117 #define INT_MODE_ERROR 0x02 /* if any error occurs */
118 #define INT_MODE_SYNC_EMPTY 0x04 /* if tx sync. queue is empty*/
119 #define INT_MODE_ASYNC_EMPTY 0x08 /* if tx async. queue is empty*/
120 #define INT_MODE_ALL 0x0F /* if any event occurs*/
122 /* CAN message types */
123 #define CL2_REMOTE_FRAME 0x08 /* frame is a remote frame*/
124 #define CL2_LINE_FLAG 0x80
125 #define CL2_EXT_FRAME 0x04 /* frame is extended format*/
127 /* Receive message flags */
128 #define CL2_FRAME_VALID 0x01 /* message in buffer is valid */
129 #define CL2_RX_OVERFLOW 0x02 /* stored unread message was
130 * overwritten by another one */
133 #define CL2_BITRATE_5K 0x7f7f /* bit-rate 5 kb/s */
134 #define CL2_BITRATE_10K 0x5c67 /* bit-rate 10 kb/s */
135 #define CL2_BITRATE_20K 0x5c53 /* bit-rate 20 kb/s */
136 #define CL2_BITRATE_50K 0x5c47 /* bit-rate 50 kb/s */
137 #define CL2_BITRATE_100K 0x5c43 /* bit-rate 100 kb/s */
138 #define CL2_BITRATE_125K 0x6743 /* bit-rate 125 kb/s */
139 #define CL2_BITRATE_200K 0x5c41 /* bit-rate 200 kb/s */
140 #define CL2_BITRATE_250K 0x6741 /* bit-rate 250 kb/s */
141 #define CL2_BITRATE_500K 0x6740 /* bit-rate 500 kb/s */
142 #define CL2_BITRATE_800K 0x3440 /* bit-rate 800 kb/s */
143 #define CL2_BITRATE_1M 0x2340 /* bit-rate 1 Mb/s */
146 /****** Definition of structures ******/
148 typedef struct /*** card definition structure ***/
150 U16 intNumber; /* Card interrupt (IRQ) number */
151 U8 *baseAddressPtr; /* Pointer to card base address (BA) */
152 U8 *rxBufPtr; /* Pointer to receive buffer */
153 U8 *rxBufBase; /* Pointer to empty receive buffer */
154 U8 *asyncTxBufPtr; /* Pointer to async transmit buffer */
155 U8 *asyncTxBufBase; /* Pointer to empty async. transmit buffer */
156 U8 *syncTxBufPtr; /* Pointer to sync. transmit buffer */
157 U8 *syncTxBufBase; /* Pointer to empty sync. transmit buffer */
158 U8 *commandRegister; /* Pointer to command register */
159 U8 *dataPtr; /* Pointer to command data buffer */
160 U16 rxBufSize; /* size of receive buffer (x16 bytes) */
161 U16 syncTxBufSize; /* size of sync. transmit buffer (x16 bytes)*/
162 U16 asyncTxBufSize; /* size of async. transmit buffer (x 16 bytes)*/
163 U16 status; /* last card status */
164 U16 error; /* last not reported card error */
168 //typedef struct /*** CAN message formet ***/
170 // U8 data[8]; /* Data message buffer (8 bytes) */
171 // U8 dataLength; /* Data length (in bytes) */
172 // U32 COB_ID; /* COB_ID */
173 // U16 timeStamp; /* Message time stamp */
174 // U8 dataType; /* Message data type */
179 U32 COB_ID; /* COB identifier */
180 U8 dataType; /* Message data type */
181 U8 dataLength; /* Data length (in bytes) */
182 U8 data[8]; /* Data message buffer (8 bytes) */
183 U16 timeStamp; /* Message time stamp [us] */
187 typedef struct /*** Remote Request RTR frame ***/
189 U32 cob_id; /* RTR frame ID */
190 U16 period; /* RTR period */
191 U16 subperiod; /* RTR subperiod */
194 typedef struct /*** Remote Request (RTR) list ***/
196 sRTR_FRAME *data; /* RTR data */
197 U32 nb; /* Number of RTR definitions */
200 typedef enum /*** CL2 functions return codes ***/
203 CL2_NO_REQUEST, /* No request*/
204 CL2_HW_FAILURE, /* HW failure */
205 CL2_HW_QUEUE_FULL, /* Transmit queue full */
206 CL2_BAD_PARAM, /* Bad number of parameters */
207 CL2_HW_QUEUE_EMPTY, /* Receive queue empty */
208 CL2_COMMAND_BUSY, /* Command busy - previous command not completed */
209 CL2_UNKNOWN_COMMAND, /* Unknown command */
210 CL2_NO_PCI_BIOS /* missing PCI BIOS support */
213 typedef enum /*** CL2 commands ***/
215 cmCL2_INT_MODE = 0x01, /**01 - Set Interrupt mode */
216 cmCL2_IIT_MODE, /**02 - Inhibit Interrupt Time mode */
217 cmCL2_SYNC_MODE, /**03 - SYNC mode */
218 cmCL2_RTR_MODE, /**04 - RTR list mode */
219 cmCL2_BUF_SIZE, /**05 - Set buffers sizes */
220 cmCL2_SET_IIT, /**06 - Start Inhibit Interrupt Time */
221 cmCL2_START_FIRMWARE, /**07 - Start firmware */
222 cmCL2_LOAD_FIRMWARE, /* 08 - Load firmware */
223 cmCL2_SET_REC_MODE, /**09 - Set Receive mode */
225 cmCL2_CLR_RX_BUFFER = 0x10, /**10 - Clear receive buffer */
226 cmCL2_CLR_SYNC_BUFFER, /**11 - Clear synchronous buffer */
227 cmCL2_CLR_ASYNC_BUFFER, /**12 - Clear asynchronous buffer */
228 cmCL2_SEND_TIME_SYNC, /**13 - Sends time synchronization */
229 cmCL2_SET_TIME_COBID, /**14 - Sets time frames COB-ID */
230 cmCL2_SET_RECEIVE_LIMIT, /* 15 - Sets receive limit */
232 cmCL2_DOWNLOAD_RTR_LIST = 0x20, /**20 - Download RTR list */
233 cmCL2_SUBSCRIBE_RTR, /**21 - Subscribe RTR */
234 cmCL2_DESUBSCRIBE_RTR, /* 22 - Desubscribe RTR */
236 cmCL2_SET_COBID = 0x30, /**30 - Set COB-ID */
237 cmCL2_SET_SYNC_PERIOD, /**31 - Set SYNC period */
238 cmCL2_SET_SYNC_WINDOW, /**32 - Set SYNC period window */
240 cmCL2_SET_BITRATE = 0x40, /**40 - Set CAN bit rate */
241 cmCL2_BUS_RESET /* 41 - CAN controller reset */
246 /****** prototypes ******/
249 /*******************************************************************************
250 * cl2_find_card - find PCIPCAN card
253 * Searches for PCIPCAN cards in the system. The mapping (memory and interrupt)
254 * of the card is found. An index parameter specifies how many PCIPCAN cards have
255 * to be skipped in search.
258 * CL2_OK - card found and mapped under 1 MB
259 * CL2_HW_FAILURE - card not found or not mapped under 1 MB
261 eCL2_RESULT cl2_find_card
263 U16 *baseAddress, /* card's physical base address */
264 U16 *intNumber, /* card's interrupt level */
265 U16 index /* number of PCIPCAN cards to be skipped */
269 /*******************************************************************************
270 * cl2_init_card - initialize card to default parameters
273 * Command installs card. The data in sCAN_CARD structure pointed
274 * by *card are initialized to their predefined default values.
275 * Command must be called before any operation with sCAN_CARD
279 * CL2_OK - command completed succesfuly
282 eCL2_RESULT cl2_init_card
284 sCAN_CARD *card, /* Pointer to card structure */
285 void *baseAddress, /* Card base address pointer */
286 U16 intNumber /* Card interrupt number */
290 /*******************************************************************************
291 * cl2_test_card - test card
294 * Test whether the card is installed in system and working properly
295 * or not. If this function fails (return value is CL2_HW_FAILURE)
296 * check if the card is present and card base address.
299 * CL2_OK - card is present and working properly
300 * CL2_HW_FAILURE - card not found or card error
303 eCL2_RESULT cl2_test_card
305 sCAN_CARD *card /* Pointer to card structure */
309 /*******************************************************************************
310 * cl2_reset_card - reset card
313 * Card pointed by *card gets hardware reset. This command resets
314 * card processor, card settings are restored to their default
318 * CL2_OK - command completed successfuly
321 eCL2_RESULT cl2_reset_card
323 sCAN_CARD *card /* Pointer to card structure */
327 /*******************************************************************************
328 * cl2_get_version - read card version
331 * Fucntion reads a value from card version register.
334 * CL2_OK - command completed successfuly
337 eCL2_RESULT cl2_get_version
339 sCAN_CARD *card, /* Pointer to card structure */
340 U16 *version /* returns card version */
344 /*******************************************************************************
345 * cl2_get_ID - read card ID
348 * Fucntion reads a value from card ID register.
351 * CL2_OK - command completed successfuly
354 eCL2_RESULT cl2_get_ID
356 sCAN_CARD *card, /* Pointer to card structure */
358 U32 *IDhigh /* returns card version */
362 /*******************************************************************************
363 * cl2_gen_interrupt - request for interrupt
366 * CAN card is requested to generate interrupt if there is any reason
367 * to do it. The condition for interrupt generation is defined by
368 * cl2_int_mode command.
371 * CL2_OK - command completed successfuly
374 eCL2_RESULT cl2_gen_interrupt
376 sCAN_CARD *card /* Pointer to card structure */
380 /*******************************************************************************
381 * cl2_start_it - start inhibit time
384 * Command starts interrupt inhibit time. If there is any reason for
385 * interrupt geneation, the card generates interrupt after end of
386 * specified time interval. Time interval is set by cl2_set_iit command.
389 * CL2_OK - command completed successfuly
392 eCL2_RESULT cl2_start_it
394 sCAN_CARD *card /* Pointer to card structure */
398 /*******************************************************************************
399 * cl2_clear_interrupt - clear interrupt
400 * """""""""""""""""""
402 * Comand clears interrupt (IRQ) generated by a card.
405 * CL2_OK - command completed successfuly
408 eCL2_RESULT cl2_clear_interrupt
410 sCAN_CARD *card /* Pointer to card structure */
414 /*******************************************************************************
415 * cl2_int_mode - set interrupt mode
418 * Command controls, which event will generate interrupt. Constants
419 * CL2_INT_XXXX are used for setting of interrupt mode.
422 * CL2_OK - command completed successfuly
423 * CL2_BAD_PARAM - bad command parameter
424 * CL2_COMMAND_BUSY - previous command not completed
427 eCL2_RESULT cl2_int_mode
429 sCAN_CARD *card, /* Pointer to card structure */
430 U16 mode /* Interrupt mode */
434 /*******************************************************************************
435 * cl2_iit_mode - inhibit interrupt time mode
438 * Command enables/disables inhibit interupt time mode.
441 * CL2_OK - command completed successfuly
442 * CL2_COMMAND_BUSY - previous command not completed
445 eCL2_RESULT cl2_iit_mode
447 sCAN_CARD *card, /* Pointer to card structure */
448 BOOLEAN1 onoff /* IIT mode - TRUE=on, FALSE=off */
452 /*******************************************************************************
453 * cl2_sync_mode - sync mode
456 * Command enables/disables transmission of SYNC frames.
459 * CL2_OK - command completed successfuly
460 * CL2_COMMAND_BUSY - previous command not completed
463 eCL2_RESULT cl2_sync_mode
465 sCAN_CARD *card, /* Pointer to card structure */
466 BOOLEAN1 onoff /* Sync mode - TRUE=on, FALSE=off */
470 /*******************************************************************************
471 * cl2_rtr_mode - rtr mode
474 * Command enables/disables automatic transmission of RTR frames
477 * CL2_OK - command completed successfuly
478 * CL2_COMMAND_BUSY - previous command not completed
481 eCL2_RESULT cl2_rtr_mode
483 sCAN_CARD *card, /* Pointer to card structure */
484 BOOLEAN1 onoff /* RTR mode - TRUE=on, FALSE=off */
488 /*******************************************************************************
489 * cl2_buf_size - size of synchronous queue
492 * Command sets the size of synchronous send buffer. The size is
493 * in numbers of messages. Default buffer size is 32 messages.
494 * The sum of synchronous_buffer_size and asynchronous_buffer_size
495 * is constant and equal to 64. So, if the size od synchronous
496 * buffer increases, the size of asynchronous buffer decreases and
498 * NOTE: 1 message = 16 bytes
501 * CL2_OK - command completed successfully
502 * CL2_COMMAND_BUSY - previous command not completed
503 * CL2_BAD_PARAM - bad command parameter (bufSize>64)
506 eCL2_RESULT cl2_buf_size
508 sCAN_CARD *card, /* Pointer to card structure */
509 U16 bufSize /* Size of synchronous buffer */
513 /*******************************************************************************
514 * cl2_set_iit - set value of inhibit interrupt time
517 * Command sets value of inhibit interrupt time. If inhibit
518 * interrupt time mode is enabled and started, generation of
519 * interrupt (IRQ) is disabled during this time period.
520 * Inhibit interrupt time can be set from 100 us to 6.5535 s
523 * CL2_OK - command completed successfuly
524 * CL2_COMMAND_BUSY - previous command not completed
527 eCL2_RESULT cl2_set_iit
529 sCAN_CARD *card, /* Pointer to card structure */
530 U16 iit /* time period in x100 us */
534 /*******************************************************************************
535 * cl2_start_firmware - start firmware
538 * Command starts card firmware
541 * CL2_OK - command completed successfuly
542 * CL2_COMMAND_BUSY - previous command not completed
545 eCL2_RESULT cl2_start_firmware
547 sCAN_CARD *card /* Pointer to card structure */
551 /*******************************************************************************
552 * cl2_set_rec_mode - set receive mode
555 * Command sets card receive mode. This enable reception of standard
556 * or extended frames according to CAN 2.0A and 2.0B specifications.
557 * If value of mode is TRUE, card receives extended frames, if mode
558 * is FALSE, card receives standard massage format (default).
561 * CL2_OK - command completed successfuly
562 * CL2_COMMAND_BUSY - previous command not completed
565 eCL2_RESULT cl2_set_rec_mode
567 sCAN_CARD *card, /* Pointer to card structure */
568 BOOLEAN1 mode /* Mode - TRUE=ext, FALSE=std */
572 /*******************************************************************************
573 * cl2_clr_rx_buffer - clear RX buffer
576 * Command clears receive (rx) buffer. All messages stored in
577 * rx buffer will be lost.
580 * CL2_OK - command completed successfuly
581 * CL2_COMMAND_BUSY - previous command not completed
584 eCL2_RESULT cl2_clr_rx_buffer
586 sCAN_CARD *card /* Pointer to card structure */
590 /*******************************************************************************
591 * cl2_clr_sync_buffer - clear synchronous buffer
592 * """""""""""""""""""
594 * Command clears synchronous send buffer. All messages stored
595 * in synchronous buffer will be lost.
598 * CL2_OK - command completed successfuly
599 * CL2_COMMAND_BUSY - previous command not completed
602 eCL2_RESULT cl2_clr_sync_buffer
604 sCAN_CARD *card /* Pointer to card structure */
608 /*******************************************************************************
609 * cl2_clr_async_buffer - clear asynchronous buffer
610 * """"""""""""""""""""
612 * Command clears asynchronnous send buffer. All messages stored
613 * in async buffer will be lost.
616 * CL2_OK - command completed successfuly
617 * CL2_COMMAND_BUSY - previous command not completed
620 eCL2_RESULT cl2_clr_async_buffer
622 sCAN_CARD *card /* Pointer to card structure */
626 /*******************************************************************************
627 * cl2_send_time_sync - send time synchronization
630 * Command forces the card to start the High Resolution Synchronization
631 * Protocol according to the CANopen Communication profile. The SYNC
632 * mode has to be enabled (cl2_sync_mode) otherwise this command has
636 * CL2_OK - command completed successfuly
637 * CL2_COMMAND_BUSY - previous command not completed
640 eCL2_RESULT cl2_send_time_sync
642 sCAN_CARD *card /* Pointer to card structure */
646 /*******************************************************************************
647 * cl2_set_time_cobid - set time COB-ID
650 * Command sets the COB-ID for high resolution synchronization
651 * frame. The synchronization can be then made by means of
652 * cl2_send_time_sync command.
655 * CL2_OK - command completed successfuly
656 * CL2_COMMAND_BUSY - previous command not completed
659 eCL2_RESULT cl2_set_time_cobid
661 sCAN_CARD *card, /* Pointer to card structure */
662 U32 COBID /* HRS frame COB-ID */
666 /*******************************************************************************
667 * cl2_set_receive_limit - set limit for receive signaling
668 * """""""""""""""""""""
670 * Command is used to set the receive limit signalized by bit
671 * RL (in CL2.H CL2_X_DATA_IN_RBUF) of the Status Register.
672 * This bit is set when more then the limit number of frames
673 * was received since the last interrupt was generated (in interrupt
674 * mode) or since the Status Register was last time read.
678 * CL2_COMMAND_BUSY - previous command not completed
679 * CL2_BAD_PARAM - bad command parameter
681 eCL2_RESULT cl2_set_receive_limit
683 sCAN_CARD *card, /* pointer to card structure */
684 U16 limit /* limit of messages in receive buffer */
688 /*******************************************************************************
689 * cl2_download_rtr_list - download rtr list
690 * """""""""""""""""""""
692 * Command downloads a list of up to 64 RTR frames. These frames are
693 * periodically transmitted by the card. The parameters, how often
694 * frames are send and in which SYNC period is defined by period and
695 * subperiod in sRTR_FRAME structure.
698 * CL2_OK - command completed successfuly
699 * CL2_COMMAND_BUSY - previous command not completed
700 * CL2_BAD_PARAM - bad command parameter
703 eCL2_RESULT cl2_download_rtr_list
705 sCAN_CARD *card, /* Pointer to card structure */
706 sRTR_LIST *rtrList /* RTR list */
710 /*******************************************************************************
711 * cl2_subscribe_rtr - subscribe RTR frame
714 * Command subscribes RTR frame. Incoming RTR frames which were
715 * subscribed are accepted, while other are ignored. Up to 10
716 * RTR frames can be subscribed.
719 * CL2_OK - command completed successfuly
720 * CL2_COMMAND_BUSY - previous command not completed
721 * CL2_BAD_PARAM - bad command parameter
724 eCL2_RESULT cl2_subscribe_rtr
726 sCAN_CARD *card, /* Pointer to card structure */
727 sCAN_MESSAGE *canMessage, /* RTR frame */
728 U16 RTRnumber /* number of RTR */
732 /*******************************************************************************
733 * cl2_desubscribe_rtr - desubscribe rtr frame
734 * """""""""""""""""""
736 * Command desubscribes RTR frame. Card will not accept RTR frames
737 * with this identifier.
740 * CL2_OK - command completed successfuly
741 * CL2_COMMAND_BUSY - previous command not completed
742 * CL2_BAD_PARAM - bad command parameter
745 eCL2_RESULT cl2_desubscribe_rtr
747 sCAN_CARD *card, /* Pointer to card structure */
748 sCAN_MESSAGE *canMessage /* RTR frame */
752 /*******************************************************************************
753 * cl2_set_sync_cobid - set COB-ID
756 * Command sets COB-ID of SYNC frame. In active SYNC mode, the SYNC
757 * frame with this COB-ID is periodically sent with period defined
758 * by cl2_set_sync_period command.
761 * CL2_OK - command completed successfuly
762 * CL2_COMMAND_BUSY - previous command not completed
765 eCL2_RESULT cl2_set_sync_cobid
767 sCAN_CARD *card, /* Pointer to card structure */
768 U32 COBID /* COB-ID */
772 /*******************************************************************************
773 * cl2_set_sync_period - set SYNC period
774 * """""""""""""""""""
776 * Coomand sets the SYNC frame send period in active SYNC mode in
777 * x100 us. The period range is from 0 to 0xFFFF (SYNC period can
778 * be set from 100us to 6.5535s).
781 * CL2_OK - command completed successfuly
782 * CL2_COMMAND_BUSY - previous command not completed
785 eCL2_RESULT cl2_set_sync_period
787 sCAN_CARD *card, /* Pointer to card structure */
788 U16 period /* period in x100 us */
792 /*******************************************************************************
793 * cl2_set_sync_window - set SYNC window
794 * """""""""""""""""""
796 * Command sets the SYNC window length. Only during this time period
797 * after SYNC frame was send or receive the frames from the synchronous
798 * send buffer can be sent.
801 * CL2_OK - command completed successfuly
802 * CL2_COMMAND_BUSY - previous command not completed
805 eCL2_RESULT cl2_set_sync_window
807 sCAN_CARD *card, /* Pointer to card structure */
808 U16 window /* period in x100 us */
812 /*******************************************************************************
813 * cl2_set_bitrate - set CAN bit-rate
816 * Command switches the bus bit-rate. There are some predefined
817 * constants CL2_BITRATE_XXXX.
820 * CL2_OK - command completed successfuly
821 * CL2_COMMAND_BUSY - previous command not completed
824 eCL2_RESULT cl2_set_bitrate
826 sCAN_CARD *card, /* Pointer to card structure */
827 U16 bitrate /* CAN bitrate */
831 /*******************************************************************************
832 * cl2_bus_reset - resets CAN controller
835 * Command resets CAN controller
838 * CL2_OK - command completed successfuly
839 * CL2_COMMAND_BUSY - previously command not completed
842 eCL2_RESULT cl2_bus_reset
844 sCAN_CARD *card /* Pointer to card structure */
848 /*******************************************************************************
849 * cl2_send_sync - sends synchronous frame
852 * Command stores massage in synchronous send buffer.
855 * CL2_OK - command completed successfuly
856 * CL2_HW_QUEUE_FULL - synchronous send buffer is full
857 * CL2_BAD_PARAM - bad command parameter
858 * CL2_HW_FAILURE - error in HW configuration
861 eCL2_RESULT cl2_send_sync
863 sCAN_CARD *card, /* Pointer to card structure */
864 sCAN_MESSAGE *message /* message to be sent */
868 /*******************************************************************************
869 * cl2_send_async - sends asynchronous frame
872 * Command stores message in asynchronous send buffer.
875 * CL2_OK - command completed successfuly
876 * CL2_HW_QUEUE_FULL - asynchronous buffer full
877 * CL2_HW_FAILURE - error in HW configuration
878 * CL2_BAD_PARAM - bad command parameter
881 eCL2_RESULT cl2_send_async
883 sCAN_CARD *card, /* Pointer to card structure */
884 sCAN_MESSAGE *message /* message */
888 /*******************************************************************************
889 * cl2_get_status - reads card status
892 * Command reads card status register. If data in status register
893 * are valid (status valid flag is set), the value of status is read
894 * and stored in status and sCAN_CARD structure.
897 * CL2_OK - command completed successfuly
898 * CL2_NO_REQUEST - status is not valid
901 eCL2_RESULT cl2_get_status
903 sCAN_CARD *card, /* Pointer to card structure */
904 U16 *status /* Returned status */
908 /*******************************************************************************
909 * cl2_get_error - reads card error
912 * Command reads card error register. If data in error register
913 * are valid (error register valid flag is set), the value of error
914 * register is read and stored in error and sCAN_CARD structure.
917 * Cl2_OK - command completed successfuly
920 eCL2_RESULT cl2_get_error
922 sCAN_CARD *card, /* Pointer to card structure */
923 U16 *error /* Returned card error code */
927 /*******************************************************************************
928 * cl2_receive_data - reads received frame
931 * Command reads new messages received by a card.
934 * CL2_OK - command commpleted successfuly
935 * CL2_NO_REQUEST - there is no new message
938 eCL2_RESULT cl2_receive_data
940 sCAN_CARD *card, /* Pointer to card structure */
941 sCAN_MESSAGE *canMessage /* Message */
945 /* *********************************************************************** *
947 * *********************************************************************** */
949 #endif /* ifndef __INC_CL2_H */