1(foreign-declare "#include <libusb.h>")
2
3(define-foreign-type vid unsigned-short)
4(define-foreign-type pid unsigned-short)
5
6(define-foreign-type libusb-ctx (c-pointer "libusb_context"))
7(define-foreign-type libusb-handle (c-pointer "libusb_device_handle"))
8
9(define libusb-init
10 (foreign-lambda void "libusb_init" (c-pointer libusb-ctx)))
11(define libusb-open
12 (foreign-lambda libusb-handle "libusb_open_device_with_vid_pid" libusb-ctx vid pid))
13(define libusb-auto-detach
14 (foreign-lambda void "libusb_set_auto_detach_kernel_driver" libusb-handle int))
15
16(define libusb-claim
17 (foreign-lambda int "libusb_claim_interface" libusb-handle int))
18(define libusb-release
19 (foreign-lambda int "libusb_release_interface" libusb-handle int))
20
21(define libusb-irq-transfer
22 (foreign-lambda
23 int
24 "libusb_interrupt_transfer"
25 libusb-handle
26 unsigned-byte
27 nonnull-u8vector
28 int
29 (c-pointer int)
30 unsigned-int))
31
32(define libusb-close
33 (foreign-lambda void "libusb_close" libusb-handle))
34(define libusb-exit
35 (foreign-lambda void "libusb_exit" libusb-ctx))