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

Committer:
samux
Date:
Thu Mar 14 11:49:53 2013 +0000
Revision:
8:93da8ea2708b
Parent:
4:b320d68e98e7
Child:
24:868cbfe611a7
update doc + license

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 8:93da8ea2708b 1 /* mbed USBHost Library
samux 8:93da8ea2708b 2 * Copyright (c) 2006-2013 ARM Limited
samux 8:93da8ea2708b 3 *
samux 8:93da8ea2708b 4 * Licensed under the Apache License, Version 2.0 (the "License");
samux 8:93da8ea2708b 5 * you may not use this file except in compliance with the License.
samux 8:93da8ea2708b 6 * You may obtain a copy of the License at
samux 8:93da8ea2708b 7 *
samux 8:93da8ea2708b 8 * http://www.apache.org/licenses/LICENSE-2.0
samux 8:93da8ea2708b 9 *
samux 8:93da8ea2708b 10 * Unless required by applicable law or agreed to in writing, software
samux 8:93da8ea2708b 11 * distributed under the License is distributed on an "AS IS" BASIS,
samux 8:93da8ea2708b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
samux 8:93da8ea2708b 13 * See the License for the specific language governing permissions and
samux 8:93da8ea2708b 14 * limitations under the License.
samux 8:93da8ea2708b 15 */
mbed_official 0:a554658735bf 16
mbed_official 0:a554658735bf 17 #ifndef USBHALHOST_H
mbed_official 0:a554658735bf 18 #define USBHALHOST_H
mbed_official 0:a554658735bf 19
mbed_official 0:a554658735bf 20 #include "USBHostTypes.h"
mbed_official 0:a554658735bf 21 #include "USBHostConf.h"
mbed_official 0:a554658735bf 22
mbed_official 0:a554658735bf 23 class USBHostHub;
mbed_official 0:a554658735bf 24
samux 8:93da8ea2708b 25 /**
samux 8:93da8ea2708b 26 * USBHALHost class
samux 8:93da8ea2708b 27 */
mbed_official 0:a554658735bf 28 class USBHALHost {
samux 8:93da8ea2708b 29 protected:
mbed_official 0:a554658735bf 30
mbed_official 0:a554658735bf 31 /**
mbed_official 0:a554658735bf 32 * Constructor
mbed_official 0:a554658735bf 33 * init variables and memory where will be stored HCCA, ED and TD
mbed_official 0:a554658735bf 34 */
mbed_official 0:a554658735bf 35 USBHALHost();
mbed_official 0:a554658735bf 36
mbed_official 0:a554658735bf 37 /**
mbed_official 0:a554658735bf 38 * Initialize host controller. Enable USB interrupts. This part is not in the constructor because,
mbed_official 0:a554658735bf 39 * this function calls a virtual method if a device is already connected
mbed_official 0:a554658735bf 40 */
mbed_official 0:a554658735bf 41 void init();
mbed_official 0:a554658735bf 42
mbed_official 0:a554658735bf 43 /**
mbed_official 0:a554658735bf 44 * reset the root hub
mbed_official 0:a554658735bf 45 */
mbed_official 0:a554658735bf 46 void resetRootHub();
mbed_official 0:a554658735bf 47
mbed_official 0:a554658735bf 48 /**
mbed_official 0:a554658735bf 49 * return the value contained in the control HEAD ED register
mbed_official 0:a554658735bf 50 *
mbed_official 0:a554658735bf 51 * @returns address of the control Head ED
mbed_official 0:a554658735bf 52 */
mbed_official 0:a554658735bf 53 uint32_t controlHeadED();
mbed_official 0:a554658735bf 54
mbed_official 0:a554658735bf 55 /**
mbed_official 0:a554658735bf 56 * return the value contained in the bulk HEAD ED register
mbed_official 0:a554658735bf 57 *
mbed_official 0:a554658735bf 58 * @returns address of the bulk head ED
mbed_official 0:a554658735bf 59 */
mbed_official 0:a554658735bf 60 uint32_t bulkHeadED();
mbed_official 0:a554658735bf 61
mbed_official 0:a554658735bf 62 /**
mbed_official 0:a554658735bf 63 * return the value of the head interrupt ED contained in the HCCA
mbed_official 0:a554658735bf 64 *
mbed_official 0:a554658735bf 65 * @returns address of the head interrupt ED contained in the HCCA
mbed_official 0:a554658735bf 66 */
mbed_official 0:a554658735bf 67 uint32_t interruptHeadED();
mbed_official 0:a554658735bf 68
mbed_official 0:a554658735bf 69 /**
mbed_official 0:a554658735bf 70 * Update the head ED for control transfers
mbed_official 0:a554658735bf 71 */
mbed_official 0:a554658735bf 72 void updateControlHeadED(uint32_t addr);
mbed_official 0:a554658735bf 73
mbed_official 0:a554658735bf 74 /**
mbed_official 0:a554658735bf 75 * Update the head ED for bulk transfers
mbed_official 0:a554658735bf 76 */
mbed_official 0:a554658735bf 77 void updateBulkHeadED(uint32_t addr);
mbed_official 0:a554658735bf 78
mbed_official 0:a554658735bf 79 /**
mbed_official 0:a554658735bf 80 * Update the head ED for interrupt transfers
mbed_official 0:a554658735bf 81 */
mbed_official 0:a554658735bf 82 void updateInterruptHeadED(uint32_t addr);
mbed_official 0:a554658735bf 83
samux 8:93da8ea2708b 84 /**
mbed_official 0:a554658735bf 85 * Enable List for the specified endpoint type
samux 8:93da8ea2708b 86 *
samux 8:93da8ea2708b 87 * @param type enable the list of ENDPOINT_TYPE type
mbed_official 0:a554658735bf 88 */
mbed_official 0:a554658735bf 89 void enableList(ENDPOINT_TYPE type);
mbed_official 0:a554658735bf 90
mbed_official 0:a554658735bf 91 /**
mbed_official 0:a554658735bf 92 * Disable List for the specified endpoint type
samux 8:93da8ea2708b 93 *
samux 8:93da8ea2708b 94 * @param type disable the list of ENDPOINT_TYPE type
mbed_official 0:a554658735bf 95 */
mbed_official 0:a554658735bf 96 bool disableList(ENDPOINT_TYPE type);
mbed_official 0:a554658735bf 97
mbed_official 0:a554658735bf 98 /**
mbed_official 0:a554658735bf 99 * Virtual method called when a device has been connected
mbed_official 0:a554658735bf 100 *
mbed_official 0:a554658735bf 101 * @param hub hub number of the device
mbed_official 0:a554658735bf 102 * @param port port number of the device
mbed_official 0:a554658735bf 103 * @param lowSpeed 1 if low speed, 0 otherwise
mbed_official 0:a554658735bf 104 * @param hub_parent reference to the hub where the device is connected (NULL if the hub parent is the root hub)
mbed_official 0:a554658735bf 105 */
samux 8:93da8ea2708b 106 virtual void deviceConnected(int hub, int port, bool lowSpeed, USBHostHub * hub_parent = NULL) = 0;
mbed_official 0:a554658735bf 107
mbed_official 0:a554658735bf 108 /**
mbed_official 0:a554658735bf 109 * Virtual method called when a device has been disconnected
mbed_official 0:a554658735bf 110 *
mbed_official 0:a554658735bf 111 * @param hub hub number of the device
mbed_official 0:a554658735bf 112 * @param port port number of the device
mbed_official 0:a554658735bf 113 * @param hub_parent reference to the hub where the device is connected (NULL if the hub parent is the root hub)
mbed_official 0:a554658735bf 114 * @param addr list of the TDs which have been completed to dequeue freed TDs
mbed_official 0:a554658735bf 115 */
samux 8:93da8ea2708b 116 virtual void deviceDisconnected(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr) = 0;
mbed_official 0:a554658735bf 117
mbed_official 0:a554658735bf 118 /**
mbed_official 0:a554658735bf 119 * Virtual method called when a transfer has been completed
mbed_official 0:a554658735bf 120 *
mbed_official 0:a554658735bf 121 * @param addr list of the TDs which have been completed
mbed_official 0:a554658735bf 122 */
samux 8:93da8ea2708b 123 virtual void transferCompleted(volatile uint32_t addr) = 0;
mbed_official 0:a554658735bf 124
mbed_official 0:a554658735bf 125 /**
mbed_official 0:a554658735bf 126 * Find a memory section for a new ED
mbed_official 0:a554658735bf 127 *
samux 8:93da8ea2708b 128 * @returns the address of the new ED
mbed_official 0:a554658735bf 129 */
mbed_official 0:a554658735bf 130 volatile uint8_t * getED();
mbed_official 0:a554658735bf 131
mbed_official 0:a554658735bf 132 /**
mbed_official 0:a554658735bf 133 * Find a memory section for a new TD
mbed_official 0:a554658735bf 134 *
samux 8:93da8ea2708b 135 * @returns the address of the new TD
mbed_official 0:a554658735bf 136 */
mbed_official 0:a554658735bf 137 volatile uint8_t * getTD();
mbed_official 0:a554658735bf 138
mbed_official 0:a554658735bf 139 /**
mbed_official 0:a554658735bf 140 * Release a previous memory section reserved for an ED
mbed_official 0:a554658735bf 141 *
mbed_official 0:a554658735bf 142 * @param ed address of the ED
mbed_official 0:a554658735bf 143 */
mbed_official 0:a554658735bf 144 void freeED(volatile uint8_t * ed);
mbed_official 0:a554658735bf 145
mbed_official 0:a554658735bf 146 /**
mbed_official 0:a554658735bf 147 * Release a previous memory section reserved for an TD
mbed_official 0:a554658735bf 148 *
samux 2:5e8fdc541b98 149 * @param td address of the TD
mbed_official 0:a554658735bf 150 */
mbed_official 0:a554658735bf 151 void freeTD(volatile uint8_t * td);
mbed_official 0:a554658735bf 152
mbed_official 0:a554658735bf 153 private:
mbed_official 0:a554658735bf 154 static void _usbisr(void);
mbed_official 0:a554658735bf 155 void UsbIrqhandler();
mbed_official 0:a554658735bf 156
mbed_official 0:a554658735bf 157 void memInit();
mbed_official 0:a554658735bf 158
mbed_official 0:a554658735bf 159 HCCA volatile * usb_hcca; //256 bytes aligned
mbed_official 0:a554658735bf 160 uint8_t volatile * usb_edBuf; //4 bytes aligned
mbed_official 0:a554658735bf 161 uint8_t volatile * usb_tdBuf; //4 bytes aligned
mbed_official 0:a554658735bf 162
mbed_official 0:a554658735bf 163 static USBHALHost * instHost;
mbed_official 0:a554658735bf 164
mbed_official 0:a554658735bf 165 bool volatile edBufAlloc[MAX_ENDPOINT];
mbed_official 0:a554658735bf 166 bool volatile tdBufAlloc[MAX_TD];
mbed_official 0:a554658735bf 167 };
mbed_official 0:a554658735bf 168
mbed_official 0:a554658735bf 169 #endif