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:
24:868cbfe611a7
Parent:
13:b58a2204422f
--- a/USBHost/USBHostTypes.h	Fri Mar 07 16:00:46 2014 +0000
+++ b/USBHost/USBHostTypes.h	Tue Jun 03 11:30:38 2014 +0100
@@ -67,28 +67,28 @@
 #define HUB_CLASS       0x09
 #define SERIAL_CLASS    0x0A
 
-// ------------------ HcControl Register ---------------------  
+// ------------------ HcControl Register ---------------------
 #define  OR_CONTROL_PLE                 0x00000004
 #define  OR_CONTROL_CLE                 0x00000010
 #define  OR_CONTROL_BLE                 0x00000020
 #define  OR_CONTROL_HCFS                0x000000C0
 #define  OR_CONTROL_HC_OPER             0x00000080
-// ----------------- HcCommandStatus Register ----------------- 
+// ----------------- HcCommandStatus Register -----------------
 #define  OR_CMD_STATUS_HCR              0x00000001
 #define  OR_CMD_STATUS_CLF              0x00000002
 #define  OR_CMD_STATUS_BLF              0x00000004
-// --------------- HcInterruptStatus Register ----------------- 
+// --------------- HcInterruptStatus Register -----------------
 #define  OR_INTR_STATUS_WDH             0x00000002
 #define  OR_INTR_STATUS_RHSC            0x00000040
 #define  OR_INTR_STATUS_UE              0x00000010
-// --------------- HcInterruptEnable Register ----------------- 
+// --------------- HcInterruptEnable Register -----------------
 #define  OR_INTR_ENABLE_WDH             0x00000002
 #define  OR_INTR_ENABLE_RHSC            0x00000040
 #define  OR_INTR_ENABLE_MIE             0x80000000
-// ---------------- HcRhDescriptorA Register ------------------ 
+// ---------------- HcRhDescriptorA Register ------------------
 #define  OR_RH_STATUS_LPSC              0x00010000
 #define  OR_RH_STATUS_DRWE              0x00008000
-// -------------- HcRhPortStatus[1:NDP] Register -------------- 
+// -------------- HcRhPortStatus[1:NDP] Register --------------
 #define  OR_RH_PORT_CCS                 0x00000001
 #define  OR_RH_PORT_PRS                 0x00000010
 #define  OR_RH_PORT_CSC                 0x00010000
@@ -100,14 +100,14 @@
 
 #define  ED_SKIP            (uint32_t) (0x00001000)        // Skip this ep in queue
 
-#define  TD_ROUNDING        (uint32_t) (0x00040000)        // Buffer Rounding                             
-#define  TD_SETUP           (uint32_t)(0)                  // Direction of Setup Packet                   
-#define  TD_IN              (uint32_t)(0x00100000)         // Direction In                                
-#define  TD_OUT             (uint32_t)(0x00080000)         // Direction Out                               
-#define  TD_DELAY_INT(x)    (uint32_t)((x) << 21)          // Delay Interrupt                             
-#define  TD_TOGGLE_0        (uint32_t)(0x02000000)         // Toggle 0                                    
-#define  TD_TOGGLE_1        (uint32_t)(0x03000000)         // Toggle 1                                    
-#define  TD_CC              (uint32_t)(0xF0000000)         // Completion Code                             
+#define  TD_ROUNDING        (uint32_t) (0x00040000)        // Buffer Rounding
+#define  TD_SETUP           (uint32_t)(0)                  // Direction of Setup Packet
+#define  TD_IN              (uint32_t)(0x00100000)         // Direction In
+#define  TD_OUT             (uint32_t)(0x00080000)         // Direction Out
+#define  TD_DELAY_INT(x)    (uint32_t)((x) << 21)          // Delay Interrupt
+#define  TD_TOGGLE_0        (uint32_t)(0x02000000)         // Toggle 0
+#define  TD_TOGGLE_1        (uint32_t)(0x03000000)         // Toggle 1
+#define  TD_CC              (uint32_t)(0xF0000000)         // Completion Code
 
 #define  DEVICE_DESCRIPTOR                     (1)
 #define  CONFIGURATION_DESCRIPTOR              (2)
@@ -115,7 +115,7 @@
 #define  ENDPOINT_DESCRIPTOR                   (5)
 #define  HID_DESCRIPTOR                        (33)
 
-//  ----------- Control RequestType Fields  ----------- 
+//  ----------- Control RequestType Fields  -----------
 #define  USB_DEVICE_TO_HOST         0x80
 #define  USB_HOST_TO_DEVICE         0x00
 #define  USB_REQUEST_TYPE_CLASS     0x20
@@ -124,14 +124,14 @@
 #define  USB_RECIPIENT_INTERFACE    0x01
 #define  USB_RECIPIENT_ENDPOINT     0x02
 
-// -------------- USB Standard Requests  -------------- 
+// -------------- USB Standard Requests  --------------
 #define  SET_ADDRESS                0x05
 #define  GET_DESCRIPTOR             0x06
 #define  SET_CONFIGURATION          0x09
 #define  SET_INTERFACE              0x0b
 #define  CLEAR_FEATURE              0x01
 
