顯示具有 Bus Hound 標籤的文章。 顯示所有文章
顯示具有 Bus Hound 標籤的文章。 顯示所有文章

2016年6月16日 星期四

Bus Hound USB Get_Descriptor Command之分析

使用Bus Hound 發送Get_Descriptor command

目前先將實驗解果稍作分析,未來對USB有更深入的了解後,有機會在更新這部分的資料。

  • Cmd: 80 06 00 01 00 00 FF 00

Value: 00 01
USB回傳訊息:會回傳USB的Device Descriptor,裡面包含了VID&PID的資料。

Device Descriptor 內容可對照usb_2.0 spec 表9-8。


  • Cmd: 80 06 00 02 00 00 FF 00
Value: 00 01
USB回傳訊息:會回傳HID configuration descriptor,可以看出此裝置是甚麼樣的device(Mouse, Keyboard...)。
HID Configuration descriptor的架構如下
Configuration descriptor
...Interface descriptor
......HID descriptor
.........Endpoint descriptor (for HID interrupt IN Endpoint)
.........Optional Endpoint descriptor (for HID interrupt Out Endpoint)

詳細內容可參考usb_2.0 spec 
9.6.3 Configuration
9.6.5 Interface
9.6.6 Endpoint


  • Cmd: 80 06 01 03 00 00 FF 00~80 06 05 03 00 00 FF 00
此command可以取得儲存在USB的string。

2016年6月15日 星期三

STM32F4XX USB 透過 Bus Hound 存取 HidRaw Device

本篇參考假濕汀的Blogger,並修改文章中所提供的範例程式,透過Bus Hound監聽軟體來驗證傳輸資料是否正確。

由於原作者範例只能將hidraw中的資料由Device端送至PC端,無法由PC端送資料至Device端,因此這裡將介紹如何解決此問題,由於USB這邊是第一次接觸,還有很多不了解的地方,有問題還請各位前輩可以提出來。

假濕汀的Blogger:
http://iamjustinwang.blogspot.tw/2015/11/stm32f401411-hid-testkeyboard-mouse.html
程式連結:
STM32FXXX_HID

修改部分:

  • usbd_hid_core.c:增加USB_HID_DataOut function





  • USBD_HID_CfgDesc array中需修改項目

原程式中只有一個input Endpoint,因此須改改interface中定義Endpoint的數量。

增加Output Endpoint Descriptor


  • main.c


  • Bus Hound驗證:
    • 1.點選interrupt Out
    • 2.輸入要送至Device端的資料與資料大小
    • 3.點選Run,將資料送出
由上圖可觀察到,送出資料後,讀出hidraw data為PC端所輸入的資料,我們已成功將資料送至Device端。