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
17 27.1.1999 - corected value of CL2_ERROR_WARNING and CL2_ERROR_BUS_OFF constants
19 12.12.2000 - CL2_STATUS_RESET_CARD, CL2_ERROR_RESET_CARD added
20 fields of sCAN_MESSAGE aligned
22 10.8.2001 - PCI PCAN ID registers content defined
23 - cl2_find_card function prototype added
24 - cl2_get_ID function prototype added
26 10.2.2004 - Start of PCAN support porting to RT-Linux and Linux environment
28 ===============================================================================
32 ******************************************************************************/
38 /****** includes ******/
40 #ifndef __INC_ANCTYPES_H
41 #include "unican_types.h"
44 /****** Definitions of constants ******/
46 /* PCI card Configuration Space Constants */
47 #define PCANDeviceID 0x0101
48 #define PCANVendorID 0xFA3C
49 #define PCANSubsystemID 0x0001
50 #define PCANSubsystemVendorID 0x7A52
53 /* Description of card and card registers location. Registers location are
54 * mapped relative to card base address (BA) */
56 #define CL2_RAM_SIZE 0x1000 /* size of dual-port RAM */
57 #define CL2_RX_BUFFER_DEFAULT 0x800 /* off(BA->rx buffer) */
58 #define CL2_SYNC_BUFFER_DEFAULT 0x400 /* off(BA->sync buffer) */
59 #define CL2_ASYNC_BUFFER_DEFAULT 0x600 /* off(BA->async buffer) */
60 #define CL2_COMMAND_REGISTER 0x3FE /* off(BA->command register )*/
61 #define CL2_VERSION_REGISTER 0x3F6 /* off(BA->version register )*/
62 #define CL2_ID_REGISTER 0x3EE /* off(BA->ID register) */
63 #define CL2_GEN_INT_REGISTER 0x3E4 /* off(BA->generate interrupt reg.)*/
64 #define CL2_CLEAR_INT_REGISTER 0x3E2 /* off(BA->clear interrupt reg)*/
65 #define CL2_RESET_REGISTER 0x3E0 /* off(BA->reset register)*/
66 #define CL2_ERROR_REGISTER 0x3F8 /* off(BA->error register)*/
67 #define CL2_TIME_REGISTER 0x3FC /* currently not used */
68 #define CL2_START_IT_REGISTER 0x3E6 /* off(BA->start inhibit time reg.) */
69 #define CL2_STATUS_REGISTER 0x3FA /* off(BA->status register)*/
70 #define CL2_VME_INT_VECTOR 0x3F0
71 #define CL2_DATA_BUFFER 0x100 /* off(BA->data buffer)*/
73 /* Default sizes of buffers (in messages)
74 * FYI: 1 message needs 16 bytes to be stored */
75 #define CL2_RX_BUFFER_SIZE 128 /* size of receive (rx) buffer */
76 #define CL2_TX_SYNC_BUFFER_SIZE 32 /* size of synchronnous buffer */
77 #define CL2_TX_ASYNC_BUFFER_SIZE 32 /* size of asynchronnous buffer*/
79 /* Command valid flag */
80 #define CL2_COMMAND_VALID 0x0080
83 #define CL2_MESSAGE_VALID 0x0001
86 #define CL2_DATA_IN_RBUF 0x0001 /* message is in rx buffer*/
87 #define CL2_X_DATA_IN_RBUF 0x0002 /* more than LIMIT messages are in
89 #define CL2_RBUF_OVERFLOW 0x0004 /* owerflow of rx buffer, some
91 #define CL2_SYNC_QUEUE_EMPTY 0x0010 /* sync queue is empty */
92 #define CL2_ASYNC_QUEUE_EMPTY 0x0020 /* async queue is empty */
93 #define CL2_CARD_ERROR 0x0040 /* card reports an error */
94 #define CL2_STATUS_VALID_FLAG 0x0080 /* bit indicating that status
95 * register contains valid data*/
96 #define CL2_CARD_READY 0x0100 /* card is ready */
97 #define CL2_SYNC_PASSIVE 0x0200 /* passive SYNC mode */
98 #define CL2_SYNC_ACTIVE 0x0400 /* active SYNC mode */
99 #define CL2_RTR_LIST 0x0800 /* RTR list sending */
100 #define CL2_STATUS_RESET_CARD 0x8000 /* card reset occurred */
103 #define CL2_ERROR_LL 0x0007 /* */
104 #define CL2_ERROR_WARNING 0x0040 /* bus warning detected */
105 #define CL2_ERROR_BUS_OFF 0x0080 /* bus error detected */
106 #define CL2_ERROR_RESET_CARD 0x0100 /* card reset occurred */
107 #define CL2_ERROR_FIRMWARE 0x1000 /* firmware error detected */
108 #define CL2_ERROR_DPRAM 0x2000 /* dual port RAM error detected */
109 #define CL2_ERROR_RAM 0x4000 /* internal RAM error detected */
110 #define CL2_ERROR_CAN 0x8000 /* CAN controller error detected */
112 /* interrupt generation */
113 #define INT_MODE_RX 0x01 /* if data are in receive buffer*/
114 #define INT_MODE_ERROR 0x02 /* if any error occurs */
115 #define INT_MODE_SYNC_EMPTY 0x04 /* if tx sync. queue is empty*/
116 #define INT_MODE_ASYNC_EMPTY 0x08 /* if tx async. queue is empty*/
117 #define INT_MODE_ALL 0x0F /* if any event occurs*/
119 /* CAN message types */
120 #define CL2_REMOTE_FRAME 0x08 /* frame is a remote frame*/
121 #define CL2_LINE_FLAG 0x80
122 #define CL2_EXT_FRAME 0x04 /* frame is extended format*/
124 /* Receive message flags */
125 #define CL2_FRAME_VALID 0x01 /* message in buffer is valid */
126 #define CL2_RX_OVERFLOW 0x02 /* stored unread message was
127 * overwritten by another one */
130 #define CL2_BITRATE_5K 0x7f7f /* bit-rate 5 kb/s */
131 #define CL2_BITRATE_10K 0x5c67 /* bit-rate 10 kb/s */
132 #define CL2_BITRATE_20K 0x5c53 /* bit-rate 20 kb/s */
133 #define CL2_BITRATE_50K 0x5c47 /* bit-rate 50 kb/s */
134 #define CL2_BITRATE_100K 0x5c43 /* bit-rate 100 kb/s */
135 #define CL2_BITRATE_125K 0x6743 /* bit-rate 125 kb/s */
136 #define CL2_BITRATE_200K 0x5c41 /* bit-rate 200 kb/s */
137 #define CL2_BITRATE_250K 0x6741 /* bit-rate 250 kb/s */
138 #define CL2_BITRATE_500K 0x6740 /* bit-rate 500 kb/s */
139 #define CL2_BITRATE_800K 0x3440 /* bit-rate 800 kb/s */
140 #define CL2_BITRATE_1M 0x2340 /* bit-rate 1 Mb/s */
143 /****** Definition of structures ******/
145 typedef struct /*** card definition structure ***/
147 U16 intNumber; /* Card interrupt (IRQ) number */
148 U8 *baseAddressPtr; /* Pointer to card base address (BA) */
149 U8 *rxBufPtr; /* Pointer to receive buffer */
150 U8 *rxBufBase; /* Pointer to empty receive buffer */
151 U8 *asyncTxBufPtr; /* Pointer to async transmit buffer */
152 U8 *asyncTxBufBase; /* Pointer to empty async. transmit buffer */
153 U8 *syncTxBufPtr; /* Pointer to sync. transmit buffer */
154 U8 *syncTxBufBase; /* Pointer to empty sync. transmit buffer */
155 U8 *commandRegister; /* Pointer to command register */
156 U8 *dataPtr; /* Pointer to command data buffer */
157 U16 rxBufSize; /* size of receive buffer (x16 bytes) */
158 U16 syncTxBufSize; /* size of sync. transmit buffer (x16 bytes)*/
159 U16 asyncTxBufSize; /* size of async. transmit buffer (x 16 bytes)*/
160 U16 status; /* last card status */
161 U16 error; /* last not reported card error */
165 //typedef struct /*** CAN message formet ***/
167 // U8 data[8]; /* Data message buffer (8 bytes) */
168 // U8 dataLength; /* Data length (in bytes) */
169 // U32 COB_ID; /* COB_ID */
170 // U16 timeStamp; /* Message time stamp */
171 // U8 dataType; /* Message data type */
176 U32 COB_ID; /* COB identifier */
177 U8 dataType; /* Message data type */
178 U8 dataLength; /* Data length (in bytes) */
179 U8 data[8]; /* Data message buffer (8 bytes) */
180 U16 timeStamp; /* Message time stamp [us] */
184 typedef struct /*** Remote Request RTR frame ***/
186 U32 cob_id; /* RTR frame ID */
187 U16 period; /* RTR period */
188 U16 subperiod; /* RTR subperiod */
191 typedef struct /*** Remote Request (RTR) list ***/
193 sRTR_FRAME *data; /* RTR data */
194 U32 nb; /* Number of RTR definitions */
197 typedef enum /*** CL2 functions return codes ***/
200 CL2_NO_REQUEST, /* No request*/
201 CL2_HW_FAILURE, /* HW failure */
202 CL2_HW_QUEUE_FULL, /* Transmit queue full */
203 CL2_BAD_PARAM, /* Bad number of parameters */
204 CL2_HW_QUEUE_EMPTY, /* Receive queue empty */
205 CL2_COMMAND_BUSY, /* Command busy - previous command not completed */
206 CL2_UNKNOWN_COMMAND, /* Unknown command */
207 CL2_NO_PCI_BIOS /* missing PCI BIOS support */
210 typedef enum /*** CL2 commands ***/
212 cmCL2_INT_MODE = 0x01, /**01 - Set Interrupt mode */
213 cmCL2_IIT_MODE, /**02 - Inhibit Interrupt Time mode */
214 cmCL2_SYNC_MODE, /**03 - SYNC mode */
215 cmCL2_RTR_MODE, /**04 - RTR list mode */
216 cmCL2_BUF_SIZE, /**05 - Set buffers sizes */
217 cmCL2_SET_IIT, /**06 - Start Inhibit Interrupt Time */
218 cmCL2_START_FIRMWARE, /**07 - Start firmware */
219 cmCL2_LOAD_FIRMWARE, /* 08 - Load firmware */
220 cmCL2_SET_REC_MODE, /**09 - Set Receive mode */
222 cmCL2_CLR_RX_BUFFER = 0x10, /**10 - Clear receive buffer */
223 cmCL2_CLR_SYNC_BUFFER, /**11 - Clear synchronous buffer */
224 cmCL2_CLR_ASYNC_BUFFER, /**12 - Clear asynchronous buffer */
225 cmCL2_SEND_TIME_SYNC, /**13 - Sends time synchronization */
226 cmCL2_SET_TIME_COBID, /**14 - Sets time frames COB-ID */
227 cmCL2_SET_RECEIVE_LIMIT, /* 15 - Sets receive limit */
229 cmCL2_DOWNLOAD_RTR_LIST = 0x20, /**20 - Download RTR list */
230 cmCL2_SUBSCRIBE_RTR, /**21 - Subscribe RTR */
231 cmCL2_DESUBSCRIBE_RTR, /* 22 - Desubscribe RTR */
233 cmCL2_SET_COBID = 0x30, /**30 - Set COB-ID */
234 cmCL2_SET_SYNC_PERIOD, /**31 - Set SYNC period */
235 cmCL2_SET_SYNC_WINDOW, /**32 - Set SYNC period window */
237 cmCL2_SET_BITRATE = 0x40, /**40 - Set CAN bit rate */
238 cmCL2_BUS_RESET /* 41 - CAN controller reset */
243 /****** prototypes ******/
246 /*******************************************************************************
247 * cl2_find_card - find PCIPCAN card
250 * Searches for PCIPCAN cards in the system. The mapping (memory and interrupt)
251 * of the card is found. An index parameter specifies how many PCIPCAN cards have
252 * to be skipped in search.
255 * CL2_OK - card found and mapped under 1 MB
256 * CL2_HW_FAILURE - card not found or not mapped under 1 MB
258 eCL2_RESULT cl2_find_card
260 U16 *baseAddress, /* card's physical base address */
261 U16 *intNumber, /* card's interrupt level */
262 U16 index /* number of PCIPCAN cards to be skipped */
266 /*******************************************************************************
267 * cl2_init_card - initialize card to default parameters
270 * Command installs card. The data in sCAN_CARD structure pointed
271 * by *card are initialized to their predefined default values.
272 * Command must be called before any operation with sCAN_CARD
276 * CL2_OK - command completed succesfuly
279 eCL2_RESULT cl2_init_card
281 sCAN_CARD *card, /* Pointer to card structure */
282 void *baseAddress, /* Card base address pointer */
283 U16 intNumber /* Card interrupt number */
287 /*******************************************************************************
288 * cl2_test_card - test card
291 * Test whether the card is installed in system and working properly
292 * or not. If this function fails (return value is CL2_HW_FAILURE)
293 * check if the card is present and card base address.
296 * CL2_OK - card is present and working properly
297 * CL2_HW_FAILURE - card not found or card error
300 eCL2_RESULT cl2_test_card
302 sCAN_CARD *card /* Pointer to card structure */
306 /*******************************************************************************
307 * cl2_reset_card - reset card
310 * Card pointed by *card gets hardware reset. This command resets
311 * card processor, card settings are restored to their default
315 * CL2_OK - command completed successfuly
318 eCL2_RESULT cl2_reset_card
320 sCAN_CARD *card /* Pointer to card structure */
324 /*******************************************************************************
325 * cl2_get_version - read card version
328 * Fucntion reads a value from card version register.
331 * CL2_OK - command completed successfuly
334 eCL2_RESULT cl2_get_version
336 sCAN_CARD *card, /* Pointer to card structure */
337 U16 *version /* returns card version */
341 /*******************************************************************************
342 * cl2_get_ID - read card ID
345 * Fucntion reads a value from card ID register.
348 * CL2_OK - command completed successfuly
351 eCL2_RESULT cl2_get_ID
353 sCAN_CARD *card, /* Pointer to card structure */
355 U32 *IDhigh /* returns card version */
359 /*******************************************************************************
360 * cl2_gen_interrupt - request for interrupt
363 * CAN card is requested to generate interrupt if there is any reason
364 * to do it. The condition for interrupt generation is defined by
365 * cl2_int_mode command.
368 * CL2_OK - command completed successfuly
371 eCL2_RESULT cl2_gen_interrupt
373 sCAN_CARD *card /* Pointer to card structure */
377 /*******************************************************************************
378 * cl2_start_it - start inhibit time
381 * Command starts interrupt inhibit time. If there is any reason for
382 * interrupt geneation, the card generates interrupt after end of
383 * specified time interval. Time interval is set by cl2_set_iit command.
386 * CL2_OK - command completed successfuly
389 eCL2_RESULT cl2_start_it
391 sCAN_CARD *card /* Pointer to card structure */
395 /*******************************************************************************
396 * cl2_clear_interrupt - clear interrupt
397 * """""""""""""""""""
399 * Comand clears interrupt (IRQ) generated by a card.
402 * CL2_OK - command completed successfuly
405 eCL2_RESULT cl2_clear_interrupt
407 sCAN_CARD *card /* Pointer to card structure */
411 /*******************************************************************************
412 * cl2_int_mode - set interrupt mode
415 * Command controls, which event will generate interrupt. Constants
416 * CL2_INT_XXXX are used for setting of interrupt mode.
419 * CL2_OK - command completed successfuly
420 * CL2_BAD_PARAM - bad command parameter
421 * CL2_COMMAND_BUSY - previous command not completed
424 eCL2_RESULT cl2_int_mode
426 sCAN_CARD *card, /* Pointer to card structure */
427 U16 mode /* Interrupt mode */
431 /*******************************************************************************
432 * cl2_iit_mode - inhibit interrupt time mode
435 * Command enables/disables inhibit interupt time mode.
438 * CL2_OK - command completed successfuly
439 * CL2_COMMAND_BUSY - previous command not completed
442 eCL2_RESULT cl2_iit_mode
444 sCAN_CARD *card, /* Pointer to card structure */
445 BOOLEAN1 onoff /* IIT mode - TRUE=on, FALSE=off */
449 /*******************************************************************************
450 * cl2_sync_mode - sync mode
453 * Command enables/disables transmission of SYNC frames.
456 * CL2_OK - command completed successfuly
457 * CL2_COMMAND_BUSY - previous command not completed
460 eCL2_RESULT cl2_sync_mode
462 sCAN_CARD *card, /* Pointer to card structure */
463 BOOLEAN1 onoff /* Sync mode - TRUE=on, FALSE=off */
467 /*******************************************************************************
468 * cl2_rtr_mode - rtr mode
471 * Command enables/disables automatic transmission of RTR frames
474 * CL2_OK - command completed successfuly
475 * CL2_COMMAND_BUSY - previous command not completed
478 eCL2_RESULT cl2_rtr_mode
480 sCAN_CARD *card, /* Pointer to card structure */
481 BOOLEAN1 onoff /* RTR mode - TRUE=on, FALSE=off */
485 /*******************************************************************************
486 * cl2_buf_size - size of synchronous queue
489 * Command sets the size of synchronous send buffer. The size is
490 * in numbers of messages. Default buffer size is 32 messages.
491 * The sum of synchronous_buffer_size and asynchronous_buffer_size
492 * is constant and equal to 64. So, if the size od synchronous
493 * buffer increases, the size of asynchronous buffer decreases and
495 * NOTE: 1 message = 16 bytes
498 * CL2_OK - command completed successfully
499 * CL2_COMMAND_BUSY - previous command not completed
500 * CL2_BAD_PARAM - bad command parameter (bufSize>64)
503 eCL2_RESULT cl2_buf_size
505 sCAN_CARD *card, /* Pointer to card structure */
506 U16 bufSize /* Size of synchronous buffer */
510 /*******************************************************************************
511 * cl2_set_iit - set value of inhibit interrupt time
514 * Command sets value of inhibit interrupt time. If inhibit
515 * interrupt time mode is enabled and started, generation of
516 * interrupt (IRQ) is disabled during this time period.
517 * Inhibit interrupt time can be set from 100 us to 6.5535 s
520 * CL2_OK - command completed successfuly
521 * CL2_COMMAND_BUSY - previous command not completed
524 eCL2_RESULT cl2_set_iit
526 sCAN_CARD *card, /* Pointer to card structure */
527 U16 iit /* time period in x100 us */
531 /*******************************************************************************
532 * cl2_start_firmware - start firmware
535 * Command starts card firmware
538 * CL2_OK - command completed successfuly
539 * CL2_COMMAND_BUSY - previous command not completed
542 eCL2_RESULT cl2_start_firmware
544 sCAN_CARD *card /* Pointer to card structure */
548 /*******************************************************************************
549 * cl2_set_rec_mode - set receive mode
552 * Command sets card receive mode. This enable reception of standard
553 * or extended frames according to CAN 2.0A and 2.0B specifications.
554 * If value of mode is TRUE, card receives extended frames, if mode
555 * is FALSE, card receives standard massage format (default).
558 * CL2_OK - command completed successfuly
559 * CL2_COMMAND_BUSY - previous command not completed
562 eCL2_RESULT cl2_set_rec_mode
564 sCAN_CARD *card, /* Pointer to card structure */
565 BOOLEAN1 mode /* Mode - TRUE=ext, FALSE=std */
569 /*******************************************************************************
570 * cl2_clr_rx_buffer - clear RX buffer
573 * Command clears receive (rx) buffer. All messages stored in
574 * rx buffer will be lost.
577 * CL2_OK - command completed successfuly
578 * CL2_COMMAND_BUSY - previous command not completed
581 eCL2_RESULT cl2_clr_rx_buffer
583 sCAN_CARD *card /* Pointer to card structure */
587 /*******************************************************************************
588 * cl2_clr_sync_buffer - clear synchronous buffer
589 * """""""""""""""""""
591 * Command clears synchronous send buffer. All messages stored
592 * in synchronous buffer will be lost.
595 * CL2_OK - command completed successfuly
596 * CL2_COMMAND_BUSY - previous command not completed
599 eCL2_RESULT cl2_clr_sync_buffer
601 sCAN_CARD *card /* Pointer to card structure */
605 /*******************************************************************************
606 * cl2_clr_async_buffer - clear asynchronous buffer
607 * """"""""""""""""""""
609 * Command clears asynchronnous send buffer. All messages stored
610 * in async buffer will be lost.
613 * CL2_OK - command completed successfuly
614 * CL2_COMMAND_BUSY - previous command not completed
617 eCL2_RESULT cl2_clr_async_buffer
619 sCAN_CARD *card /* Pointer to card structure */
623 /*******************************************************************************
624 * cl2_send_time_sync - send time synchronization
627 * Command forces the card to start the High Resolution Synchronization
628 * Protocol according to the CANopen Communication profile. The SYNC
629 * mode has to be enabled (cl2_sync_mode) otherwise this command has
633 * CL2_OK - command completed successfuly
634 * CL2_COMMAND_BUSY - previous command not completed
637 eCL2_RESULT cl2_send_time_sync
639 sCAN_CARD *card /* Pointer to card structure */
643 /*******************************************************************************
644 * cl2_set_time_cobid - set time COB-ID
647 * Command sets the COB-ID for high resolution synchronization
648 * frame. The synchronization can be then made by means of
649 * cl2_send_time_sync command.
652 * CL2_OK - command completed successfuly
653 * CL2_COMMAND_BUSY - previous command not completed
656 eCL2_RESULT cl2_set_time_cobid
658 sCAN_CARD *card, /* Pointer to card structure */
659 U32 COBID /* HRS frame COB-ID */
663 /*******************************************************************************
664 * cl2_set_receive_limit - set limit for receive signaling
665 * """""""""""""""""""""
667 * Command is used to set the receive limit signalized by bit
668 * RL (in CL2.H CL2_X_DATA_IN_RBUF) of the Status Register.
669 * This bit is set when more then the limit number of frames
670 * was received since the last interrupt was generated (in interrupt
671 * mode) or since the Status Register was last time read.
675 * CL2_COMMAND_BUSY - previous command not completed
676 * CL2_BAD_PARAM - bad command parameter
678 eCL2_RESULT cl2_set_receive_limit
680 sCAN_CARD *card, /* pointer to card structure */
681 U16 limit /* limit of messages in receive buffer */
685 /*******************************************************************************
686 * cl2_download_rtr_list - download rtr list
687 * """""""""""""""""""""
689 * Command downloads a list of up to 64 RTR frames. These frames are
690 * periodically transmitted by the card. The parameters, how often
691 * frames are send and in which SYNC period is defined by period and
692 * subperiod in sRTR_FRAME structure.
695 * CL2_OK - command completed successfuly
696 * CL2_COMMAND_BUSY - previous command not completed
697 * CL2_BAD_PARAM - bad command parameter
700 eCL2_RESULT cl2_download_rtr_list
702 sCAN_CARD *card, /* Pointer to card structure */
703 sRTR_LIST *rtrList /* RTR list */
707 /*******************************************************************************
708 * cl2_subscribe_rtr - subscribe RTR frame
711 * Command subscribes RTR frame. Incoming RTR frames which were
712 * subscribed are accepted, while other are ignored. Up to 10
713 * RTR frames can be subscribed.
716 * CL2_OK - command completed successfuly
717 * CL2_COMMAND_BUSY - previous command not completed
718 * CL2_BAD_PARAM - bad command parameter
721 eCL2_RESULT cl2_subscribe_rtr
723 sCAN_CARD *card, /* Pointer to card structure */
724 sCAN_MESSAGE *canMessage, /* RTR frame */
725 U16 RTRnumber /* number of RTR */
729 /*******************************************************************************
730 * cl2_desubscribe_rtr - desubscribe rtr frame
731 * """""""""""""""""""
733 * Command desubscribes RTR frame. Card will not accept RTR frames
734 * with this identifier.
737 * CL2_OK - command completed successfuly
738 * CL2_COMMAND_BUSY - previous command not completed
739 * CL2_BAD_PARAM - bad command parameter
742 eCL2_RESULT cl2_desubscribe_rtr
744 sCAN_CARD *card, /* Pointer to card structure */
745 sCAN_MESSAGE *canMessage /* RTR frame */
749 /*******************************************************************************
750 * cl2_set_sync_cobid - set COB-ID
753 * Command sets COB-ID of SYNC frame. In active SYNC mode, the SYNC
754 * frame with this COB-ID is periodically sent with period defined
755 * by cl2_set_sync_period command.
758 * CL2_OK - command completed successfuly
759 * CL2_COMMAND_BUSY - previous command not completed
762 eCL2_RESULT cl2_set_sync_cobid
764 sCAN_CARD *card, /* Pointer to card structure */
765 U32 COBID /* COB-ID */
769 /*******************************************************************************
770 * cl2_set_sync_period - set SYNC period
771 * """""""""""""""""""
773 * Coomand sets the SYNC frame send period in active SYNC mode in
774 * x100 us. The period range is from 0 to 0xFFFF (SYNC period can
775 * be set from 100us to 6.5535s).
778 * CL2_OK - command completed successfuly
779 * CL2_COMMAND_BUSY - previous command not completed
782 eCL2_RESULT cl2_set_sync_period
784 sCAN_CARD *card, /* Pointer to card structure */
785 U16 period /* period in x100 us */
789 /*******************************************************************************
790 * cl2_set_sync_window - set SYNC window
791 * """""""""""""""""""
793 * Command sets the SYNC window length. Only during this time period
794 * after SYNC frame was send or receive the frames from the synchronous
795 * send buffer can be sent.
798 * CL2_OK - command completed successfuly
799 * CL2_COMMAND_BUSY - previous command not completed
802 eCL2_RESULT cl2_set_sync_window
804 sCAN_CARD *card, /* Pointer to card structure */
805 U16 window /* period in x100 us */
809 /*******************************************************************************
810 * cl2_set_bitrate - set CAN bit-rate
813 * Command switches the bus bit-rate. There are some predefined
814 * constants CL2_BITRATE_XXXX.
817 * CL2_OK - command completed successfuly
818 * CL2_COMMAND_BUSY - previous command not completed
821 eCL2_RESULT cl2_set_bitrate
823 sCAN_CARD *card, /* Pointer to card structure */
824 U16 bitrate /* CAN bitrate */
828 /*******************************************************************************
829 * cl2_bus_reset - resets CAN controller
832 * Command resets CAN controller
835 * CL2_OK - command completed successfuly
836 * CL2_COMMAND_BUSY - previously command not completed
839 eCL2_RESULT cl2_bus_reset
841 sCAN_CARD *card /* Pointer to card structure */
845 /*******************************************************************************
846 * cl2_send_sync - sends synchronous frame
849 * Command stores massage in synchronous send buffer.
852 * CL2_OK - command completed successfuly
853 * CL2_HW_QUEUE_FULL - synchronous send buffer is full
854 * CL2_BAD_PARAM - bad command parameter
855 * CL2_HW_FAILURE - error in HW configuration
858 eCL2_RESULT cl2_send_sync
860 sCAN_CARD *card, /* Pointer to card structure */
861 sCAN_MESSAGE *message /* message to be sent */
865 /*******************************************************************************
866 * cl2_send_async - sends asynchronous frame
869 * Command stores message in asynchronous send buffer.
872 * CL2_OK - command completed successfuly
873 * CL2_HW_QUEUE_FULL - asynchronous buffer full
874 * CL2_HW_FAILURE - error in HW configuration
875 * CL2_BAD_PARAM - bad command parameter
878 eCL2_RESULT cl2_send_async
880 sCAN_CARD *card, /* Pointer to card structure */
881 sCAN_MESSAGE *message /* message */
885 /*******************************************************************************
886 * cl2_get_status - reads card status
889 * Command reads card status register. If data in status register
890 * are valid (status valid flag is set), the value of status is read
891 * and stored in status and sCAN_CARD structure.
894 * CL2_OK - command completed successfuly
895 * CL2_NO_REQUEST - status is not valid
898 eCL2_RESULT cl2_get_status
900 sCAN_CARD *card, /* Pointer to card structure */
901 U16 *status /* Returned status */
905 /*******************************************************************************
906 * cl2_get_error - reads card error
909 * Command reads card error register. If data in error register
910 * are valid (error register valid flag is set), the value of error
911 * register is read and stored in error and sCAN_CARD structure.
914 * Cl2_OK - command completed successfuly
917 eCL2_RESULT cl2_get_error
919 sCAN_CARD *card, /* Pointer to card structure */
920 U16 *error /* Returned card error code */
924 /*******************************************************************************
925 * cl2_receive_data - reads received frame
928 * Command reads new messages received by a card.
931 * CL2_OK - command commpleted successfuly
932 * CL2_NO_REQUEST - there is no new message
935 eCL2_RESULT cl2_receive_data
937 sCAN_CARD *card, /* Pointer to card structure */
938 sCAN_MESSAGE *canMessage /* Message */
942 /* *********************************************************************** *
944 * *********************************************************************** */
946 #endif /* ifndef __INC_CL2_H */