5e4f61e6f9560e09c93fe00c5af5bbc8824878f9
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)
40 //ret = cp210x_ctlmsg(port, 0xff, 0xc0, 0x00c2, 0, gpio, 1);
48 /* Get current GPIO register from PL2303 */
49 char gpio_read_reg(usb_dev_handle
*h
)
52 int bytes
= usb_control_msg(
53 h
, // handle obtained with usb_open()
58 &buf
, // pointer to destination buffer
73 void gpio_write_reg(usb_dev_handle
*h
, uint16_t reg
)
75 int bytes
= usb_control_msg(
76 h
, // handle obtained with usb_open()
81 0, // pointer to destination buffer
89 void gpio_out(usb_dev_handle
*h
, int gnum
, int value
)
97 gpio
|= (GPIO_0
<< 8);
102 gpio
|= (GPIO_1
<< 8);
107 gpio
|= (GPIO_2
<< 8);
112 gpio
|= (GPIO_3
<< 8);
115 gpio_write_reg(h
, gpio
);
118 void gpio_in(usb_dev_handle
*h
, int gpio
, int pullup
)
120 printf("FixMe: don't know how to make pins input on cp2103\n");
123 int gpio_read(usb_dev_handle
*h
, int gpio
)
125 printf("FixMe: don't know how to read pins on cp2103\n");
129 extern usb_dev_handle
*nc_usb_open(int vendor
, int product
,
130 const char *vendor_name
, const char *product_name
, const char *serial
);
131 void check_handle(usb_dev_handle
**h
, const char* manuf
, const char* product
, const char* serial
)
136 *h
= nc_usb_open(I_VENDOR_NUM
, I_PRODUCT_NUM
, manuf
, product
, serial
);
138 fprintf(stderr
, "No CP2103 USB device %04x:%04x found ;(\n", I_VENDOR_NUM
, I_PRODUCT_NUM
);