| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
int usb_get_paths( |
| 23 |
icompaths *p |
| 24 |
) { |
| 25 |
int w0 = 0, dk; |
| 26 |
|
| 27 |
#ifdef EN_LIBUSB0 |
| 28 |
w0 = usb_get_paths_w0(p); |
| 29 |
# ifndef EN_USBDK |
| 30 |
return w0; |
| 31 |
# endif |
| 32 |
#endif |
| 33 |
|
| 34 |
#ifdef EN_USBDK |
| 35 |
dk = usb_get_paths_dk(p); |
| 36 |
# ifdef EN_LIBUSB0 |
| 37 |
if (dk != 0) |
| 38 |
return w0; |
| 39 |
# endif |
| 40 |
return dk; |
| 41 |
#endif |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
int usb_copy_usb_idevice(icoms *d, icompath *s) { |
| 46 |
if (s->usbd == NULL) { |
| 47 |
d->usbd = NULL; |
| 48 |
return ICOM_OK; |
| 49 |
} |
| 50 |
#ifdef EN_USBDK |
| 51 |
if (s->usbd->is_dk) |
| 52 |
return usb_copy_usb_idevice_dk(d, s); |
| 53 |
#endif |
| 54 |
#ifdef EN_LIBUSB0 |
| 55 |
return usb_copy_usb_idevice_w0(d, s); |
| 56 |
#endif |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
void usb_del_usb_idevice(struct usb_idevice *usbd) { |
| 61 |
if (usbd == NULL) |
| 62 |
return; |
| 63 |
#ifdef EN_USBDK |
| 64 |
if (usbd->is_dk) { |
| 65 |
usb_del_usb_idevice_dk(usbd); |
| 66 |
return; |
| 67 |
} |
| 68 |
#endif |
| 69 |
#ifdef EN_LIBUSB0 |
| 70 |
usb_del_usb_idevice_w0(usbd); |
| 71 |
#endif |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
void usb_del_usb(icoms *p) { |
| 76 |
if (p->usbd == NULL) |
| 77 |
return; |
| 78 |
#ifdef EN_USBDK |
| 79 |
if (p->usbd->is_dk) { |
| 80 |
usb_del_usb_dk(p); |
| 81 |
return; |
| 82 |
} |
| 83 |
#endif |
| 84 |
#ifdef EN_LIBUSB0 |
| 85 |
usb_del_usb_w0(p); |
| 86 |
#endif |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
void usb_close_port(icoms *p) { |
| 91 |
if (p->usbd == NULL) |
| 92 |
return; |
| 93 |
#ifdef EN_USBDK |
| 94 |
if (p->usbd->is_dk) { |
| 95 |
usb_close_port_dk(p); |
| 96 |
return; |
| 97 |
} |
| 98 |
#endif |
| 99 |
#ifdef EN_LIBUSB0 |
| 100 |
usb_close_port_w0(p); |
| 101 |
#endif |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
static int usb_open_port( |
| 106 |
icoms *p, |
| 107 |
int config, |
| 108 |
int wr_ep, |
| 109 |
int rd_ep, |
| 110 |
icomuflags usbflags, |
| 111 |
int retries, |
| 112 |
char **pnames |
| 113 |
) { |
| 114 |
#ifdef EN_USBDK |
| 115 |
if (p->usbd->is_dk) |
| 116 |
return usb_open_port_dk(p, config, wr_ep, rd_ep, usbflags, retries, pnames); |
| 117 |
#endif |
| 118 |
#ifdef EN_LIBUSB0 |
| 119 |
return usb_open_port_w0(p, config, wr_ep, rd_ep, usbflags, retries, pnames); |
| 120 |
#endif |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
static int icoms_usb_transaction( |
| 127 |
icoms *p, |
| 128 |
usb_cancelt *cancelt, |
| 129 |
int *transferred, |
| 130 |
icom_usb_trantype ttype, |
| 131 |
unsigned char endpoint, |
| 132 |
unsigned char *buffer, |
| 133 |
int length, |
| 134 |
unsigned int timeout |
| 135 |
) { |
| 136 |
#ifdef EN_USBDK |
| 137 |
if (p->usbd->is_dk) |
| 138 |
return icoms_usb_transaction_dk(p, cancelt, transferred, ttype, endpoint, buffer, length, timeout); |
| 139 |
#endif |
| 140 |
#ifdef EN_LIBUSB0 |
| 141 |
return icoms_usb_transaction_w0(p, cancelt, transferred, ttype, endpoint, buffer, length, timeout); |
| 142 |
#endif |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
static int icoms_usb_control_msg( |
| 147 |
icoms *p, |
| 148 |
int *transferred, |
| 149 |
int requesttype, |
| 150 |
int request, |
| 151 |
int value, |
| 152 |
int index, |
| 153 |
unsigned char *bytes, |
| 154 |
int size, |
| 155 |
int timeout |
| 156 |
) { |
| 157 |
#ifdef EN_USBDK |
| 158 |
if (p->usbd->is_dk) |
| 159 |
return icoms_usb_control_msg_dk(p, transferred, requesttype, request, value, index, bytes, size, timeout); |
| 160 |
#endif |
| 161 |
#ifdef EN_LIBUSB0 |
| 162 |
return icoms_usb_control_msg_w0(p, transferred, requesttype, request, value, index, bytes, size, timeout); |
| 163 |
#endif |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
int icoms_usb_cancel_io( |
| 168 |
icoms *p, |
| 169 |
usb_cancelt *cancelt |
| 170 |
) { |
| 171 |
#ifdef EN_USBDK |
| 172 |
if (p->usbd->is_dk) |
| 173 |
return icoms_usb_cancel_io_dk(p, cancelt); |
| 174 |
#endif |
| 175 |
#ifdef EN_LIBUSB0 |
| 176 |
return icoms_usb_cancel_io_w0(p, cancelt); |
| 177 |
#endif |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
int icoms_usb_resetep( |
| 182 |
icoms *p, |
| 183 |
int ep |
| 184 |
) { |
| 185 |
#ifdef EN_USBDK |
| 186 |
if (p->usbd->is_dk) |
| 187 |
return icoms_usb_resetep_dk(p, ep); |
| 188 |
#endif |
| 189 |
#ifdef EN_LIBUSB0 |
| 190 |
return icoms_usb_resetep_w0(p, ep); |
| 191 |
#endif |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
int icoms_usb_clearhalt( |
| 196 |
icoms *p, |
| 197 |
int ep |
| 198 |
) { |
| 199 |
#ifdef EN_USBDK |
| 200 |
if (p->usbd->is_dk) |
| 201 |
return icoms_usb_clearhalt_dk(p, ep); |
| 202 |
#endif |
| 203 |
#ifdef EN_LIBUSB0 |
| 204 |
return icoms_usb_clearhalt_w0(p, ep); |
| 205 |
#endif |
| 206 |
} |
| 207 |
|