-// -------------- USB Descriptor Length  -------------- 
+// -------------- USB Descriptor Length  --------------
 #define DEVICE_DESCRIPTOR_LENGTH            0x12
 #define CONFIGURATION_DESCRIPTOR_LENGTH     0x09
 
@@ -145,7 +145,7 @@
     uint32_t dummy[3];              // padding
 } PACKED HCTD;
 
-// ----------- HostController EndPoint Descriptor ------------- 
+// ----------- HostController EndPoint Descriptor -------------
 typedef struct hcEd {
     __IO  uint32_t  control;        // Endpoint descriptor control
     __IO  HCTD *  tailTD;           // Physical address of tail in Transfer descriptor list
@@ -154,73 +154,73 @@
 } PACKED HCED;
 
 
-// ----------- Host Controller Communication Area ------------  
+// ----------- Host Controller Communication Area ------------
 typedef struct hcca {
     __IO  uint32_t  IntTable[32];   // Interrupt Table
     __IO  uint32_t  FrameNumber;    // Frame Number
     __IO  uint32_t  DoneHead;       // Done Head
-    volatile  uint8_t   Reserved[116];  // Reserved for future use                                  
-    volatile  uint8_t   Unknown[4];     // Unused                                                   
+    volatile  uint8_t   Reserved[116];  // Reserved for future use
+    volatile  uint8_t   Unknown[4];     // Unused
 } PACKED HCCA;
 
 typedef struct {
-    uint8_t bLength;            
-    uint8_t bDescriptorType;    
-    uint16_t bcdUSB;            
-    uint8_t bDeviceClass;       
-    uint8_t bDeviceSubClass;    
-    uint8_t bDeviceProtocol;    
-    uint8_t bMaxPacketSize;     
-    uint16_t idVendor;          
-    uint16_t idProduct;         
-    uint16_t bcdDevice;         
-    uint8_t iManufacturer;      
-    uint8_t iProduct;           
-    uint8_t iSerialNumber;      
-    uint8_t bNumConfigurations; 
+    uint8_t bLength;
+    uint8_t bDescriptorType;
+    uint16_t bcdUSB;
+    uint8_t bDeviceClass;
+    uint8_t bDeviceSubClass;
+    uint8_t bDeviceProtocol;
+    uint8_t bMaxPacketSize;
+    uint16_t idVendor;
+    uint16_t idProduct;
+    uint16_t bcdDevice;
+    uint8_t iManufacturer;
+    uint8_t iProduct;
+    uint8_t iSerialNumber;
+    uint8_t bNumConfigurations;
 } PACKED DeviceDescriptor;
 
 typedef struct {
-    uint8_t bLength;               
-    uint8_t bDescriptorType;       
-    uint16_t wTotalLength;         
-    uint8_t bNumInterfaces;        
-    uint8_t bConfigurationValue;   
-    uint8_t iConfiguration;        
-    uint8_t bmAttributes;          
-    uint8_t bMaxPower;             
-} PACKED ConfigurationDescriptor; 
+    uint8_t bLength;
+    uint8_t bDescriptorType;
+    uint16_t wTotalLength;
+    uint8_t bNumInterfaces;
+    uint8_t bConfigurationValue;
+    uint8_t iConfiguration;
+    uint8_t bmAttributes;
+    uint8_t bMaxPower;
+} PACKED ConfigurationDescriptor;
 
 typedef struct {
-    uint8_t bLength;                 
-    uint8_t bDescriptorType;   
-    uint8_t bInterfaceNumber;  
-    uint8_t bAlternateSetting; 
-    uint8_t bNumEndpoints;     
-    uint8_t bInterfaceClass;   
+    uint8_t bLength;
+    uint8_t bDescriptorType;
+    uint8_t bInterfaceNumber;
+    uint8_t bAlternateSetting;
+    uint8_t bNumEndpoints;
+    uint8_t bInterfaceClass;
     uint8_t bInterfaceSubClass;
     uint8_t bInterfaceProtocol;
-    uint8_t iInterface;        
-} InterfaceDescriptor; 
+    uint8_t iInterface;
+} InterfaceDescriptor;
 
 typedef struct {
-    uint8_t bLength;          
-    uint8_t bDescriptorType;  
-    uint8_t bEndpointAddress; 
-    uint8_t bmAttributes;     
-    uint16_t wMaxPacketSize;  
-    uint8_t bInterval;        
+    uint8_t bLength;
+    uint8_t bDescriptorType;
+    uint8_t bEndpointAddress;
+    uint8_t bmAttributes;
+    uint16_t wMaxPacketSize;
+    uint8_t bInterval;
 } EndpointDescriptor;
 
 typedef struct {
-    uint8_t bDescLength;      
-    uint8_t bDescriptorType;  
-    uint8_t bNbrPorts;        
+    uint8_t bDescLength;
+    uint8_t bDescriptorType;
+    uint8_t bNbrPorts;
     uint16_t wHubCharacteristics;
-    uint8_t bPwrOn2PwrGood;   
-    uint8_t bHubContrCurrent; 
-    uint8_t DeviceRemovable;  
-    uint8_t PortPweCtrlMak;   
-} HubDescriptor;              
+    uint8_t bPwrOn2PwrGood;
+    uint8_t bHubContrCurrent;
+    uint8_t DeviceRemovable;
+    uint8_t PortPweCtrlMak;
+} HubDescriptor;
 
 #endif