91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

STM32 自定義HID 設備, 通過快傳輸接收上位機發來的數據。上位機使用Libusb庫函數實現,接口簡單。程序中添加了上位機接收數據的接口,USB 設備端的IN 接口也做好了,用戶只要將需要發送給HOST的數據添加進去就可以了。博文地址: http://blog.csdn.net/chengwenyang/article/details/51039741

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?

#include?“libusb.h“

#define?VID?0x8888
#define?PID?0x0088

#define?edp2in?0x82
#define?edp2out?0x02

int?main(void)
{
????libusb_device?**devs?*dev;
????int?ret?i;
????ssize_t?cnt;
????usb_pro_t?usb_pro;
????struct?libusb_device_handle?*handle?=?NULL;
????libusb_context?*ctx?=?NULL;

????ret?=?libusb_init(&ctx);
????if?(ret?????????return?-1;

????libusb_set_debug(ctx?3);

????cnt?=?libusb_get_device_list(NULL?&devs);
????if?(cnt?????????printf(“no?usb?dev?on?bus\r\n“);
????????return??-1;
????}

????i?=?0;
????while((dev?=?devs[i++])?!=?NULL)?{

????????ret?=?libusb_get_device_descriptor(dev&desc);
????????if?(ret?????????????printf(“failed?to?get?device?descriptor“);
????????????goto?error;
????????}

????????if?((desc.idVendor?==?VID)?&&?(desc.idProduct?==?PID))?{
????????????printf(“bLength:?0x%04x\r\n“?desc.bLength);
????????????printf(“bDescriptorType:?0x%04x\r\n“?desc.bDescriptorType);
????????????printf(“bcdUSB:?0x%04x\r\n“?desc.bcdUSB);
????????????printf(“bDeviceClass:?0x%04x\r\n“?desc.bDeviceClass);
????????????printf(“bDeviceSubClass:?0x%04x\r\n“?desc.bDeviceSubClass);
????????????printf(“bDeviceProtocol:?0x%04x\r\n“?desc.bDeviceProtocol);
????????????printf(“bMaxPacketSize0:?0x%04x\r\n“?desc.bMaxPacketSize0);
????????????printf(“vendor?id:?0x%04x\r\n“?desc.idVendor);
????????????printf(“product?id:?0x%04x\r\n“?desc.idProduct);
????????????printf(“bcdDevice:?0x%04x\r\n“?desc.bcdDevice);
????????????printf(“iManufacturer:?0x%04x\r\n“?desc.iManufacturer);
????????????printf(“iProduct:?0x%04x\r\n“?desc.iProduct);
????????????printf(“iSerialNumber:?0x%04x\r\n“?desc.iSerialNumber);
????????????printf(“bNumConfigurations:?0x%04x\r\n“?desc.bNumConfigurations);

????????}

????}

????handle?=?libusb_open_device_with_vid_pid(ctx?VID?PID);

????if?(handle?==?NULL)?{
????????printf(“cant‘t?open?device\r\n“);
????????goto?error;
????}?else?{
????????printf(“open?device\r\n“);
????}

????libusb_free_device_list(devs?1);

????if?(libusb_kernel_driver_active(handle?0)?==1)?{
????????printf(“kernel?driver?active?detach?it?\r\n“);

????????if?(libusb_detach_kernel_driver(handle?0)?==?0)?{
????????????printf(“detached?kernel?driver\r\n“);
????????}
????????else?{
????????????goto?error;
????????}
????}

????ret?=?libusb_claim_interface(handle?0);
????if?(ret?????????printf(“can‘t?claim?interface\r\n“);
????????goto?error;
????}?else?{
????????printf(“claimed?interface\r\n“);
????}

????char?data[64];
????int?actual_len?=?0;
????int?didi?=?1000;
????for?(int?i?=?0;?i????????memset(data?0?sizeof(data));
????????/*??receive?data?from?device??*/
????????/*
????????ret?=?libusb_bulk_transfer(handle?edp2in?data?64?&actual_len?0);

????????if?(actual_len?=?0)?{
????????????printf(“received?nothing\r\n“);

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-04-02?11:20??libsub_app\
?????文件????????3584??2016-04-02?12:44??libsub_app\main.c
?????文件?????????469??2016-04-02?12:43??libsub_app\makefile
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\
?????文件???????51511??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\CMSIS?END?USER?LICENCE?AGREEMENT.pdf
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Include\
?????文件??????637870??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Include\stm32f10x.h
?????文件????????2220??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Include\system_stm32f10x.h
?????文件???????34574??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Release_Notes.html
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TASKING\
?????文件????????3675??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TASKING\cstart_thumb2.asm
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\
?????文件???????12739??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_cl.s
?????文件???????12727??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_hd.s
?????文件???????12374??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_hd_vl.s
?????文件????????9961??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_ld.s
?????文件???????10410??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_ld_vl.s
?????文件???????10410??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_md.s
?????文件???????10892??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_md_vl.s
?????文件???????13387??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\TrueSTUDIO\startup_stm32f10x_xl.s
?????目錄???????????0??2016-04-02?11:21??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\arm\
?????文件???????15896??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\arm\startup_stm32f10x_cl.s
?????文件???????15633??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\arm\startup_stm32f10x_hd.s
?????文件???????15822??2012-03-22?22:44??stm32usb_bulk_transfer\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\arm\startup_stm32f10x_hd_vl.s
............此處省略488個文件信息

評論

共有 條評論