root/pic/test/libusb/pickit2/pickit2.c

Revision 27, 0.7 kB (checked in by naoya_t, 17 years ago)
Line 
1#include <stdio.h>
2#include <usb.h>
3
4#define PRODUCT_ID 0x0033
5#define VENDOR_ID  0x04d8
6// serial = PIC18F2550
7
8main()
9{
10  struct usb_bus *bus;
11  struct usb_device *dev;
12  usb_dev_handle *dh;
13
14  usb_init();
15  usb_find_busses();
16  usb_find_devices();
17
18  for (bus = usb_get_busses(); bus; bus = bus->next) {
19        for (dev = bus->devices; dev; dev = dev->next) {
20          if (dev->descriptor.idVendor == VENDOR_ID &&
21                  dev->descriptor.idProduct == PRODUCT_ID) {
22            goto device_found;
23          }
24        }
25  }
26  /* デバイスが見つからなかった場合 */
27  fprintf(stderr, "Device not found.\n");
28  exit(1);
29  /* デバイスが見つかった場合 */
30 device_found:
31  printf("Device Found!!\n"); /* 確認用*/
32}
Note: See TracBrowser for help on using the browser.