うおーるぼっとをWiiリモコンでコントロールする新しいプログラムです。 以前のものより、Wiiリモコンが早く繋がる様になりました。 It is a program which controls A with the Wii remote. ※ A Bluetooth dongle and a Wii remote control are needed.

Dependencies:   USBHost mbed FATFileSystem mbed-rtos

Committer:
jksoft
Date:
Mon Jun 10 16:01:50 2013 +0000
Revision:
0:fccb789424fc
1.0

Who changed what in which revision?

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