]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/unican_cl2.h
ffd6bec000912856ed8b5bd6768374be1e6edf59
[lincan.git] / lincan / include / unican_cl2.h
1 /******************************************************************************
2
3 Cl2.H - PCAN and VCAN cards hardware access library
4 """"""""
5                    (C) Copyright 1997   Unicontrols a.s.
6
7 PROJEKT            :    CANopen
8 AUTOR              :    F.Spurny
9 FIRMA              :    CVUT FEL, Dept. of Measurement
10 PORTING            :    Adapted for LinCAN driver by Pavel Pisa, OCERA team member
11
12 DULEZITE UPOZORNENI:
13
14 ARCHIVACNI INFORMACE:
15 $Log$
16 Revision 1.1  2004/03/13 23:13:31  ppisa
17 Interconnected OCERA configuration options with LinCAN boardlist.c compilation.
18
19
20 27.1.1999 - corected value of CL2_ERROR_WARNING and CL2_ERROR_BUS_OFF constants
21
22 12.12.2000 - CL2_STATUS_RESET_CARD, CL2_ERROR_RESET_CARD added
23              fields of sCAN_MESSAGE aligned
24
25 10.8.2001 - PCI PCAN ID registers content defined
26         - cl2_find_card function prototype added
27         - cl2_get_ID function prototype added
28
29 10.2.2004 - Start of PCAN support porting to RT-Linux and Linux environment
30
31 ===============================================================================
32
33 UCEL A FUNKCE:
34
35 ******************************************************************************/
36
37 #ifndef __INC_CL2_H
38 #define __INC_CL2_H
39
40
41 /****** includes ******/
42
43 #ifndef __INC_ANCTYPES_H
44 #include "anctypes.h"
45 #endif
46
47 /****** Definitions of constants  ******/
48
49 /* PCI card Configuration Space Constants */
50 #define PCANDeviceID                    0x0101
51 #define PCANVendorID                    0xFA3C
52 #define PCANSubsystemID                 0x0001
53 #define PCANSubsystemVendorID           0x7A52
54
55
56 /* Description of card and card registers location. Registers location are
57  * mapped relative to card base address (BA) */
58
59 #define CL2_RAM_SIZE                    0x1000  /* size of dual-port RAM */
60 #define CL2_RX_BUFFER_DEFAULT           0x800   /* off(BA->rx buffer) */
61 #define CL2_SYNC_BUFFER_DEFAULT         0x400   /* off(BA->sync buffer) */
62 #define CL2_ASYNC_BUFFER_DEFAULT        0x600   /* off(BA->async buffer) */
63 #define CL2_COMMAND_REGISTER            0x3FE   /* off(BA->command register )*/
64 #define CL2_VERSION_REGISTER            0x3F6   /* off(BA->version register )*/
65 #define CL2_ID_REGISTER                 0x3EE   /* off(BA->ID register) */
66 #define CL2_GEN_INT_REGISTER            0x3E4   /* off(BA->generate interrupt reg.)*/
67 #define CL2_CLEAR_INT_REGISTER          0x3E2   /* off(BA->clear interrupt reg)*/
68 #define CL2_RESET_REGISTER              0x3E0   /* off(BA->reset register)*/
69 #define CL2_ERROR_REGISTER              0x3F8   /* off(BA->error register)*/
70 #define CL2_TIME_REGISTER                       0x3FC   /* currently not used */
71 #define CL2_START_IT_REGISTER           0x3E6   /* off(BA->start inhibit time reg.) */
72 #define CL2_STATUS_REGISTER             0x3FA   /* off(BA->status register)*/
73 #define CL2_VME_INT_VECTOR              0x3F0
74 #define CL2_DATA_BUFFER                 0x100   /* off(BA->data buffer)*/
75
76 /* Default sizes of buffers (in messages)
77  * FYI: 1 message needs 16 bytes to be stored */
78 #define CL2_RX_BUFFER_SIZE                              128     /* size of receive (rx) buffer */
79 #define CL2_TX_SYNC_BUFFER_SIZE         32              /* size of synchronnous buffer */
80 #define CL2_TX_ASYNC_BUFFER_SIZE                32              /* size of asynchronnous buffer*/
81
82 /* Command valid flag */
83 #define CL2_COMMAND_VALID                        0x0080
84
85 /* Message flags */
86 #define CL2_MESSAGE_VALID         0x0001
87
88 /* status bits */
89 #define CL2_DATA_IN_RBUF          0x0001   /* message is in rx buffer*/
90 #define CL2_X_DATA_IN_RBUF        0x0002   /* more than LIMIT messages are in
91                                                                                                                   * rx buffer*/
92 #define CL2_RBUF_OVERFLOW         0x0004   /* owerflow of rx buffer, some
93                                             * messages are lost*/
94 #define CL2_SYNC_QUEUE_EMPTY      0x0010   /* sync queue is empty */
95 #define CL2_ASYNC_QUEUE_EMPTY     0x0020   /* async queue is empty */
96 #define CL2_CARD_ERROR            0x0040   /* card reports an error */
97 #define CL2_STATUS_VALID_FLAG     0x0080   /* bit indicating that status
98                                             * register contains valid data*/
99 #define CL2_CARD_READY            0x0100   /* card is ready */
100 #define CL2_SYNC_PASSIVE          0x0200   /* passive SYNC mode */
101 #define CL2_SYNC_ACTIVE           0x0400   /* active SYNC mode */
102 #define CL2_RTR_LIST              0x0800   /* RTR list sending */
103 #define CL2_STATUS_RESET_CARD     0x8000   /* card reset occurred */
104
105 /* error bits */
106 #define CL2_ERROR_LL              0x0007   /*  */
107 #define CL2_ERROR_WARNING         0x0040   /* bus warning detected */
108 #define CL2_ERROR_BUS_OFF         0x0080   /* bus error detected */
109 #define CL2_ERROR_RESET_CARD      0x0100   /* card reset occurred */\r
110 #define CL2_ERROR_FIRMWARE        0x1000   /* firmware error detected */
111 #define CL2_ERROR_DPRAM           0x2000   /* dual port RAM error detected */
112 #define CL2_ERROR_RAM             0x4000   /* internal RAM error detected */
113 #define CL2_ERROR_CAN             0x8000   /* CAN controller error detected */
114
115 /* interrupt generation */
116 #define INT_MODE_RX               0x01     /* if data are in receive buffer*/
117 #define INT_MODE_ERROR            0x02     /* if any error occurs */
118 #define INT_MODE_SYNC_EMPTY       0x04     /* if tx sync. queue is empty*/
119 #define INT_MODE_ASYNC_EMPTY      0x08     /* if tx async. queue is empty*/
120 #define INT_MODE_ALL              0x0F     /* if any event occurs*/
121
122 /* CAN message types */
123 #define CL2_REMOTE_FRAME          0x08     /* frame is a remote frame*/
124 #define CL2_LINE_FLAG             0x80
125 #define CL2_EXT_FRAME             0x04     /* frame is extended format*/
126
127 /* Receive message flags */
128 #define CL2_FRAME_VALID           0x01     /* message in buffer is valid */
129 #define CL2_RX_OVERFLOW           0x02     /* stored unread message was
130                                             * overwritten by another one */
131
132 /* Bitrates */
133 #define CL2_BITRATE_5K            0x7f7f   /* bit-rate 5 kb/s */
134 #define CL2_BITRATE_10K           0x5c67   /* bit-rate 10 kb/s */
135 #define CL2_BITRATE_20K           0x5c53   /* bit-rate 20 kb/s */
136 #define CL2_BITRATE_50K           0x5c47   /* bit-rate 50 kb/s */
137 #define CL2_BITRATE_100K          0x5c43   /* bit-rate 100 kb/s */
138 #define CL2_BITRATE_125K          0x6743   /* bit-rate 125 kb/s */
139 #define CL2_BITRATE_200K          0x5c41   /* bit-rate 200 kb/s */
140 #define CL2_BITRATE_250K          0x6741   /* bit-rate 250 kb/s */
141 #define CL2_BITRATE_500K          0x6740   /* bit-rate 500 kb/s */
142 #define CL2_BITRATE_800K          0x3440   /* bit-rate 800 kb/s */
143 #define CL2_BITRATE_1M            0x2340   /* bit-rate 1 Mb/s */
144
145
146 /****** Definition of structures  ******/
147
148 typedef struct  /*** card definition structure ***/
149         {
150         U16  intNumber;         /* Card interrupt (IRQ) number */
151         U8   *baseAddressPtr;   /* Pointer to card base address (BA) */
152         U8   *rxBufPtr;         /* Pointer to receive buffer */
153         U8   *rxBufBase;        /* Pointer to empty receive buffer */
154         U8   *asyncTxBufPtr;    /* Pointer to async transmit buffer */
155         U8   *asyncTxBufBase;   /* Pointer to empty async. transmit buffer */
156         U8   *syncTxBufPtr;     /* Pointer to sync. transmit buffer */
157         U8   *syncTxBufBase;    /* Pointer to empty sync. transmit buffer */
158         U8   *commandRegister;  /* Pointer to command register */
159         U8   *dataPtr;          /* Pointer to command data buffer */
160         U16  rxBufSize;         /* size of receive buffer (x16 bytes) */
161         U16  syncTxBufSize;     /* size of sync. transmit buffer (x16 bytes)*/
162         U16  asyncTxBufSize;    /* size of async. transmit buffer (x 16 bytes)*/
163         U16  status;            /* last card status */
164         U16  error;             /* last not reported card error */
165         U32 rtrSub[10];
166         } sCAN_CARD;
167
168 //typedef struct  /*** CAN message formet ***/
169 //      {
170 //      U8   data[8];           /* Data message buffer (8 bytes) */
171 //      U8   dataLength;        /* Data length (in bytes) */
172 //      U32  COB_ID;            /* COB_ID */
173 //      U16  timeStamp;         /* Message time stamp */
174 //      U8   dataType;          /* Message data type */
175 //      } sCAN_MESSAGE;
176
177 typedef struct
178    {
179    U32  COB_ID;             /* COB identifier */
180    U8   dataType;          /* Message data type */
181    U8   dataLength;        /* Data length (in bytes) */
182    U8   data[8];           /* Data message buffer (8 bytes) */
183    U16  timeStamp;         /* Message time stamp [us] */
184    } sCAN_MESSAGE;
185
186
187 typedef struct  /*** Remote Request RTR frame ***/
188    {
189    U32  cob_id;           /* RTR frame ID */
190    U16  period;           /* RTR period */
191    U16  subperiod;        /* RTR subperiod */
192    } sRTR_FRAME;
193
194 typedef struct  /*** Remote Request (RTR) list ***/
195         {
196         sRTR_FRAME *data;       /* RTR data */
197         U32 nb;                 /* Number of RTR definitions */
198         } sRTR_LIST;
199
200 typedef enum  /*** CL2 functions return codes ***/
201         {
202         CL2_OK = 0,           /* OK */
203         CL2_NO_REQUEST,       /* No request*/
204         CL2_HW_FAILURE,       /* HW failure */
205         CL2_HW_QUEUE_FULL,    /* Transmit queue full */
206         CL2_BAD_PARAM,        /* Bad number of parameters */
207    CL2_HW_QUEUE_EMPTY,   /* Receive queue empty */
208         CL2_COMMAND_BUSY,     /* Command busy - previous command not completed */
209         CL2_UNKNOWN_COMMAND,  /* Unknown command */
210         CL2_NO_PCI_BIOS          /* missing PCI BIOS support */
211    } eCL2_RESULT;
212
213 typedef enum  /*** CL2 commands ***/
214    {
215    cmCL2_INT_MODE = 0x01,            /**01 - Set Interrupt mode */
216    cmCL2_IIT_MODE,                   /**02 - Inhibit Interrupt Time mode */
217    cmCL2_SYNC_MODE,                  /**03 - SYNC mode */
218         cmCL2_RTR_MODE,                   /**04 - RTR list mode */
219         cmCL2_BUF_SIZE,                   /**05 - Set buffers sizes */
220    cmCL2_SET_IIT,                    /**06 - Start Inhibit Interrupt Time */
221    cmCL2_START_FIRMWARE,             /**07 - Start firmware */
222    cmCL2_LOAD_FIRMWARE,              /* 08 - Load firmware */
223         cmCL2_SET_REC_MODE,               /**09 - Set Receive mode */
224
225    cmCL2_CLR_RX_BUFFER = 0x10,       /**10 - Clear receive buffer */
226    cmCL2_CLR_SYNC_BUFFER,            /**11 - Clear synchronous buffer */
227    cmCL2_CLR_ASYNC_BUFFER,           /**12 - Clear asynchronous buffer */
228         cmCL2_SEND_TIME_SYNC,             /**13 - Sends time synchronization */
229         cmCL2_SET_TIME_COBID,             /**14 - Sets time frames COB-ID */
230    cmCL2_SET_RECEIVE_LIMIT,          /* 15 - Sets receive limit */
231
232         cmCL2_DOWNLOAD_RTR_LIST = 0x20,   /**20 - Download RTR list */
233    cmCL2_SUBSCRIBE_RTR,              /**21 - Subscribe RTR */
234    cmCL2_DESUBSCRIBE_RTR,            /* 22 - Desubscribe RTR */
235
236    cmCL2_SET_COBID = 0x30,           /**30 - Set COB-ID */
237    cmCL2_SET_SYNC_PERIOD,            /**31 - Set SYNC period */
238    cmCL2_SET_SYNC_WINDOW,            /**32 - Set SYNC period window */
239
240         cmCL2_SET_BITRATE = 0x40,         /**40 - Set CAN bit rate */
241         cmCL2_BUS_RESET                   /* 41 - CAN controller reset */
242
243         } eCLU2_COMMAND;
244
245
246 /****** prototypes ******/
247
248
249 /*******************************************************************************
250 * cl2_find_card - find PCIPCAN card
251 * """""""""""""
252 *
253 * Searches for PCIPCAN cards in the system. The mapping (memory and interrupt)
254 * of the card is found. An index parameter specifies how many PCIPCAN cards have
255 * to be skipped in search.
256 *
257 * RETURNS:
258 *   CL2_OK - card found and mapped under 1 MB
259 *   CL2_HW_FAILURE - card not found or not mapped under 1 MB
260 */
261 eCL2_RESULT cl2_find_card
262          (
263          U16 *baseAddress,               /* card's physical base address */
264          U16 *intNumber,                 /* card's interrupt level */
265          U16 index                  /* number of PCIPCAN cards to be skipped */
266          );
267
268
269 /*******************************************************************************
270 * cl2_init_card - initialize card to default parameters
271 * """""""""""""
272 *
273 * Command installs card. The data in sCAN_CARD structure pointed
274 * by *card are initialized to their predefined default values.
275 * Command must be called before any operation with sCAN_CARD
276 * structure.
277 *
278 * RETURNS:
279 *   CL2_OK - command completed succesfuly
280 *
281 */
282 eCL2_RESULT cl2_init_card
283         (
284         sCAN_CARD *card,            /* Pointer to card structure */
285         void *baseAddress,          /* Card base address pointer */
286         U16 intNumber               /* Card interrupt number */
287         );
288
289
290 /*******************************************************************************
291 * cl2_test_card - test card
292 * """""""""""""
293 *
294 * Test whether the card is installed in system and working properly
295 * or not. If this function fails (return value is CL2_HW_FAILURE)
296 * check if the card is present and card base address.
297 *
298 * RETURNS:
299 *   CL2_OK - card is present and working properly
300 *   CL2_HW_FAILURE - card not found or card error
301 *
302 */
303 eCL2_RESULT cl2_test_card
304         (
305         sCAN_CARD *card           /* Pointer to card structure */
306         );
307
308
309 /*******************************************************************************
310 * cl2_reset_card - reset card
311 * """"""""""""""
312 *
313 * Card pointed by *card gets hardware reset. This command resets
314 * card processor, card settings are restored to their default
315 * values.
316 *
317 * RETURNS:
318 *   CL2_OK - command completed successfuly
319 *
320 */
321 eCL2_RESULT cl2_reset_card
322    (
323    sCAN_CARD *card             /* Pointer to card structure */
324    );
325
326
327 /*******************************************************************************
328 * cl2_get_version - read card version
329 * """""""""""""""
330 *
331 * Fucntion reads a value from card version register.
332 *
333 * RETURNS:
334 *   CL2_OK - command completed successfuly
335 *
336 */
337 eCL2_RESULT cl2_get_version
338    (
339    sCAN_CARD *card,            /* Pointer to card structure */
340    U16 *version                /* returns card version */
341    );
342
343
344 /*******************************************************************************
345 * cl2_get_ID - read card ID
346 * """""""""""""""
347 *
348 * Fucntion reads a value from card ID register.
349 *
350 * RETURNS:
351 *   CL2_OK - command completed successfuly
352 *
353 */
354 eCL2_RESULT cl2_get_ID
355    (
356    sCAN_CARD *card,            /* Pointer to card structure */
357    U32 *IDlow,
358    U32 *IDhigh                         /* returns card version */
359    );
360
361
362 /*******************************************************************************
363 * cl2_gen_interrupt - request for interrupt
364 * """""""""""""""""
365 *
366 * CAN card is requested to generate interrupt if there is any reason
367 * to do it. The condition for interrupt generation is defined by
368 * cl2_int_mode command.
369 *
370 * RETURNS:
371 *   CL2_OK - command completed successfuly
372 *
373 */
374 eCL2_RESULT cl2_gen_interrupt
375    (
376    sCAN_CARD *card           /* Pointer to card structure */
377    );
378
379
380 /*******************************************************************************
381 * cl2_start_it - start inhibit time
382 * """"""""""""
383 *
384 * Command starts interrupt inhibit time. If there is any reason for
385 * interrupt geneation, the card generates interrupt after end of
386 * specified time interval. Time interval is set by cl2_set_iit command.
387 *
388 * RETURNS:
389 *   CL2_OK - command completed successfuly
390 *
391 */
392 eCL2_RESULT cl2_start_it
393    (
394    sCAN_CARD *card           /* Pointer to card structure */
395    );
396
397
398 /*******************************************************************************
399 * cl2_clear_interrupt - clear interrupt
400 * """""""""""""""""""
401 *
402 * Comand clears interrupt (IRQ) generated by a card.
403 *
404 * RETURNS:
405 *   CL2_OK - command completed successfuly
406 *
407 */
408 eCL2_RESULT cl2_clear_interrupt
409    (
410    sCAN_CARD *card          /* Pointer to card structure */
411    );
412
413
414 /*******************************************************************************
415 * cl2_int_mode - set interrupt mode
416 * """"""""""""
417 *
418 * Command controls, which event will generate interrupt. Constants
419 * CL2_INT_XXXX are used for setting of interrupt mode.
420 *
421 * RETURNS:
422 *   CL2_OK - command completed successfuly
423 *   CL2_BAD_PARAM - bad command parameter
424 *   CL2_COMMAND_BUSY - previous command not completed
425 *
426 */
427 eCL2_RESULT cl2_int_mode
428    (
429    sCAN_CARD *card,            /* Pointer to card structure */
430    U16 mode                    /* Interrupt mode */
431    );
432
433
434 /*******************************************************************************
435 * cl2_iit_mode - inhibit interrupt time mode
436 * """"""""""""
437 *
438 * Command enables/disables inhibit interupt time mode.
439 *
440 * RETURNS:
441 *   CL2_OK - command completed successfuly
442 *   CL2_COMMAND_BUSY - previous command not completed
443 *
444 */
445 eCL2_RESULT cl2_iit_mode
446    (
447    sCAN_CARD *card,            /* Pointer to card structure */
448    BOOLEAN1 onoff              /* IIT mode - TRUE=on, FALSE=off */
449    );
450
451
452 /*******************************************************************************
453 * cl2_sync_mode - sync mode
454 * """""""""""""
455 *
456 * Command enables/disables transmission of SYNC frames.
457 *
458 * RETURNS:
459 *   CL2_OK - command completed successfuly
460 *   CL2_COMMAND_BUSY - previous command not completed
461 *
462 */
463 eCL2_RESULT cl2_sync_mode
464    (
465    sCAN_CARD *card,            /* Pointer to card structure */
466    BOOLEAN1 onoff              /* Sync mode - TRUE=on, FALSE=off */
467    );
468
469
470 /*******************************************************************************
471 * cl2_rtr_mode - rtr mode
472 * """"""""""""
473 *
474 * Command enables/disables automatic transmission of RTR frames
475 *
476 * RETURNS:
477 *   CL2_OK - command completed successfuly
478 *   CL2_COMMAND_BUSY - previous command not completed
479 *
480 */
481 eCL2_RESULT cl2_rtr_mode
482    (
483    sCAN_CARD *card,            /* Pointer to card structure */
484    BOOLEAN1 onoff              /* RTR mode - TRUE=on, FALSE=off */
485    );
486
487
488 /*******************************************************************************
489 * cl2_buf_size - size of synchronous queue
490 * """"""""""""
491 *
492 * Command sets the size of synchronous send buffer. The size is
493 * in numbers of messages. Default buffer size is 32 messages.
494 * The sum of synchronous_buffer_size and asynchronous_buffer_size
495 * is constant and equal to 64. So, if the size od synchronous
496 * buffer increases, the size of asynchronous buffer decreases and
497 * vice versa.
498 * NOTE: 1 message = 16 bytes
499 *
500 * RETURNS:
501 *   CL2_OK - command completed successfully
502 *   CL2_COMMAND_BUSY - previous command not completed
503 *   CL2_BAD_PARAM - bad command parameter (bufSize>64)
504 *
505 */
506 eCL2_RESULT cl2_buf_size
507    (
508    sCAN_CARD *card,            /* Pointer to card structure */
509    U16 bufSize                 /* Size of synchronous buffer */
510    );
511
512
513 /*******************************************************************************
514 * cl2_set_iit - set value of inhibit interrupt time
515 * """""""""""
516 *
517 * Command sets value of inhibit interrupt time. If inhibit
518 * interrupt time mode is enabled and started, generation of
519 * interrupt (IRQ) is disabled during this time period.
520 * Inhibit interrupt time can be set from 100 us to 6.5535 s
521 *
522 * RETURNS:
523 *   CL2_OK - command completed successfuly
524 *   CL2_COMMAND_BUSY - previous command not completed
525 *
526 */
527 eCL2_RESULT cl2_set_iit
528    (
529    sCAN_CARD *card,            /* Pointer to card structure */
530    U16 iit                     /* time period in x100 us */
531    );
532
533
534 /*******************************************************************************
535 * cl2_start_firmware - start firmware
536 * """"""""""""""""""
537 *
538 * Command starts card firmware
539 *
540 * RETURNS:
541 *   CL2_OK - command completed successfuly
542 *   CL2_COMMAND_BUSY - previous command not completed
543 *
544 */
545 eCL2_RESULT cl2_start_firmware
546    (
547    sCAN_CARD *card             /* Pointer to card structure */
548    );
549
550
551 /*******************************************************************************
552 * cl2_set_rec_mode - set receive mode
553 * """"""""""""""""
554 *
555 * Command sets card receive mode. This enable reception of standard
556 * or extended frames according to CAN 2.0A and 2.0B specifications.
557 * If value of mode is TRUE, card receives extended frames, if mode
558 * is FALSE, card receives standard massage format (default).
559 *
560 * RETURNS:
561 *   CL2_OK - command completed successfuly
562 *   CL2_COMMAND_BUSY - previous command not completed
563 *
564 */
565 eCL2_RESULT cl2_set_rec_mode
566    (
567    sCAN_CARD *card,           /* Pointer to card structure */
568    BOOLEAN1 mode              /* Mode - TRUE=ext, FALSE=std */
569    );
570
571
572 /*******************************************************************************
573 * cl2_clr_rx_buffer - clear RX buffer
574 * """""""""""""""""
575 *
576 * Command clears receive (rx) buffer. All messages stored in
577 * rx buffer will be lost.
578 *
579 * RETURNS:
580 *   CL2_OK - command completed successfuly
581 *   CL2_COMMAND_BUSY - previous command not completed
582 *
583 */
584 eCL2_RESULT cl2_clr_rx_buffer
585    (
586    sCAN_CARD *card            /* Pointer to card structure */
587    );
588
589
590 /*******************************************************************************
591 * cl2_clr_sync_buffer - clear synchronous buffer
592 * """""""""""""""""""
593 *
594 * Command clears synchronous send buffer. All messages stored
595 * in synchronous buffer will be lost.
596 *
597 * RETURNS:
598 *   CL2_OK - command completed successfuly
599 *   CL2_COMMAND_BUSY - previous command not completed
600 *
601 */
602 eCL2_RESULT cl2_clr_sync_buffer
603    (
604    sCAN_CARD *card             /* Pointer to card structure */
605    );
606
607
608 /*******************************************************************************
609 * cl2_clr_async_buffer - clear asynchronous buffer
610 * """"""""""""""""""""
611 *
612 * Command clears asynchronnous send buffer. All messages stored
613 * in async buffer will be lost.
614 *
615 * RETURNS:
616 *   CL2_OK - command completed successfuly
617 *   CL2_COMMAND_BUSY - previous command not completed
618 *
619 */
620 eCL2_RESULT cl2_clr_async_buffer
621    (
622    sCAN_CARD *card            /* Pointer to card structure */
623    );
624
625
626 /*******************************************************************************
627 * cl2_send_time_sync - send time synchronization
628 * """"""""""""""""""
629 *
630 * Command forces the card to start the High Resolution Synchronization
631 * Protocol according to the CANopen Communication profile. The SYNC
632 * mode has to be enabled (cl2_sync_mode) otherwise this command has
633 * no effect.
634 *
635 * RETURNS:
636 *   CL2_OK - command completed successfuly
637 *   CL2_COMMAND_BUSY - previous command not completed
638 *
639 */
640 eCL2_RESULT cl2_send_time_sync
641    (
642    sCAN_CARD *card             /* Pointer to card structure */
643    );
644
645
646 /*******************************************************************************
647 * cl2_set_time_cobid - set time COB-ID
648 * """"""""""""""""""
649 *
650 * Command sets the COB-ID for high resolution synchronization
651 * frame. The synchronization can be then made by means of
652 * cl2_send_time_sync command.
653 *
654 * RETURNS:
655 *   CL2_OK - command completed successfuly
656 *   CL2_COMMAND_BUSY - previous command not completed
657 *
658 */
659 eCL2_RESULT cl2_set_time_cobid
660    (
661    sCAN_CARD *card,           /* Pointer to card structure */
662    U32 COBID                  /* HRS frame COB-ID */
663    );
664
665
666 /*******************************************************************************
667 * cl2_set_receive_limit - set limit for receive signaling
668 * """""""""""""""""""""
669 *
670 * Command is used to set the receive limit signalized by bit
671 * RL (in CL2.H CL2_X_DATA_IN_RBUF) of the Status Register.
672 * This bit is set when more then the limit number of frames
673 * was received since the last interrupt was generated (in interrupt
674 * mode) or since the Status Register was last time read.
675 *
676 * RETURNS:
677 *   CL2_OK
678 *   CL2_COMMAND_BUSY - previous command not completed
679 *   CL2_BAD_PARAM - bad command parameter
680 */
681 eCL2_RESULT cl2_set_receive_limit
682    (
683    sCAN_CARD *card,          /* pointer to card structure */
684    U16 limit                 /* limit of messages in receive buffer */
685    );
686
687
688 /*******************************************************************************
689 * cl2_download_rtr_list - download rtr list
690 * """""""""""""""""""""
691 *
692 * Command downloads a list of up to 64 RTR frames. These frames are
693 * periodically transmitted by the card. The parameters, how often
694 * frames are send and in which SYNC period is defined by period and
695 * subperiod in sRTR_FRAME structure.
696 *
697 * RETURNS:
698 *   CL2_OK - command completed successfuly
699 *   CL2_COMMAND_BUSY - previous command not completed
700 *   CL2_BAD_PARAM - bad command parameter
701 *
702 */
703 eCL2_RESULT cl2_download_rtr_list
704    (
705    sCAN_CARD *card,           /* Pointer to card structure */
706    sRTR_LIST *rtrList         /* RTR list */
707    );
708
709
710 /*******************************************************************************
711 * cl2_subscribe_rtr - subscribe RTR frame
712 * """""""""""""""""
713 *
714 * Command subscribes RTR frame. Incoming RTR frames which were
715 * subscribed are accepted, while other are ignored. Up to 10
716 * RTR frames can be subscribed.
717 *
718 * RETURNS:
719 *   CL2_OK - command completed successfuly
720 *   CL2_COMMAND_BUSY - previous command not completed
721 *   CL2_BAD_PARAM - bad command parameter
722 *
723 */
724 eCL2_RESULT cl2_subscribe_rtr
725    (
726    sCAN_CARD *card,            /* Pointer to card structure */
727    sCAN_MESSAGE *canMessage,   /* RTR frame */
728    U16 RTRnumber               /* number of RTR */
729    );
730
731
732 /*******************************************************************************
733 * cl2_desubscribe_rtr - desubscribe rtr frame
734 * """""""""""""""""""
735 *
736 * Command desubscribes RTR frame. Card will not accept RTR frames
737 * with this identifier.
738 *
739 * RETURNS:
740 *   CL2_OK - command completed successfuly
741 *   CL2_COMMAND_BUSY - previous command not completed
742 *   CL2_BAD_PARAM - bad command parameter
743 *
744 */
745 eCL2_RESULT cl2_desubscribe_rtr
746    (
747    sCAN_CARD *card,            /* Pointer to card structure */
748    sCAN_MESSAGE *canMessage    /* RTR frame */
749    );
750
751
752 /*******************************************************************************
753 * cl2_set_sync_cobid - set COB-ID
754 * """"""""""""""""""
755 *
756 * Command sets COB-ID of SYNC frame. In active SYNC mode, the SYNC
757 * frame with this COB-ID is periodically sent with period defined
758 * by cl2_set_sync_period command.
759 *
760 * RETURNS:
761 *   CL2_OK - command completed successfuly
762 *   CL2_COMMAND_BUSY - previous command not completed
763 *
764 */
765 eCL2_RESULT cl2_set_sync_cobid
766    (
767    sCAN_CARD *card,            /* Pointer to card structure */
768    U32 COBID                   /* COB-ID */
769    );
770
771
772 /*******************************************************************************
773 * cl2_set_sync_period - set SYNC period
774 * """""""""""""""""""
775 *
776 * Coomand sets the SYNC frame send period in active SYNC mode in
777 * x100 us. The period range is from 0 to 0xFFFF (SYNC period can
778 * be set from 100us to 6.5535s).
779 *
780 * RETURNS:
781 *   CL2_OK - command completed successfuly
782 *   CL2_COMMAND_BUSY - previous command not completed
783 *
784 */
785 eCL2_RESULT cl2_set_sync_period
786    (
787    sCAN_CARD *card,            /* Pointer to card structure */
788    U16 period                  /* period in x100 us */
789    );
790
791
792 /*******************************************************************************
793 * cl2_set_sync_window - set SYNC window
794 * """""""""""""""""""
795 *
796 * Command sets the SYNC window length. Only during this time period
797 * after SYNC frame was send or receive the frames from the synchronous
798 * send buffer can be sent.
799 *
800 * RETURNS:
801 *   CL2_OK - command completed successfuly
802 *   CL2_COMMAND_BUSY - previous command not completed
803 *
804 */
805 eCL2_RESULT cl2_set_sync_window
806    (
807    sCAN_CARD *card,            /* Pointer to card structure */
808    U16 window                  /* period in x100 us */
809    );
810
811
812 /*******************************************************************************
813 * cl2_set_bitrate - set CAN bit-rate
814 * """""""""""""""
815 *
816 * Command switches the bus bit-rate. There are some predefined
817 * constants CL2_BITRATE_XXXX.
818 *
819 * RETURNS:
820 *   CL2_OK - command completed successfuly
821 *   CL2_COMMAND_BUSY - previous command not completed
822 *
823 */
824 eCL2_RESULT cl2_set_bitrate
825    (
826    sCAN_CARD *card,            /* Pointer to card structure */
827    U16 bitrate                 /* CAN bitrate */
828    );
829
830
831 /*******************************************************************************
832 * cl2_bus_reset - resets CAN controller
833 * """""""""""""
834 *
835 * Command resets CAN controller
836 *
837 * RETURNS:
838 *   CL2_OK - command completed successfuly
839 *   CL2_COMMAND_BUSY - previously command not completed
840 *
841 */
842 eCL2_RESULT cl2_bus_reset
843    (
844    sCAN_CARD *card            /* Pointer to card structure */
845    );
846
847
848 /*******************************************************************************
849 * cl2_send_sync - sends synchronous frame
850 * """""""""""""
851 *
852 * Command stores massage in synchronous send buffer.
853 *
854 * RETURNS:
855 *   CL2_OK - command completed successfuly
856 *   CL2_HW_QUEUE_FULL - synchronous send buffer is full
857 *   CL2_BAD_PARAM - bad command parameter
858 *   CL2_HW_FAILURE - error in HW configuration
859 *
860 */
861 eCL2_RESULT cl2_send_sync
862    (
863    sCAN_CARD *card,           /* Pointer to card structure */
864    sCAN_MESSAGE *message      /* message to be sent */
865    );
866
867
868 /*******************************************************************************
869 * cl2_send_async - sends asynchronous frame
870 * """"""""""""""
871 *
872 * Command stores message in asynchronous send buffer.
873 *
874 * RETURNS:
875 *   CL2_OK - command completed successfuly
876 *   CL2_HW_QUEUE_FULL - asynchronous buffer full
877 *   CL2_HW_FAILURE - error in HW configuration
878 *   CL2_BAD_PARAM - bad command parameter
879 *
880 */
881 eCL2_RESULT cl2_send_async
882    (
883    sCAN_CARD *card,           /* Pointer to card structure */
884    sCAN_MESSAGE *message      /* message */
885    );
886
887
888 /*******************************************************************************
889 * cl2_get_status - reads card status
890 * """"""""""""""
891 *
892 * Command reads card status register. If data in status register
893 * are valid (status valid flag is set), the value of status is read
894 * and stored in status and sCAN_CARD structure.
895 *
896 * RETURNS:
897 *   CL2_OK - command completed successfuly
898 *   CL2_NO_REQUEST - status is not valid
899 *
900 */
901 eCL2_RESULT cl2_get_status
902    (
903    sCAN_CARD *card,           /* Pointer to card structure */
904    U16 *status                /* Returned status */
905    );
906
907
908 /*******************************************************************************
909 * cl2_get_error - reads card error
910 * """""""""""""
911 *
912 * Command reads card error register. If data in error register
913 * are valid (error register valid flag is set), the value of error
914 * register is read and stored in error and sCAN_CARD structure.
915 *
916 * RETURNS:
917 *   Cl2_OK - command completed successfuly
918 *
919 */
920 eCL2_RESULT cl2_get_error
921    (
922    sCAN_CARD *card,           /* Pointer to card structure */
923    U16 *error                 /* Returned card error code */
924    );
925
926
927 /*******************************************************************************
928 * cl2_receive_data - reads received frame
929 * """"""""""""""""
930 *
931 * Command reads new messages received by a card.
932 *
933 * RETURNS:
934 *   CL2_OK - command commpleted successfuly
935 *   CL2_NO_REQUEST - there is no new message
936 *
937 */
938 eCL2_RESULT cl2_receive_data
939    (
940    sCAN_CARD *card,             /* Pointer to card structure */
941    sCAN_MESSAGE *canMessage     /* Message */
942    );
943
944
945 /* *********************************************************************** *
946  * END OF CL2.H                                                            *
947  * *********************************************************************** */
948
949 #endif /* ifndef __INC_CL2_H */