SDG+USBHost(Mouse) Sample

Dependencies:   Sound_Generator USBHost_custom

Fork of SDG_Mouse_Sample by GR-PEACH_producer_meeting

Information

Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.

What is this?

This program is a demonstration that sounds the sound by mouse operation by using USBHost(Mouse) and Sound Generator.

Settings

Close JP3 of GR-PEACH.
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

Operation

operationeffect
Right clickSounds
Left clickReset to base tone (C)
Moves the mouse to the rightLower the sound
Moves the mouse to the leftHigher the sound
Center cursorAdjust the sensitivity.
Reset the reference value in the click.

Others

The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication


概要

このプログラムは、USBHost(Mouse) + Sound Generatorで、マウス操作による擬似笛デモです。

設定

GR-PEACHのJP3をショートする必要があります。
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

操作方法

操作内容
右クリック音出力開始
左クリック基準音(ド)にリセット
マウス右移動高音になります
マウス左移動低音になります
センターカーソル音高低の変化量調整(クリックで基準値にリセット)

Others

mbedのシリアル通信(ボーレート等)のデフォルト設定は以下のリンクに示しています。
リンクを参考に、お使いのPCターミナルソフトの設定を変更して下さい。
mbedでのボーレートのデフォルト値は9600で、このサンプルではボーレート9600を使います。
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Revision:
4:b320d68e98e7
Parent:
0:a554658735bf
Child:
6:1571e517a91b
--- a/USBHost/USBHost.h	Wed Mar 06 17:50:07 2013 +0000
+++ b/USBHost/USBHost.h	Tue Mar 12 17:23:37 2013 +0000
@@ -156,6 +156,7 @@
      *  register a driver into the host associated with a callback function called when the device is disconnected
      *
      *  @param dev device
+     *  @param intf interface number
      *  @param tptr pointer to the object to call the member function on
      *  @param mptr pointer to the member function to be called
      */
@@ -163,8 +164,8 @@
     inline void registerDriver(USBDeviceConnected * dev, uint8_t intf, T* tptr, void (T::*mptr)(void)) {
         int index = findDevice(dev);
         if ((index != -1) && (mptr != NULL) && (tptr != NULL)) {
-            USB_DBG("register driver for dev: %p", dev);
-            deviceAttachedDriver[index] = true;
+            USB_DBG("register driver for dev: %p on intf: %d", dev, intf);
+            deviceAttachedDriver[index][intf] = true;
             dev->onDisconnect(intf, tptr, mptr);
         }
     }
@@ -173,13 +174,14 @@
      * register a driver into the host associated with a callback function called when the device is disconnected
      *
      * @param dev device
+     * @param intf interface number
      * @param fn callback called when the specified device has been disconnected
      */
     inline void registerDriver(USBDeviceConnected * dev, uint8_t intf, void (*fn)(void)) {
         int index = findDevice(dev);
         if ((index != -1) && (fn != NULL)) {
-            USB_DBG("register driver for dev: %p", dev);
-            deviceAttachedDriver[index] = true;
+            USB_DBG("register driver for dev: %p on intf: %d", dev, intf);
+            deviceAttachedDriver[index][intf] = true;
             dev->onDisconnect(intf, fn);
         }
     }
@@ -244,8 +246,9 @@
     // devices connected
     USBDeviceConnected devices[MAX_DEVICE_CONNECTED];
     volatile bool  deviceInUse[MAX_DEVICE_CONNECTED];
-    volatile bool  deviceAttachedDriver[MAX_DEVICE_CONNECTED];
+    volatile bool  deviceAttachedDriver[MAX_DEVICE_CONNECTED][MAX_INTF];
     volatile bool  deviceReset[MAX_DEVICE_CONNECTED];
+    volatile bool  deviceInited[MAX_DEVICE_CONNECTED];
     
 #if MAX_HUB_NB
     USBHostHub hubs[MAX_HUB_NB];
@@ -273,7 +276,7 @@
     Mutex usb_mutex;
     
     // buffer for conf descriptor
-    uint8_t data[400];
+    uint8_t data[300];
     
     /**
     * Add a transfer on the TD linked list associated to an ED
@@ -365,6 +368,7 @@
     void parseConfDescr(USBDeviceConnected * dev, uint8_t * conf_descr, uint32_t len, IUSBEnumerator* pEnumerator) ;
     int findDevice(USBDeviceConnected * dev) ;
     int findDevice(uint8_t hub, uint8_t port, USBHostHub * hub_parent = NULL) ;
+    uint8_t numberDriverAttached(USBDeviceConnected * dev);
 
     /////////////////////////
     /// FOR DEBUG
@@ -374,4 +378,3 @@
 };
 
 #endif
-