| 1 | /*-----------------------------------------------------------------------------
|
|---|
| 2 | can_lib.h -- Interface to CAN library
|
|---|
| 3 |
|
|---|
| 4 | Copyright (c) 1994 JANZ Computer AG
|
|---|
| 5 | All Rights Reserved
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | Created 96/01/23 by Stefan Althoefer
|
|---|
| 9 | Version 1.8 of 96/10/31
|
|---|
| 10 | -----------------------------------------------------------------------------*/
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | #ifndef can_lib_DEFINED
|
|---|
| 14 | #define can_lib_DEFINED
|
|---|
| 15 |
|
|---|
| 16 | #ifdef __cplusplus
|
|---|
| 17 | extern "C" {
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #ifdef VXWORKS
|
|---|
| 21 | #include "semLib.h"
|
|---|
| 22 | #endif
|
|---|
| 23 |
|
|---|
| 24 | #include "defs.h"
|
|---|
| 25 | #include "mican.h"
|
|---|
| 26 | #include "dpm.h"
|
|---|
| 27 | #include "vmod.h"
|
|---|
| 28 |
|
|---|
| 29 | /*------- Function Declarations ---------------------------------------------*/
|
|---|
| 30 |
|
|---|
| 31 | /* Open the device and return a descriptor. Only one process may
|
|---|
| 32 | hold the the device open at a time. */
|
|---|
| 33 | extern int can_open _PARAMS((char *));
|
|---|
| 34 | extern int can_alt_open _PARAMS((char *));
|
|---|
| 35 |
|
|---|
| 36 | /* Close a device */
|
|---|
| 37 | extern void can_close _PARAMS((int fd));
|
|---|
| 38 |
|
|---|
| 39 | /* Reset a device */
|
|---|
| 40 | extern void can_reset _PARAMS((int fd));
|
|---|
| 41 |
|
|---|
| 42 | /* Declare a signal (for OS-9 systems only) */
|
|---|
| 43 | extern int can_sigdcl _PARAMS((int fd, int pid, int sig));
|
|---|
| 44 |
|
|---|
| 45 | /* Undeclare a signal (for OS-9 systems only) */
|
|---|
| 46 | extern void can_sigdel _PARAMS((int fd));
|
|---|
| 47 |
|
|---|
| 48 | #ifdef VXWORKS
|
|---|
| 49 | /* Declare a semaphore (for VxWorks systems only) */
|
|---|
| 50 | extern SEM_ID can_semdcl _PARAMS((int fd));
|
|---|
| 51 |
|
|---|
| 52 | /* Delete a semaphore (for VxWorks systems only) */
|
|---|
| 53 | extern void can_semdel _PARAMS((int fd));
|
|---|
| 54 | #endif
|
|---|
| 55 |
|
|---|
| 56 | /* Receive a message from a module */
|
|---|
| 57 | extern int can_recv _PARAMS((int fd, Message *pm));
|
|---|
| 58 |
|
|---|
| 59 | /* Receive a fast message from a module */
|
|---|
| 60 | extern int can_recv_fast _PARAMS((int fd, FastMessage *pm));
|
|---|
| 61 |
|
|---|
| 62 | /* Send a middle prior message to a module */
|
|---|
| 63 | extern int can_send _PARAMS((int fd, Message *pm));
|
|---|
| 64 |
|
|---|
| 65 | /* Send a high prior message to a module */
|
|---|
| 66 | extern int can_send_hi _PARAMS((int fd, Message *pm));
|
|---|
| 67 |
|
|---|
| 68 | /* Send a low_prior message to a module */
|
|---|
| 69 | extern int can_send_low _PARAMS((int fd, Message *pm));
|
|---|
| 70 |
|
|---|
| 71 | /* Send a fast message to a module */
|
|---|
| 72 | extern int can_fast_send _PARAMS((int fd, FastMessage *pm));
|
|---|
| 73 |
|
|---|
| 74 | /* Send a fast message to a module */
|
|---|
| 75 | extern int can_fast_send_prio _PARAMS((int fd, int prioQueue, FastMessage *pm));
|
|---|
| 76 |
|
|---|
| 77 | /* One communication step (MS-DOS systems only) */
|
|---|
| 78 | extern void can_comm _PARAMS((int fd));
|
|---|
| 79 |
|
|---|
| 80 | /* Switch to new stylish hostinterface */
|
|---|
| 81 | extern void ican2_select_hostif _PARAMS((int fd, int rbuffers, int wbuffers));
|
|---|
| 82 |
|
|---|
| 83 | /* Switch to new stylish hostinterface with dedicated priorized-messsage- */
|
|---|
| 84 | /* buffer-size */
|
|---|
| 85 | extern void ican2_select_hostif_prio _PARAMS((int fd, int rbuffers,
|
|---|
| 86 | int wbuffers, int wbuffers_hi, int wbuffers_low));
|
|---|
| 87 |
|
|---|
| 88 | /* Init fast CANbus access */
|
|---|
| 89 | extern int ican2_init_fast_can _PARAMS((int fd, int rbuffers, int wbuffers));
|
|---|
| 90 |
|
|---|
| 91 | /* Init fast CANbus access */
|
|---|
| 92 | extern int ican2_init_fast_can_prio _PARAMS((int fd, int rbuffers, int wbuffers,
|
|---|
| 93 | int numOfPrioQueues));
|
|---|
| 94 |
|
|---|
| 95 | /* Copy a block of data to the DPM */
|
|---|
| 96 | extern void ican2_todpmcpy _PARAMS((int fd, unsigned int d,
|
|---|
| 97 | unsigned char *s, int n));
|
|---|
| 98 |
|
|---|
| 99 | /* Copy a block of data from the DPM */
|
|---|
| 100 | extern void ican2_fromdpmcpy _PARAMS((int fd, unsigned char *d,
|
|---|
| 101 | unsigned int s, int n));
|
|---|
| 102 |
|
|---|
| 103 | /* Initialize table; holds Id-specific message-queue-ids, where */
|
|---|
| 104 | /* fast messages with the corresponding ID should be routed to are stored */
|
|---|
| 105 | extern int init_id_msg_q_table(int fd);
|
|---|
| 106 |
|
|---|
| 107 | /* Deinitialize above described table */
|
|---|
| 108 | extern int deinit_id_msg_q_table(int fd);
|
|---|
| 109 |
|
|---|
| 110 | /* Enter one message-queue-id into the above described table. */
|
|---|
| 111 | /* this entry causes a message-sending not to the default, common queue */
|
|---|
| 112 | /* but to a user defined queue */
|
|---|
| 113 | int add_msg_q_to_id_table(
|
|---|
| 114 | #ifdef VXWORKS
|
|---|
| 115 | int fd,
|
|---|
| 116 | unsigned short id,
|
|---|
| 117 | MSG_Q_ID target_queue
|
|---|
| 118 | #endif
|
|---|
| 119 | #ifdef LINUX
|
|---|
| 120 | int fd,
|
|---|
| 121 | unsigned short id
|
|---|
| 122 | #endif
|
|---|
| 123 | );
|
|---|
| 124 |
|
|---|
| 125 | /* removes one entry like above described */
|
|---|
| 126 | int rem_msg_q_from_id_table(
|
|---|
| 127 | int fd,
|
|---|
| 128 | unsigned short id
|
|---|
| 129 | );
|
|---|
| 130 |
|
|---|
| 131 | /* Initialize table; holds device and ID where messages from this device */
|
|---|
| 132 | /* and with a certain CAN-ID should be routed to. */
|
|---|
| 133 | extern int can_init_layer_2_routing _PARAMS((int fd));
|
|---|
| 134 |
|
|---|
| 135 | /* Deinitialize above described table */
|
|---|
| 136 | extern int can_deinit_layer_2_routing _PARAMS((int fd));
|
|---|
| 137 |
|
|---|
| 138 | /* */
|
|---|
| 139 | extern int can_init_route_id _PARAMS((
|
|---|
| 140 | int fd,
|
|---|
| 141 | int Id,
|
|---|
| 142 | int max_routes
|
|---|
| 143 | ));
|
|---|
| 144 |
|
|---|
| 145 | /* */
|
|---|
| 146 | extern int can_add_route_to_id _PARAMS((
|
|---|
| 147 | int fd,
|
|---|
| 148 | int source_Id,
|
|---|
| 149 | int dest_fd,
|
|---|
| 150 | int dest_Id
|
|---|
| 151 | ));
|
|---|
| 152 |
|
|---|
| 153 | /* */
|
|---|
| 154 | extern unsigned int can_drv_idvers _PARAMS((
|
|---|
| 155 | int fd
|
|---|
| 156 | ));
|
|---|
| 157 |
|
|---|
| 158 | /* initiate a tpu request */
|
|---|
| 159 | extern void ican2_tpurequest _PARAMS((int fd));
|
|---|
| 160 |
|
|---|
| 161 | extern void ican_objdic _PARAMS((
|
|---|
| 162 | int fd,
|
|---|
| 163 | int objdic_index,
|
|---|
| 164 | int objdic_subindex,
|
|---|
| 165 | int access_type,
|
|---|
| 166 | void *entry_structure
|
|---|
| 167 | ));
|
|---|
| 168 |
|
|---|
| 169 | extern int ican_read_pp _PARAMS((
|
|---|
| 170 | int fd,
|
|---|
| 171 | int dataSize,
|
|---|
| 172 | int offset,
|
|---|
| 173 | char *buffer
|
|---|
| 174 | ));
|
|---|
| 175 |
|
|---|
| 176 | extern void ican_write_pp _PARAMS((
|
|---|
| 177 | int fd,
|
|---|
| 178 | int dataSize,
|
|---|
| 179 | int offset,
|
|---|
| 180 | char *buffer
|
|---|
| 181 | ));
|
|---|
| 182 |
|
|---|
| 183 | #ifdef __cplusplus
|
|---|
| 184 | }
|
|---|
| 185 | #endif
|
|---|
| 186 |
|
|---|
| 187 | #endif /* !can_lib_DEFINED */
|
|---|