SDG+USBHost(Mouse) Sample
Dependencies: Sound_Generator USBHost_custom
Fork of SDG_Mouse_Sample by
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.
Operation
| operation | effect |
|---|---|
| Right click | Sounds |
| Left click | Reset to base tone (C) |
| Moves the mouse to the right | Lower the sound |
| Moves the mouse to the left | Higher the sound |
| Center cursor | Adjust 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をショートする必要があります。
操作方法
| 操作 | 内容 |
|---|---|
| 右クリック | 音出力開始 |
| 左クリック | 基準音(ド)にリセット |
| マウス右移動 | 高音になります |
| マウス左移動 | 低音になります |
| センターカーソル | 音高低の変化量調整(クリックで基準値にリセット) |
Others
mbedのシリアル通信(ボーレート等)のデフォルト設定は以下のリンクに示しています。
リンクを参考に、お使いのPCターミナルソフトの設定を変更して下さい。
mbedでのボーレートのデフォルト値は9600で、このサンプルではボーレート9600を使います。
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication
Diff: USBHostSerial/USBHostSerial.h
- Revision:
- 24:868cbfe611a7
- Parent:
- 19:bd46ea19486b
--- a/USBHostSerial/USBHostSerial.h Fri Mar 07 16:00:46 2014 +0000
+++ b/USBHostSerial/USBHostSerial.h Tue Jun 03 11:30:38 2014 +0100
@@ -25,7 +25,7 @@
#include "Stream.h"
#include "MtxCircBuffer.h"
-/**
+/**
* A class to communicate a USB virtual serial port
*/
class USBHostSerialPort : public Stream {
@@ -39,7 +39,7 @@
RxIrq,
TxIrq
};
-
+
enum Parity {
None = 0,
Odd,
@@ -48,7 +48,7 @@
Space
};
- void connect(USBHost* _host, USBDeviceConnected * _dev,
+ void connect(USBHost* _host, USBDeviceConnected * _dev,
uint8_t _serial_intf, USBEndpoint* _bulk_in, USBEndpoint* _bulk_out);
/**
@@ -56,7 +56,7 @@
*
* @returns the number of bytes available
*/
- uint8_t available();
+ uint8_t available();
/**
* Attach a member function to call when a packet is received.
@@ -90,13 +90,13 @@
}
}
}
-
+
/** Set the baud rate of the serial port
*
* @param baudrate The baudrate of the serial port (default = 9600).
*/
void baud(int baudrate = 9600);
-
+
/** Set the transmission format used by the Serial port
*
* @param bits The number of bits in a word (default = 8)
@@ -110,7 +110,7 @@
protected:
virtual int _getc();
virtual int _putc(int c);
-
+
private:
USBHost * host;
USBDeviceConnected * dev;
@@ -132,7 +132,7 @@
uint8_t parity;
uint8_t data_bits;
} PACKED LINE_CODING;
-
+
LINE_CODING line_coding;
void rxHandler();
@@ -145,18 +145,18 @@
#if (USBHOST_SERIAL <= 1)
-class USBHostSerial : public IUSBEnumerator, public USBHostSerialPort
+class USBHostSerial : public IUSBEnumerator, public USBHostSerialPort
{
-public:
+public:
USBHostSerial();
-
+
/**
* Try to connect a serial device
*
* @return true if connection was successful
*/
bool connect();
-
+
void disconnect();
/**
@@ -165,7 +165,7 @@
* @returns true if a serial device is connected
*/
bool connected();
-
+
protected:
USBHost* host;
USBDeviceConnected* dev;
@@ -176,7 +176,7 @@
virtual void setVidPid(uint16_t vid, uint16_t pid);
virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
-
+
private:
bool dev_connected;
};
@@ -184,13 +184,13 @@
#else // (USBHOST_SERIAL > 1)
class USBHostMultiSerial : public IUSBEnumerator {
-public:
+public:
USBHostMultiSerial();
virtual ~USBHostMultiSerial();
-
- USBHostSerialPort* getPort(int port)
- {
- return port < USBHOST_SERIAL ? ports[port] : NULL;
+
+ USBHostSerialPort* getPort(int port)
+ {
+ return port < USBHOST_SERIAL ? ports[port] : NULL;
}
/**
@@ -199,7 +199,7 @@
* @return true if connection was successful
*/
bool connect();
-
+
void disconnect();
/**
@@ -208,7 +208,7 @@
* @returns true if a serial device is connected
*/
bool connected();
-
+
protected:
USBHost* host;
USBDeviceConnected* dev;
@@ -220,7 +220,7 @@
virtual void setVidPid(uint16_t vid, uint16_t pid);
virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
-
+
private:
bool dev_connected;
};
