3 /* According to POSIX.1-2001 */
4 #include <sys/select.h>
20 #define I_VENDOR_NUM 0x10c4
21 #define I_PRODUCT_NUM 0xea60
24 #define VENDOR_READ_REQUEST_TYPE 0xc0
25 #define VENDOR_READ_REQUEST 0x01
27 #define VENDOR_WRITE_REQUEST_TYPE 0x40
28 #define VENDOR_WRITE_REQUEST 0x01
35 #define GPIO_MASK (GPIO_0|GPIO_1|GPIO_2|GPIO_3)
51 //ret = cp210x_ctlmsg(port, 0xff, 0xc0, 0x00c2, 0, gpio, 1);
59 /* Get current GPIO register from PL2303 */
60 char gpio_read_reg(libusb_device_handle
*h
)
63 int bytes
= libusb_control_transfer(
64 h
, // handle obtained with usb_open()
69 &buf
, // pointer to destination buffer
84 void gpio_write_reg(libusb_device_handle
*h
, uint16_t reg
)
86 int bytes
= libusb_control_transfer(
87 h
, // handle obtained with usb_open()
92 0, // pointer to destination buffer
100 void gpio_out(libusb_device_handle
*h
, int gnum
, int value
)
108 gpio
|= (GPIO_0
<< 8);
113 gpio
|= (GPIO_1
<< 8);
118 gpio
|= (GPIO_2
<< 8);
123 gpio
|= (GPIO_3
<< 8);
126 gpio_write_reg(h
, gpio
);
129 void gpio_in(libusb_device_handle
*h
, int gpio
, int pullup
)
131 printf("FixMe: don't know how to make pins input on cp2103\n");
134 int gpio_read(libusb_device_handle
*h
, int gpio
)
136 printf("FixMe: don't know how to read pins on cp2103\n");