]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/unican_cl2.h
The LinCAN driver license unified according to DCE FEE CTU head and superiors request.
[lincan.git] / lincan / include / unican_cl2.h
1 /**************************************************************************/
2 /* File: unican_cl2.h - Unicontrols PCAN,PCAN-PCI, VCAN core support      */
3 /*                                                                        */
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>      */
11 /*                                                                        */
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.                                              */
22 /*                                                                        */
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:                                                     */
26 /*                                                                        */
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 /**************************************************************************/
36
37
38 #ifndef __INC_CL2_H
39 #define __INC_CL2_H
40
41
42 /****** includes ******/
43
44 #ifndef __INC_ANCTYPES_H
45 #include "unican_types.h"
46 #endif
47
48 /****** Definitions of constants  ******/
49
50 /* PCI card Configuration Space Constants */
51 #define PCANDeviceID                    0x0101
52 #define PCANVendorID                    0xFA3C
53 #define PCANSubsystemID                 0x0001
54 #define PCANSubsystemVendorID           0x7A52
55
56
57 /* Description of card and card registers location. Registers location are
58  * mapped relative to card base address (BA) */
59
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)*/
76
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*/
82
83 /* Command valid flag */
84 #define CL2_COMMAND_VALID                        0x0080
85
86 /* Message flags */
87 #define CL2_MESSAGE_VALID         0x0001
88
89 /* status bits */
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
92                                                                                                                   * rx buffer*/
93 #define CL2_RBUF_OVERFLOW         0x0004   /* owerflow of rx buffer, some
94                                             * messages are lost*/
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 */
105
106 /* error bits */
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 */
115
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*/
122
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*/
127
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 */
132
133 /* Bitrates */
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 */
145
146
147 /****** Definition of structures  ******/
148
149 typedef struct  /*** card definition structure ***/
150         {
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 */
166         U32 rtrSub[10];
167         } sCAN_CARD;
168
169 //typedef struct  /*** CAN message formet ***/
170 //      {
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 */
176 //      } sCAN_MESSAGE;
177
178 typedef struct
179    {
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] */
185    } sCAN_MESSAGE;
186
187
188 typedef struct  /*** Remote Request RTR frame ***/
189    {
190    U32  cob_id;           /* RTR frame ID */
191    U16  period;           /* RTR period */
192    U16  subperiod;        /* RTR subperiod */
193    } sRTR_FRAME;
194
195 typedef struct  /*** Remote Request (RTR) list ***/
196         {
197         sRTR_FRAME *data;       /* RTR data */
198         U32 nb;                 /* Number of RTR definitions */
199         } sRTR_LIST;
200
201 typedef enum  /*** CL2 functions return codes ***/
202         {
203         CL2_OK = 0,           /* OK */
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 */
212    } eCL2_RESULT;
213
214 typedef enum  /*** CL2 commands ***/
215    {
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 */
225
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 */
232
233         cmCL2_DOWNLOAD_RTR_LIST = 0x20,   /**20 - Download RTR list */
234    cmCL2_SUBSCRIBE_RTR,              /**21 - Subscribe RTR */
235    cmCL2_DESUBSCRIBE_RTR,            /* 22 - Desubscribe RTR */
236
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 */
240
241         cmCL2_SET_BITRATE = 0x40,         /**40 - Set CAN bit rate */
242         cmCL2_BUS_RESET                   /* 41 - CAN controller reset */
243
244         } eCLU2_COMMAND;
245
246
247 /****** prototypes ******/
248
249
250 /*******************************************************************************
251 * cl2_find_card - find PCIPCAN card
252 * """""""""""""
253 *
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.
257 *
258 * RETURNS:
259 *   CL2_OK - card found and mapped under 1 MB
260 *   CL2_HW_FAILURE - card not found or not mapped under 1 MB
261 */
262 eCL2_RESULT cl2_find_card
263          (
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 */
267          );
268
269
270 /*******************************************************************************
271 * cl2_init_card - initialize card to default parameters
272 * """""""""""""
273 *
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
277 * structure.
278 *
279 * RETURNS:
280 *   CL2_OK - command completed succesfuly
281 *
282 */
283 eCL2_RESULT cl2_init_card
284         (
285         sCAN_CARD *card,            /* Pointer to card structure */
286         void *baseAddress,          /* Card base address pointer */
287         U16 intNumber               /* Card interrupt number */
288         );
289
290
291 /*******************************************************************************
292 * cl2_test_card - test card
293 * """""""""""""
294 *
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.
298 *
299 * RETURNS:
300 *   CL2_OK - card is present and working properly
301 *   CL2_HW_FAILURE - card not found or card error
302 *
303 */
304 eCL2_RESULT cl2_test_card
305         (
306         sCAN_CARD *card           /* Pointer to card structure */
307         );
308
309
310 /*******************************************************************************
311 * cl2_reset_card - reset card
312 * """"""""""""""
313 *
314 * Card pointed by *card gets hardware reset. This command resets
315 * card processor, card settings are restored to their default
316 * values.
317 *
318 * RETURNS:
319 *   CL2_OK - command completed successfuly
320 *
321 */
322 eCL2_RESULT cl2_reset_card
323    (
324    sCAN_CARD *card             /* Pointer to card structure */
325    );
326
327
328 /*******************************************************************************
329 * cl2_get_version - read card version
330 * """""""""""""""
331 *
332 * Fucntion reads a value from card version register.
333 *
334 * RETURNS:
335 *   CL2_OK - command completed successfuly
336 *
337 */
338 eCL2_RESULT cl2_get_version
339    (
340    sCAN_CARD *card,            /* Pointer to card structure */
341    U16 *version                /* returns card version */
342    );
343
344
345 /*******************************************************************************
346 * cl2_get_ID - read card ID
347 * """""""""""""""
348 *
349 * Fucntion reads a value from card ID register.
350 *
351 * RETURNS:
352 *   CL2_OK - command completed successfuly
353 *
354 */
355 eCL2_RESULT cl2_get_ID
356    (
357    sCAN_CARD *card,            /* Pointer to card structure */
358    U32 *IDlow,
359    U32 *IDhigh                         /* returns card version */
360    );
361
362
363 /*******************************************************************************
364 * cl2_gen_interrupt - request for interrupt
365 * """""""""""""""""
366 *
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.
370 *
371 * RETURNS:
372 *   CL2_OK - command completed successfuly
373 *
374 */
375 eCL2_RESULT cl2_gen_interrupt
376    (
377    sCAN_CARD *card           /* Pointer to card structure */
378    );
379
380
381 /*******************************************************************************
382 * cl2_start_it - start inhibit time
383 * """"""""""""
384 *
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.
388 *
389 * RETURNS:
390 *   CL2_OK - command completed successfuly
391 *
392 */
393 eCL2_RESULT cl2_start_it
394    (
395    sCAN_CARD *card           /* Pointer to card structure */
396    );
397
398
399 /*******************************************************************************
400 * cl2_clear_interrupt - clear interrupt
401 * """""""""""""""""""
402 *
403 * Comand clears interrupt (IRQ) generated by a card.
404 *
405 * RETURNS:
406 *   CL2_OK - command completed successfuly
407 *
408 */
409 eCL2_RESULT cl2_clear_interrupt
410    (
411    sCAN_CARD *card          /* Pointer to card structure */
412    );
413
414
415 /*******************************************************************************
416 * cl2_int_mode - set interrupt mode
417 * """"""""""""
418 *
419 * Command controls, which event will generate interrupt. Constants
420 * CL2_INT_XXXX are used for setting of interrupt mode.
421 *
422 * RETURNS:
423 *   CL2_OK - command completed successfuly
424 *   CL2_BAD_PARAM - bad command parameter
425 *   CL2_COMMAND_BUSY - previous command not completed
426 *
427 */
428 eCL2_RESULT cl2_int_mode
429    (
430    sCAN_CARD *card,            /* Pointer to card structure */
431    U16 mode                    /* Interrupt mode */
432    );
433
434
435 /*******************************************************************************
436 * cl2_iit_mode - inhibit interrupt time mode
437 * """"""""""""
438 *
439 * Command enables/disables inhibit interupt time mode.
440 *
441 * RETURNS:
442 *   CL2_OK - command completed successfuly
443 *   CL2_COMMAND_BUSY - previous command not completed
444 *
445 */
446 eCL2_RESULT cl2_iit_mode
447    (
448    sCAN_CARD *card,            /* Pointer to card structure */
449    BOOLEAN1 onoff              /* IIT mode - TRUE=on, FALSE=off */
450    );
451
452
453 /*******************************************************************************
454 * cl2_sync_mode - sync mode
455 * """""""""""""
456 *
457 * Command enables/disables transmission of SYNC frames.
458 *
459 * RETURNS:
460 *   CL2_OK - command completed successfuly
461 *   CL2_COMMAND_BUSY - previous command not completed
462 *
463 */
464 eCL2_RESULT cl2_sync_mode
465    (
466    sCAN_CARD *card,            /* Pointer to card structure */
467    BOOLEAN1 onoff              /* Sync mode - TRUE=on, FALSE=off */
468    );
469
470
471 /*******************************************************************************
472 * cl2_rtr_mode - rtr mode
473 * """"""""""""
474 *
475 * Command enables/disables automatic transmission of RTR frames
476 *
477 * RETURNS:
478 *   CL2_OK - command completed successfuly
479 *   CL2_COMMAND_BUSY - previous command not completed
480 *
481 */
482 eCL2_RESULT cl2_rtr_mode
483    (
484    sCAN_CARD *card,            /* Pointer to card structure */
485    BOOLEAN1 onoff              /* RTR mode - TRUE=on, FALSE=off */
486    );
487
488
489 /*******************************************************************************
490 * cl2_buf_size - size of synchronous queue
491 * """"""""""""
492 *
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
498 * vice versa.
499 * NOTE: 1 message = 16 bytes
500 *
501 * RETURNS:
502 *   CL2_OK - command completed successfully
503 *   CL2_COMMAND_BUSY - previous command not completed
504 *   CL2_BAD_PARAM - bad command parameter (bufSize>64)
505 *
506 */
507 eCL2_RESULT cl2_buf_size
508    (
509    sCAN_CARD *card,            /* Pointer to card structure */
510    U16 bufSize                 /* Size of synchronous buffer */
511    );
512
513
514 /*******************************************************************************
515 * cl2_set_iit - set value of inhibit interrupt time
516 * """""""""""
517 *
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
522 *
523 * RETURNS:
524 *   CL2_OK - command completed successfuly
525 *   CL2_COMMAND_BUSY - previous command not completed
526 *
527 */
528 eCL2_RESULT cl2_set_iit
529    (
530    sCAN_CARD *card,            /* Pointer to card structure */
531    U16 iit                     /* time period in x100 us */
532    );
533
534
535 /*******************************************************************************
536 * cl2_start_firmware - start firmware
537 * """"""""""""""""""
538 *
539 * Command starts card firmware
540 *
541 * RETURNS:
542 *   CL2_OK - command completed successfuly
543 *   CL2_COMMAND_BUSY - previous command not completed
544 *
545 */
546 eCL2_RESULT cl2_start_firmware
547    (
548    sCAN_CARD *card             /* Pointer to card structure */
549    );
550
551
552 /*******************************************************************************
553 * cl2_set_rec_mode - set receive mode
554 * """"""""""""""""
555 *
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).
560 *
561 * RETURNS:
562 *   CL2_OK - command completed successfuly
563 *   CL2_COMMAND_BUSY - previous command not completed
564 *
565 */
566 eCL2_RESULT cl2_set_rec_mode
567    (
568    sCAN_CARD *card,           /* Pointer to card structure */
569    BOOLEAN1 mode              /* Mode - TRUE=ext, FALSE=std */
570    );
571
572
573 /*******************************************************************************
574 * cl2_clr_rx_buffer - clear RX buffer
575 * """""""""""""""""
576 *
577 * Command clears receive (rx) buffer. All messages stored in
578 * rx buffer will be lost.
579 *
580 * RETURNS:
581 *   CL2_OK - command completed successfuly
582 *   CL2_COMMAND_BUSY - previous command not completed
583 *
584 */
585 eCL2_RESULT cl2_clr_rx_buffer
586    (
587    sCAN_CARD *card            /* Pointer to card structure */
588    );
589
590
591 /*******************************************************************************
592 * cl2_clr_sync_buffer - clear synchronous buffer
593 * """""""""""""""""""
594 *
595 * Command clears synchronous send buffer. All messages stored
596 * in synchronous buffer will be lost.
597 *
598 * RETURNS:
599 *   CL2_OK - command completed successfuly
600 *   CL2_COMMAND_BUSY - previous command not completed
601 *
602 */
603 eCL2_RESULT cl2_clr_sync_buffer
604    (
605    sCAN_CARD *card             /* Pointer to card structure */
606    );
607
608
609 /*******************************************************************************
610 * cl2_clr_async_buffer - clear asynchronous buffer
611 * """"""""""""""""""""
612 *
613 * Command clears asynchronnous send buffer. All messages stored
614 * in async buffer will be lost.
615 *
616 * RETURNS:
617 *   CL2_OK - command completed successfuly
618 *   CL2_COMMAND_BUSY - previous command not completed
619 *
620 */
621 eCL2_RESULT cl2_clr_async_buffer
622    (
623    sCAN_CARD *card            /* Pointer to card structure */
624    );
625
626
627 /*******************************************************************************
628 * cl2_send_time_sync - send time synchronization
629 * """"""""""""""""""
630 *
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
634 * no effect.
635 *
636 * RETURNS:
637 *   CL2_OK - command completed successfuly
638 *   CL2_COMMAND_BUSY - previous command not completed
639 *
640 */
641 eCL2_RESULT cl2_send_time_sync
642    (
643    sCAN_CARD *card             /* Pointer to card structure */
644    );
645
646
647 /*******************************************************************************
648 * cl2_set_time_cobid - set time COB-ID
649 * """"""""""""""""""
650 *
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.
654 *
655 * RETURNS:
656 *   CL2_OK - command completed successfuly
657 *   CL2_COMMAND_BUSY - previous command not completed
658 *
659 */
660 eCL2_RESULT cl2_set_time_cobid
661    (
662    sCAN_CARD *card,           /* Pointer to card structure */
663    U32 COBID                  /* HRS frame COB-ID */
664    );
665
666
667 /*******************************************************************************
668 * cl2_set_receive_limit - set limit for receive signaling
669 * """""""""""""""""""""
670 *
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.
676 *
677 * RETURNS:
678 *   CL2_OK
679 *   CL2_COMMAND_BUSY - previous command not completed
680 *   CL2_BAD_PARAM - bad command parameter
681 */
682 eCL2_RESULT cl2_set_receive_limit
683    (
684    sCAN_CARD *card,          /* pointer to card structure */
685    U16 limit                 /* limit of messages in receive buffer */
686    );
687
688
689 /*******************************************************************************
690 * cl2_download_rtr_list - download rtr list
691 * """""""""""""""""""""
692 *
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.
697 *
698 * RETURNS:
699 *   CL2_OK - command completed successfuly
700 *   CL2_COMMAND_BUSY - previous command not completed
701 *   CL2_BAD_PARAM - bad command parameter
702 *
703 */
704 eCL2_RESULT cl2_download_rtr_list
705    (
706    sCAN_CARD *card,           /* Pointer to card structure */
707    sRTR_LIST *rtrList         /* RTR list */
708    );
709
710
711 /*******************************************************************************
712 * cl2_subscribe_rtr - subscribe RTR frame
713 * """""""""""""""""
714 *
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.
718 *
719 * RETURNS:
720 *   CL2_OK - command completed successfuly
721 *   CL2_COMMAND_BUSY - previous command not completed
722 *   CL2_BAD_PARAM - bad command parameter
723 *
724 */
725 eCL2_RESULT cl2_subscribe_rtr
726    (
727    sCAN_CARD *card,            /* Pointer to card structure */
728    sCAN_MESSAGE *canMessage,   /* RTR frame */
729    U16 RTRnumber               /* number of RTR */
730    );
731
732
733 /*******************************************************************************
734 * cl2_desubscribe_rtr - desubscribe rtr frame
735 * """""""""""""""""""
736 *
737 * Command desubscribes RTR frame. Card will not accept RTR frames
738 * with this identifier.
739 *
740 * RETURNS:
741 *   CL2_OK - command completed successfuly
742 *   CL2_COMMAND_BUSY - previous command not completed
743 *   CL2_BAD_PARAM - bad command parameter
744 *
745 */
746 eCL2_RESULT cl2_desubscribe_rtr
747    (
748    sCAN_CARD *card,            /* Pointer to card structure */
749    sCAN_MESSAGE *canMessage    /* RTR frame */
750    );
751
752
753 /*******************************************************************************
754 * cl2_set_sync_cobid - set COB-ID
755 * """"""""""""""""""
756 *
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.
760 *
761 * RETURNS:
762 *   CL2_OK - command completed successfuly
763 *   CL2_COMMAND_BUSY - previous command not completed
764 *
765 */
766 eCL2_RESULT cl2_set_sync_cobid
767    (
768    sCAN_CARD *card,            /* Pointer to card structure */
769    U32 COBID                   /* COB-ID */
770    );
771
772
773 /*******************************************************************************
774 * cl2_set_sync_period - set SYNC period
775 * """""""""""""""""""
776 *
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).
780 *
781 * RETURNS:
782 *   CL2_OK - command completed successfuly
783 *   CL2_COMMAND_BUSY - previous command not completed
784 *
785 */
786 eCL2_RESULT cl2_set_sync_period
787    (
788    sCAN_CARD *card,            /* Pointer to card structure */
789    U16 period                  /* period in x100 us */
790    );
791
792
793 /*******************************************************************************
794 * cl2_set_sync_window - set SYNC window
795 * """""""""""""""""""
796 *
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.
800 *
801 * RETURNS:
802 *   CL2_OK - command completed successfuly
803 *   CL2_COMMAND_BUSY - previous command not completed
804 *
805 */
806 eCL2_RESULT cl2_set_sync_window
807    (
808    sCAN_CARD *card,            /* Pointer to card structure */
809    U16 window                  /* period in x100 us */
810    );
811
812
813 /*******************************************************************************
814 * cl2_set_bitrate - set CAN bit-rate
815 * """""""""""""""
816 *
817 * Command switches the bus bit-rate. There are some predefined
818 * constants CL2_BITRATE_XXXX.
819 *
820 * RETURNS:
821 *   CL2_OK - command completed successfuly
822 *   CL2_COMMAND_BUSY - previous command not completed
823 *
824 */
825 eCL2_RESULT cl2_set_bitrate
826    (
827    sCAN_CARD *card,            /* Pointer to card structure */
828    U16 bitrate                 /* CAN bitrate */
829    );
830
831
832 /*******************************************************************************
833 * cl2_bus_reset - resets CAN controller
834 * """""""""""""
835 *
836 * Command resets CAN controller
837 *
838 * RETURNS:
839 *   CL2_OK - command completed successfuly
840 *   CL2_COMMAND_BUSY - previously command not completed
841 *
842 */
843 eCL2_RESULT cl2_bus_reset
844    (
845    sCAN_CARD *card            /* Pointer to card structure */
846    );
847
848
849 /*******************************************************************************
850 * cl2_send_sync - sends synchronous frame
851 * """""""""""""
852 *
853 * Command stores massage in synchronous send buffer.
854 *
855 * RETURNS:
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
860 *
861 */
862 eCL2_RESULT cl2_send_sync
863    (
864    sCAN_CARD *card,           /* Pointer to card structure */
865    sCAN_MESSAGE *message      /* message to be sent */
866    );
867
868
869 /*******************************************************************************
870 * cl2_send_async - sends asynchronous frame
871 * """"""""""""""
872 *
873 * Command stores message in asynchronous send buffer.
874 *
875 * RETURNS:
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
880 *
881 */
882 eCL2_RESULT cl2_send_async
883    (
884    sCAN_CARD *card,           /* Pointer to card structure */
885    sCAN_MESSAGE *message      /* message */
886    );
887
888
889 /*******************************************************************************
890 * cl2_get_status - reads card status
891 * """"""""""""""
892 *
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.
896 *
897 * RETURNS:
898 *   CL2_OK - command completed successfuly
899 *   CL2_NO_REQUEST - status is not valid
900 *
901 */
902 eCL2_RESULT cl2_get_status
903    (
904    sCAN_CARD *card,           /* Pointer to card structure */
905    U16 *status                /* Returned status */
906    );
907
908
909 /*******************************************************************************
910 * cl2_get_error - reads card error
911 * """""""""""""
912 *
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.
916 *
917 * RETURNS:
918 *   Cl2_OK - command completed successfuly
919 *
920 */
921 eCL2_RESULT cl2_get_error
922    (
923    sCAN_CARD *card,           /* Pointer to card structure */
924    U16 *error                 /* Returned card error code */
925    );
926
927
928 /*******************************************************************************
929 * cl2_receive_data - reads received frame
930 * """"""""""""""""
931 *
932 * Command reads new messages received by a card.
933 *
934 * RETURNS:
935 *   CL2_OK - command commpleted successfuly
936 *   CL2_NO_REQUEST - there is no new message
937 *
938 */
939 eCL2_RESULT cl2_receive_data
940    (
941    sCAN_CARD *card,             /* Pointer to card structure */
942    sCAN_MESSAGE *canMessage     /* Message */
943    );
944
945
946 /* *********************************************************************** *
947  * END OF CL2.H                                                            *
948  * *********************************************************************** */
949
950 #endif /* ifndef __INC_CL2_H */