1 /**************************************************************************/
2 /* File: unican_cl2.h - Unicontrols PCAN,PCAN-PCI, VCAN core support */
4 /* LinCAN - (Not only) Linux CAN bus driver */
5 /* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz> */
6 /* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz> */
7 /* Copyright (C) 1997 F. Spurny, CVUT FEL, Dept. of Measurement */
8 /* Copyright (C) 1997 Unicontrols a.s. */
9 /* Funded by OCERA and FRESCOR IST projects */
10 /* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl> */
12 /* LinCAN is free software; you can redistribute it and/or modify it */
13 /* under terms of the GNU General Public License as published by the */
14 /* Free Software Foundation; either version 2, or (at your option) any */
15 /* later version. LinCAN is distributed in the hope that it will be */
16 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
17 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
18 /* General Public License for more details. You should have received a */
19 /* copy of the GNU General Public License along with LinCAN; see file */
20 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
21 /* Cambridge, MA 02139, USA. */
23 /* To allow use of LinCAN in the compact embedded systems firmware */
24 /* and RT-executives (RTEMS for example), main authors agree with next */
25 /* special exception: */
27 /* Including LinCAN header files in a file, instantiating LinCAN generics */
28 /* or templates, or linking other files with LinCAN objects to produce */
29 /* an application image/executable, does not by itself cause the */
30 /* resulting application image/executable to be covered by */
31 /* the GNU General Public License. */
32 /* This exception does not however invalidate any other reasons */
33 /* why the executable file might be covered by the GNU Public License. */
34 /* Publication of enhanced or derived LinCAN files is required although. */
35 /**************************************************************************/
42 /****** includes ******/
44 #ifndef __INC_ANCTYPES_H
45 #include "unican_types.h"
48 /****** Definitions of constants ******/
50 /* PCI card Configuration Space Constants */
51 #define PCANDeviceID 0x0101
52 #define PCANVendorID 0xFA3C
53 #define PCANSubsystemID 0x0001
54 #define PCANSubsystemVendorID 0x7A52
57 /* Description of card and card registers location. Registers location are
58 * mapped relative to card base address (BA) */
60 #define CL2_RAM_SIZE 0x1000 /* size of dual-port RAM */
61 #define CL2_RX_BUFFER_DEFAULT 0x800 /* off(BA->rx buffer) */
62 #define CL2_SYNC_BUFFER_DEFAULT 0x400 /* off(BA->sync buffer) */
63 #define CL2_ASYNC_BUFFER_DEFAULT 0x600 /* off(BA->async buffer) */
64 #define CL2_COMMAND_REGISTER 0x3FE /* off(BA->command register )*/
65 #define CL2_VERSION_REGISTER 0x3F6 /* off(BA->version register )*/
66 #define CL2_ID_REGISTER 0x3EE /* off(BA->ID register) */
67 #define CL2_GEN_INT_REGISTER 0x3E4 /* off(BA->generate interrupt reg.)*/
68 #define CL2_CLEAR_INT_REGISTER 0x3E2 /* off(BA->clear interrupt reg)*/
69 #define CL2_RESET_REGISTER 0x3E0 /* off(BA->reset register)*/
70 #define CL2_ERROR_REGISTER 0x3F8 /* off(BA->error register)*/
71 #define CL2_TIME_REGISTER 0x3FC /* currently not used */
72 #define CL2_START_IT_REGISTER 0x3E6 /* off(BA->start inhibit time reg.) */
73 #define CL2_STATUS_REGISTER 0x3FA /* off(BA->status register)*/
74 #define CL2_VME_INT_VECTOR 0x3F0
75 #define CL2_DATA_BUFFER 0x100 /* off(BA->data buffer)*/
77 /* Default sizes of buffers (in messages)
78 * FYI: 1 message needs 16 bytes to be stored */
79 #define CL2_RX_BUFFER_SIZE 128 /* size of receive (rx) buffer */
80 #define CL2_TX_SYNC_BUFFER_SIZE 32 /* size of synchronnous buffer */
81 #define CL2_TX_ASYNC_BUFFER_SIZE 32 /* size of asynchronnous buffer*/
83 /* Command valid flag */
84 #define CL2_COMMAND_VALID 0x0080
87 #define CL2_MESSAGE_VALID 0x0001
90 #define CL2_DATA_IN_RBUF 0x0001 /* message is in rx buffer*/
91 #define CL2_X_DATA_IN_RBUF 0x0002 /* more than LIMIT messages are in
93 #define CL2_RBUF_OVERFLOW 0x0004 /* owerflow of rx buffer, some
95 #define CL2_SYNC_QUEUE_EMPTY 0x0010 /* sync queue is empty */
96 #define CL2_ASYNC_QUEUE_EMPTY 0x0020 /* async queue is empty */
97 #define CL2_CARD_ERROR 0x0040 /* card reports an error */
98 #define CL2_STATUS_VALID_FLAG 0x0080 /* bit indicating that status
99 * register contains valid data*/
100 #define CL2_CARD_READY 0x0100 /* card is ready */
101 #define CL2_SYNC_PASSIVE 0x0200 /* passive SYNC mode */
102 #define CL2_SYNC_ACTIVE 0x0400 /* active SYNC mode */
103 #define CL2_RTR_LIST 0x0800 /* RTR list sending */
104 #define CL2_STATUS_RESET_CARD 0x8000 /* card reset occurred */
107 #define CL2_ERROR_LL 0x0007 /* */
108 #define CL2_ERROR_WARNING 0x0040 /* bus warning detected */
109 #define CL2_ERROR_BUS_OFF 0x0080 /* bus error detected */
110 #define CL2_ERROR_RESET_CARD 0x0100 /* card reset occurred */
111 #define CL2_ERROR_FIRMWARE 0x1000 /* firmware error detected */
112 #define CL2_ERROR_DPRAM 0x2000 /* dual port RAM error detected */
113 #define CL2_ERROR_RAM 0x4000 /* internal RAM error detected */
114 #define CL2_ERROR_CAN 0x8000 /* CAN controller error detected */
116 /* interrupt generation */
117 #define INT_MODE_RX 0x01 /* if data are in receive buffer*/
118 #define INT_MODE_ERROR 0x02 /* if any error occurs */
119 #define INT_MODE_SYNC_EMPTY 0x04 /* if tx sync. queue is empty*/
120 #define INT_MODE_ASYNC_EMPTY 0x08 /* if tx async. queue is empty*/
121 #define INT_MODE_ALL 0x0F /* if any event occurs*/
123 /* CAN message types */
124 #define CL2_REMOTE_FRAME 0x08 /* frame is a remote frame*/
125 #define CL2_LINE_FLAG 0x80
126 #define CL2_EXT_FRAME 0x04 /* frame is extended format*/
128 /* Receive message flags */
129 #define CL2_FRAME_VALID 0x01 /* message in buffer is valid */
130 #define CL2_RX_OVERFLOW 0x02 /* stored unread message was
131 * overwritten by another one */
134 #define CL2_BITRATE_5K 0x7f7f /* bit-rate 5 kb/s */
135 #define CL2_BITRATE_10K 0x5c67 /* bit-rate 10 kb/s */
136 #define CL2_BITRATE_20K 0x5c53 /* bit-rate 20 kb/s */
137 #define CL2_BITRATE_50K 0x5c47 /* bit-rate 50 kb/s */
138 #define CL2_BITRATE_100K 0x5c43 /* bit-rate 100 kb/s */
139 #define CL2_BITRATE_125K 0x6743 /* bit-rate 125 kb/s */
140 #define CL2_BITRATE_200K 0x5c41 /* bit-rate 200 kb/s */
141 #define CL2_BITRATE_250K 0x6741 /* bit-rate 250 kb/s */
142 #define CL2_BITRATE_500K 0x6740 /* bit-rate 500 kb/s */
143 #define CL2_BITRATE_800K 0x3440 /* bit-rate 800 kb/s */
144 #define CL2_BITRATE_1M 0x2340 /* bit-rate 1 Mb/s */
147 /****** Definition of structures ******/
149 typedef struct /*** card definition structure ***/
151 U16 intNumber; /* Card interrupt (IRQ) number */
152 U8 *baseAddressPtr; /* Pointer to card base address (BA) */
153 U8 *rxBufPtr; /* Pointer to receive buffer */
154 U8 *rxBufBase; /* Pointer to empty receive buffer */
155 U8 *asyncTxBufPtr; /* Pointer to async transmit buffer */
156 U8 *asyncTxBufBase; /* Pointer to empty async. transmit buffer */
157 U8 *syncTxBufPtr; /* Pointer to sync. transmit buffer */
158 U8 *syncTxBufBase; /* Pointer to empty sync. transmit buffer */
159 U8 *commandRegister; /* Pointer to command register */
160 U8 *dataPtr; /* Pointer to command data buffer */
161 U16 rxBufSize; /* size of receive buffer (x16 bytes) */
162 U16 syncTxBufSize; /* size of sync. transmit buffer (x16 bytes)*/
163 U16 asyncTxBufSize; /* size of async. transmit buffer (x 16 bytes)*/
164 U16 status; /* last card status */
165 U16 error; /* last not reported card error */
169 //typedef struct /*** CAN message formet ***/
171 // U8 data[8]; /* Data message buffer (8 bytes) */
172 // U8 dataLength; /* Data length (in bytes) */
173 // U32 COB_ID; /* COB_ID */
174 // U16 timeStamp; /* Message time stamp */
175 // U8 dataType; /* Message data type */
180 U32 COB_ID; /* COB identifier */
181 U8 dataType; /* Message data type */
182 U8 dataLength; /* Data length (in bytes) */
183 U8 data[8]; /* Data message buffer (8 bytes) */
184 U16 timeStamp; /* Message time stamp [us] */
188 typedef struct /*** Remote Request RTR frame ***/
190 U32 cob_id; /* RTR frame ID */
191 U16 period; /* RTR period */
192 U16 subperiod; /* RTR subperiod */
195 typedef struct /*** Remote Request (RTR) list ***/
197 sRTR_FRAME *data; /* RTR data */
198 U32 nb; /* Number of RTR definitions */
201 typedef enum /*** CL2 functions return codes ***/
204 CL2_NO_REQUEST, /* No request*/
205 CL2_HW_FAILURE, /* HW failure */
206 CL2_HW_QUEUE_FULL, /* Transmit queue full */
207 CL2_BAD_PARAM, /* Bad number of parameters */
208 CL2_HW_QUEUE_EMPTY, /* Receive queue empty */
209 CL2_COMMAND_BUSY, /* Command busy - previous command not completed */
210 CL2_UNKNOWN_COMMAND, /* Unknown command */
211 CL2_NO_PCI_BIOS /* missing PCI BIOS support */
214 typedef enum /*** CL2 commands ***/
216 cmCL2_INT_MODE = 0x01, /**01 - Set Interrupt mode */
217 cmCL2_IIT_MODE, /**02 - Inhibit Interrupt Time mode */
218 cmCL2_SYNC_MODE, /**03 - SYNC mode */
219 cmCL2_RTR_MODE, /**04 - RTR list mode */
220 cmCL2_BUF_SIZE, /**05 - Set buffers sizes */
221 cmCL2_SET_IIT, /**06 - Start Inhibit Interrupt Time */
222 cmCL2_START_FIRMWARE, /**07 - Start firmware */
223 cmCL2_LOAD_FIRMWARE, /* 08 - Load firmware */
224 cmCL2_SET_REC_MODE, /**09 - Set Receive mode */
226 cmCL2_CLR_RX_BUFFER = 0x10, /**10 - Clear receive buffer */
227 cmCL2_CLR_SYNC_BUFFER, /**11 - Clear synchronous buffer */
228 cmCL2_CLR_ASYNC_BUFFER, /**12 - Clear asynchronous buffer */
229 cmCL2_SEND_TIME_SYNC, /**13 - Sends time synchronization */
230 cmCL2_SET_TIME_COBID, /**14 - Sets time frames COB-ID */
231 cmCL2_SET_RECEIVE_LIMIT, /* 15 - Sets receive limit */
233 cmCL2_DOWNLOAD_RTR_LIST = 0x20, /**20 - Download RTR list */
234 cmCL2_SUBSCRIBE_RTR, /**21 - Subscribe RTR */
235 cmCL2_DESUBSCRIBE_RTR, /* 22 - Desubscribe RTR */
237 cmCL2_SET_COBID = 0x30, /**30 - Set COB-ID */
238 cmCL2_SET_SYNC_PERIOD, /**31 - Set SYNC period */
239 cmCL2_SET_SYNC_WINDOW, /**32 - Set SYNC period window */
241 cmCL2_SET_BITRATE = 0x40, /**40 - Set CAN bit rate */
242 cmCL2_BUS_RESET /* 41 - CAN controller reset */
247 /****** prototypes ******/
250 /*******************************************************************************
251 * cl2_find_card - find PCIPCAN card
254 * Searches for PCIPCAN cards in the system. The mapping (memory and interrupt)
255 * of the card is found. An index parameter specifies how many PCIPCAN cards have
256 * to be skipped in search.
259 * CL2_OK - card found and mapped under 1 MB
260 * CL2_HW_FAILURE - card not found or not mapped under 1 MB
262 eCL2_RESULT cl2_find_card
264 U16 *baseAddress, /* card's physical base address */
265 U16 *intNumber, /* card's interrupt level */
266 U16 index /* number of PCIPCAN cards to be skipped */
270 /*******************************************************************************
271 * cl2_init_card - initialize card to default parameters
274 * Command installs card. The data in sCAN_CARD structure pointed
275 * by *card are initialized to their predefined default values.
276 * Command must be called before any operation with sCAN_CARD
280 * CL2_OK - command completed succesfuly
283 eCL2_RESULT cl2_init_card
285 sCAN_CARD *card, /* Pointer to card structure */
286 void *baseAddress, /* Card base address pointer */
287 U16 intNumber /* Card interrupt number */
291 /*******************************************************************************
292 * cl2_test_card - test card
295 * Test whether the card is installed in system and working properly
296 * or not. If this function fails (return value is CL2_HW_FAILURE)
297 * check if the card is present and card base address.
300 * CL2_OK - card is present and working properly
301 * CL2_HW_FAILURE - card not found or card error
304 eCL2_RESULT cl2_test_card
306 sCAN_CARD *card /* Pointer to card structure */
310 /*******************************************************************************
311 * cl2_reset_card - reset card
314 * Card pointed by *card gets hardware reset. This command resets
315 * card processor, card settings are restored to their default
319 * CL2_OK - command completed successfuly
322 eCL2_RESULT cl2_reset_card
324 sCAN_CARD *card /* Pointer to card structure */
328 /*******************************************************************************
329 * cl2_get_version - read card version
332 * Fucntion reads a value from card version register.
335 * CL2_OK - command completed successfuly
338 eCL2_RESULT cl2_get_version
340 sCAN_CARD *card, /* Pointer to card structure */
341 U16 *version /* returns card version */
345 /*******************************************************************************
346 * cl2_get_ID - read card ID
349 * Fucntion reads a value from card ID register.
352 * CL2_OK - command completed successfuly
355 eCL2_RESULT cl2_get_ID
357 sCAN_CARD *card, /* Pointer to card structure */
359 U32 *IDhigh /* returns card version */
363 /*******************************************************************************
364 * cl2_gen_interrupt - request for interrupt
367 * CAN card is requested to generate interrupt if there is any reason
368 * to do it. The condition for interrupt generation is defined by
369 * cl2_int_mode command.
372 * CL2_OK - command completed successfuly
375 eCL2_RESULT cl2_gen_interrupt
377 sCAN_CARD *card /* Pointer to card structure */
381 /*******************************************************************************
382 * cl2_start_it - start inhibit time
385 * Command starts interrupt inhibit time. If there is any reason for
386 * interrupt geneation, the card generates interrupt after end of
387 * specified time interval. Time interval is set by cl2_set_iit command.
390 * CL2_OK - command completed successfuly
393 eCL2_RESULT cl2_start_it
395 sCAN_CARD *card /* Pointer to card structure */
399 /*******************************************************************************
400 * cl2_clear_interrupt - clear interrupt
401 * """""""""""""""""""
403 * Comand clears interrupt (IRQ) generated by a card.
406 * CL2_OK - command completed successfuly
409 eCL2_RESULT cl2_clear_interrupt
411 sCAN_CARD *card /* Pointer to card structure */
415 /*******************************************************************************
416 * cl2_int_mode - set interrupt mode
419 * Command controls, which event will generate interrupt. Constants
420 * CL2_INT_XXXX are used for setting of interrupt mode.
423 * CL2_OK - command completed successfuly
424 * CL2_BAD_PARAM - bad command parameter
425 * CL2_COMMAND_BUSY - previous command not completed
428 eCL2_RESULT cl2_int_mode
430 sCAN_CARD *card, /* Pointer to card structure */
431 U16 mode /* Interrupt mode */
435 /*******************************************************************************
436 * cl2_iit_mode - inhibit interrupt time mode
439 * Command enables/disables inhibit interupt time mode.
442 * CL2_OK - command completed successfuly
443 * CL2_COMMAND_BUSY - previous command not completed
446 eCL2_RESULT cl2_iit_mode
448 sCAN_CARD *card, /* Pointer to card structure */
449 BOOLEAN1 onoff /* IIT mode - TRUE=on, FALSE=off */
453 /*******************************************************************************
454 * cl2_sync_mode - sync mode
457 * Command enables/disables transmission of SYNC frames.
460 * CL2_OK - command completed successfuly
461 * CL2_COMMAND_BUSY - previous command not completed
464 eCL2_RESULT cl2_sync_mode
466 sCAN_CARD *card, /* Pointer to card structure */
467 BOOLEAN1 onoff /* Sync mode - TRUE=on, FALSE=off */
471 /*******************************************************************************
472 * cl2_rtr_mode - rtr mode
475 * Command enables/disables automatic transmission of RTR frames
478 * CL2_OK - command completed successfuly
479 * CL2_COMMAND_BUSY - previous command not completed
482 eCL2_RESULT cl2_rtr_mode
484 sCAN_CARD *card, /* Pointer to card structure */
485 BOOLEAN1 onoff /* RTR mode - TRUE=on, FALSE=off */
489 /*******************************************************************************
490 * cl2_buf_size - size of synchronous queue
493 * Command sets the size of synchronous send buffer. The size is
494 * in numbers of messages. Default buffer size is 32 messages.
495 * The sum of synchronous_buffer_size and asynchronous_buffer_size
496 * is constant and equal to 64. So, if the size od synchronous
497 * buffer increases, the size of asynchronous buffer decreases and
499 * NOTE: 1 message = 16 bytes
502 * CL2_OK - command completed successfully
503 * CL2_COMMAND_BUSY - previous command not completed
504 * CL2_BAD_PARAM - bad command parameter (bufSize>64)
507 eCL2_RESULT cl2_buf_size
509 sCAN_CARD *card, /* Pointer to card structure */
510 U16 bufSize /* Size of synchronous buffer */
514 /*******************************************************************************
515 * cl2_set_iit - set value of inhibit interrupt time
518 * Command sets value of inhibit interrupt time. If inhibit
519 * interrupt time mode is enabled and started, generation of
520 * interrupt (IRQ) is disabled during this time period.
521 * Inhibit interrupt time can be set from 100 us to 6.5535 s
524 * CL2_OK - command completed successfuly
525 * CL2_COMMAND_BUSY - previous command not completed
528 eCL2_RESULT cl2_set_iit
530 sCAN_CARD *card, /* Pointer to card structure */
531 U16 iit /* time period in x100 us */
535 /*******************************************************************************
536 * cl2_start_firmware - start firmware
539 * Command starts card firmware
542 * CL2_OK - command completed successfuly
543 * CL2_COMMAND_BUSY - previous command not completed
546 eCL2_RESULT cl2_start_firmware
548 sCAN_CARD *card /* Pointer to card structure */
552 /*******************************************************************************
553 * cl2_set_rec_mode - set receive mode
556 * Command sets card receive mode. This enable reception of standard
557 * or extended frames according to CAN 2.0A and 2.0B specifications.
558 * If value of mode is TRUE, card receives extended frames, if mode
559 * is FALSE, card receives standard massage format (default).
562 * CL2_OK - command completed successfuly
563 * CL2_COMMAND_BUSY - previous command not completed
566 eCL2_RESULT cl2_set_rec_mode
568 sCAN_CARD *card, /* Pointer to card structure */
569 BOOLEAN1 mode /* Mode - TRUE=ext, FALSE=std */
573 /*******************************************************************************
574 * cl2_clr_rx_buffer - clear RX buffer
577 * Command clears receive (rx) buffer. All messages stored in
578 * rx buffer will be lost.
581 * CL2_OK - command completed successfuly
582 * CL2_COMMAND_BUSY - previous command not completed
585 eCL2_RESULT cl2_clr_rx_buffer
587 sCAN_CARD *card /* Pointer to card structure */
591 /*******************************************************************************
592 * cl2_clr_sync_buffer - clear synchronous buffer
593 * """""""""""""""""""
595 * Command clears synchronous send buffer. All messages stored
596 * in synchronous buffer will be lost.
599 * CL2_OK - command completed successfuly
600 * CL2_COMMAND_BUSY - previous command not completed
603 eCL2_RESULT cl2_clr_sync_buffer
605 sCAN_CARD *card /* Pointer to card structure */
609 /*******************************************************************************
610 * cl2_clr_async_buffer - clear asynchronous buffer
611 * """"""""""""""""""""
613 * Command clears asynchronnous send buffer. All messages stored
614 * in async buffer will be lost.
617 * CL2_OK - command completed successfuly
618 * CL2_COMMAND_BUSY - previous command not completed
621 eCL2_RESULT cl2_clr_async_buffer
623 sCAN_CARD *card /* Pointer to card structure */
627 /*******************************************************************************
628 * cl2_send_time_sync - send time synchronization
631 * Command forces the card to start the High Resolution Synchronization
632 * Protocol according to the CANopen Communication profile. The SYNC
633 * mode has to be enabled (cl2_sync_mode) otherwise this command has
637 * CL2_OK - command completed successfuly
638 * CL2_COMMAND_BUSY - previous command not completed
641 eCL2_RESULT cl2_send_time_sync
643 sCAN_CARD *card /* Pointer to card structure */
647 /*******************************************************************************
648 * cl2_set_time_cobid - set time COB-ID
651 * Command sets the COB-ID for high resolution synchronization
652 * frame. The synchronization can be then made by means of
653 * cl2_send_time_sync command.
656 * CL2_OK - command completed successfuly
657 * CL2_COMMAND_BUSY - previous command not completed
660 eCL2_RESULT cl2_set_time_cobid
662 sCAN_CARD *card, /* Pointer to card structure */
663 U32 COBID /* HRS frame COB-ID */
667 /*******************************************************************************
668 * cl2_set_receive_limit - set limit for receive signaling
669 * """""""""""""""""""""
671 * Command is used to set the receive limit signalized by bit
672 * RL (in CL2.H CL2_X_DATA_IN_RBUF) of the Status Register.
673 * This bit is set when more then the limit number of frames
674 * was received since the last interrupt was generated (in interrupt
675 * mode) or since the Status Register was last time read.
679 * CL2_COMMAND_BUSY - previous command not completed
680 * CL2_BAD_PARAM - bad command parameter
682 eCL2_RESULT cl2_set_receive_limit
684 sCAN_CARD *card, /* pointer to card structure */
685 U16 limit /* limit of messages in receive buffer */
689 /*******************************************************************************
690 * cl2_download_rtr_list - download rtr list
691 * """""""""""""""""""""
693 * Command downloads a list of up to 64 RTR frames. These frames are
694 * periodically transmitted by the card. The parameters, how often
695 * frames are send and in which SYNC period is defined by period and
696 * subperiod in sRTR_FRAME structure.
699 * CL2_OK - command completed successfuly
700 * CL2_COMMAND_BUSY - previous command not completed
701 * CL2_BAD_PARAM - bad command parameter
704 eCL2_RESULT cl2_download_rtr_list
706 sCAN_CARD *card, /* Pointer to card structure */
707 sRTR_LIST *rtrList /* RTR list */
711 /*******************************************************************************
712 * cl2_subscribe_rtr - subscribe RTR frame
715 * Command subscribes RTR frame. Incoming RTR frames which were
716 * subscribed are accepted, while other are ignored. Up to 10
717 * RTR frames can be subscribed.
720 * CL2_OK - command completed successfuly
721 * CL2_COMMAND_BUSY - previous command not completed
722 * CL2_BAD_PARAM - bad command parameter
725 eCL2_RESULT cl2_subscribe_rtr
727 sCAN_CARD *card, /* Pointer to card structure */
728 sCAN_MESSAGE *canMessage, /* RTR frame */
729 U16 RTRnumber /* number of RTR */
733 /*******************************************************************************
734 * cl2_desubscribe_rtr - desubscribe rtr frame
735 * """""""""""""""""""
737 * Command desubscribes RTR frame. Card will not accept RTR frames
738 * with this identifier.
741 * CL2_OK - command completed successfuly
742 * CL2_COMMAND_BUSY - previous command not completed
743 * CL2_BAD_PARAM - bad command parameter
746 eCL2_RESULT cl2_desubscribe_rtr
748 sCAN_CARD *card, /* Pointer to card structure */
749 sCAN_MESSAGE *canMessage /* RTR frame */
753 /*******************************************************************************
754 * cl2_set_sync_cobid - set COB-ID
757 * Command sets COB-ID of SYNC frame. In active SYNC mode, the SYNC
758 * frame with this COB-ID is periodically sent with period defined
759 * by cl2_set_sync_period command.
762 * CL2_OK - command completed successfuly
763 * CL2_COMMAND_BUSY - previous command not completed
766 eCL2_RESULT cl2_set_sync_cobid
768 sCAN_CARD *card, /* Pointer to card structure */
769 U32 COBID /* COB-ID */
773 /*******************************************************************************
774 * cl2_set_sync_period - set SYNC period
775 * """""""""""""""""""
777 * Coomand sets the SYNC frame send period in active SYNC mode in
778 * x100 us. The period range is from 0 to 0xFFFF (SYNC period can
779 * be set from 100us to 6.5535s).
782 * CL2_OK - command completed successfuly
783 * CL2_COMMAND_BUSY - previous command not completed
786 eCL2_RESULT cl2_set_sync_period
788 sCAN_CARD *card, /* Pointer to card structure */
789 U16 period /* period in x100 us */
793 /*******************************************************************************
794 * cl2_set_sync_window - set SYNC window
795 * """""""""""""""""""
797 * Command sets the SYNC window length. Only during this time period
798 * after SYNC frame was send or receive the frames from the synchronous
799 * send buffer can be sent.
802 * CL2_OK - command completed successfuly
803 * CL2_COMMAND_BUSY - previous command not completed
806 eCL2_RESULT cl2_set_sync_window
808 sCAN_CARD *card, /* Pointer to card structure */
809 U16 window /* period in x100 us */
813 /*******************************************************************************
814 * cl2_set_bitrate - set CAN bit-rate
817 * Command switches the bus bit-rate. There are some predefined
818 * constants CL2_BITRATE_XXXX.
821 * CL2_OK - command completed successfuly
822 * CL2_COMMAND_BUSY - previous command not completed
825 eCL2_RESULT cl2_set_bitrate
827 sCAN_CARD *card, /* Pointer to card structure */
828 U16 bitrate /* CAN bitrate */
832 /*******************************************************************************
833 * cl2_bus_reset - resets CAN controller
836 * Command resets CAN controller
839 * CL2_OK - command completed successfuly
840 * CL2_COMMAND_BUSY - previously command not completed
843 eCL2_RESULT cl2_bus_reset
845 sCAN_CARD *card /* Pointer to card structure */
849 /*******************************************************************************
850 * cl2_send_sync - sends synchronous frame
853 * Command stores massage in synchronous send buffer.
856 * CL2_OK - command completed successfuly
857 * CL2_HW_QUEUE_FULL - synchronous send buffer is full
858 * CL2_BAD_PARAM - bad command parameter
859 * CL2_HW_FAILURE - error in HW configuration
862 eCL2_RESULT cl2_send_sync
864 sCAN_CARD *card, /* Pointer to card structure */
865 sCAN_MESSAGE *message /* message to be sent */
869 /*******************************************************************************
870 * cl2_send_async - sends asynchronous frame
873 * Command stores message in asynchronous send buffer.
876 * CL2_OK - command completed successfuly
877 * CL2_HW_QUEUE_FULL - asynchronous buffer full
878 * CL2_HW_FAILURE - error in HW configuration
879 * CL2_BAD_PARAM - bad command parameter
882 eCL2_RESULT cl2_send_async
884 sCAN_CARD *card, /* Pointer to card structure */
885 sCAN_MESSAGE *message /* message */
889 /*******************************************************************************
890 * cl2_get_status - reads card status
893 * Command reads card status register. If data in status register
894 * are valid (status valid flag is set), the value of status is read
895 * and stored in status and sCAN_CARD structure.
898 * CL2_OK - command completed successfuly
899 * CL2_NO_REQUEST - status is not valid
902 eCL2_RESULT cl2_get_status
904 sCAN_CARD *card, /* Pointer to card structure */
905 U16 *status /* Returned status */
909 /*******************************************************************************
910 * cl2_get_error - reads card error
913 * Command reads card error register. If data in error register
914 * are valid (error register valid flag is set), the value of error
915 * register is read and stored in error and sCAN_CARD structure.
918 * Cl2_OK - command completed successfuly
921 eCL2_RESULT cl2_get_error
923 sCAN_CARD *card, /* Pointer to card structure */
924 U16 *error /* Returned card error code */
928 /*******************************************************************************
929 * cl2_receive_data - reads received frame
932 * Command reads new messages received by a card.
935 * CL2_OK - command commpleted successfuly
936 * CL2_NO_REQUEST - there is no new message
939 eCL2_RESULT cl2_receive_data
941 sCAN_CARD *card, /* Pointer to card structure */
942 sCAN_MESSAGE *canMessage /* Message */
946 /* *********************************************************************** *
948 * *********************************************************************** */
950 #endif /* ifndef __INC_CL2_H */