うおーるぼっとを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 USBHOSTMSD_H
jksoft 0:fccb789424fc 18 #define USBHOSTMSD_H
jksoft 0:fccb789424fc 19
jksoft 0:fccb789424fc 20 #include "USBHostConf.h"
jksoft 0:fccb789424fc 21
jksoft 0:fccb789424fc 22 #if USBHOST_MSD
jksoft 0:fccb789424fc 23
jksoft 0:fccb789424fc 24 #include "USBHost.h"
jksoft 0:fccb789424fc 25 #include "FATFileSystem.h"
jksoft 0:fccb789424fc 26
jksoft 0:fccb789424fc 27 /**
jksoft 0:fccb789424fc 28 * A class to communicate a USB flash disk
jksoft 0:fccb789424fc 29 */
jksoft 0:fccb789424fc 30 class USBHostMSD : public IUSBEnumerator, public FATFileSystem {
jksoft 0:fccb789424fc 31 public:
jksoft 0:fccb789424fc 32 /**
jksoft 0:fccb789424fc 33 * Constructor
jksoft 0:fccb789424fc 34 *
jksoft 0:fccb789424fc 35 * @param rootdir mount name
jksoft 0:fccb789424fc 36 */
jksoft 0:fccb789424fc 37 USBHostMSD(const char * rootdir);
jksoft 0:fccb789424fc 38
jksoft 0:fccb789424fc 39 /**
jksoft 0:fccb789424fc 40 * Check if a MSD device is connected
jksoft 0:fccb789424fc 41 *
jksoft 0:fccb789424fc 42 * @return true if a MSD device is connected
jksoft 0:fccb789424fc 43 */
jksoft 0:fccb789424fc 44 bool connected();
jksoft 0:fccb789424fc 45
jksoft 0:fccb789424fc 46 /**
jksoft 0:fccb789424fc 47 * Try to connect to a MSD device
jksoft 0:fccb789424fc 48 *
jksoft 0:fccb789424fc 49 * @return true if connection was successful
jksoft 0:fccb789424fc 50 */
jksoft 0:fccb789424fc 51 bool connect();
jksoft 0:fccb789424fc 52
jksoft 0:fccb789424fc 53 protected:
jksoft 0:fccb789424fc 54 //From IUSBEnumerator
jksoft 0:fccb789424fc 55 virtual void setVidPid(uint16_t vid, uint16_t pid);
jksoft 0:fccb789424fc 56 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
jksoft 0:fccb789424fc 57 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
jksoft 0:fccb789424fc 58
jksoft 0:fccb789424fc 59 // From FATFileSystem
jksoft 0:fccb789424fc 60 virtual int disk_initialize();
jksoft 0:fccb789424fc 61 virtual int disk_status() {return 0;};
jksoft 0:fccb789424fc 62 virtual int disk_read(uint8_t * buffer, uint64_t sector);
jksoft 0:fccb789424fc 63 virtual int disk_write(const uint8_t * buffer, uint64_t sector);
jksoft 0:fccb789424fc 64 virtual int disk_sync() {return 0;};
jksoft 0:fccb789424fc 65 virtual uint64_t disk_sectors();
jksoft 0:fccb789424fc 66
jksoft 0:fccb789424fc 67 private:
jksoft 0:fccb789424fc 68 USBHost * host;
jksoft 0:fccb789424fc 69 USBDeviceConnected * dev;
jksoft 0:fccb789424fc 70 bool dev_connected;
jksoft 0:fccb789424fc 71 USBEndpoint * bulk_in;
jksoft 0:fccb789424fc 72 USBEndpoint * bulk_out;
jksoft 0:fccb789424fc 73 uint8_t nb_ep;
jksoft 0:fccb789424fc 74
jksoft 0:fccb789424fc 75 // Bulk-only CBW
jksoft 0:fccb789424fc 76 typedef __packed struct {
jksoft 0:fccb789424fc 77 uint32_t Signature;
jksoft 0:fccb789424fc 78 uint32_t Tag;
jksoft 0:fccb789424fc 79 uint32_t DataLength;
jksoft 0:fccb789424fc 80 uint8_t Flags;
jksoft 0:fccb789424fc 81 uint8_t LUN;
jksoft 0:fccb789424fc 82 uint8_t CBLength;
jksoft 0:fccb789424fc 83 uint8_t CB[16];
jksoft 0:fccb789424fc 84 } CBW;
jksoft 0:fccb789424fc 85
jksoft 0:fccb789424fc 86 // Bulk-only CSW
jksoft 0:fccb789424fc 87 typedef __packed struct {
jksoft 0:fccb789424fc 88 uint32_t Signature;
jksoft 0:fccb789424fc 89 uint32_t Tag;
jksoft 0:fccb789424fc 90 uint32_t DataResidue;
jksoft 0:fccb789424fc 91 uint8_t Status;
jksoft 0:fccb789424fc 92 } CSW;
jksoft 0:fccb789424fc 93
jksoft 0:fccb789424fc 94 CBW cbw;
jksoft 0:fccb789424fc 95 CSW csw;
jksoft 0:fccb789424fc 96
jksoft 0:fccb789424fc 97 int SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t * data, uint32_t transfer_len);
jksoft 0:fccb789424fc 98 int testUnitReady();
jksoft 0:fccb789424fc 99 int readCapacity();
jksoft 0:fccb789424fc 100 int inquiry(uint8_t lun, uint8_t page_code);
jksoft 0:fccb789424fc 101 int SCSIRequestSense();
jksoft 0:fccb789424fc 102 int dataTransfer(uint8_t * buf, uint32_t block, uint8_t nbBlock, int direction);
jksoft 0:fccb789424fc 103 int checkResult(uint8_t res, USBEndpoint * ep);
jksoft 0:fccb789424fc 104 int getMaxLun();
jksoft 0:fccb789424fc 105
jksoft 0:fccb789424fc 106 int blockSize;
jksoft 0:fccb789424fc 107 uint64_t blockCount;
jksoft 0:fccb789424fc 108
jksoft 0:fccb789424fc 109 int msd_intf;
jksoft 0:fccb789424fc 110 bool msd_device_found;
jksoft 0:fccb789424fc 111 bool disk_init;
jksoft 0:fccb789424fc 112
jksoft 0:fccb789424fc 113 void init();
jksoft 0:fccb789424fc 114
jksoft 0:fccb789424fc 115 };
jksoft 0:fccb789424fc 116
jksoft 0:fccb789424fc 117 #endif
jksoft 0:fccb789424fc 118
jksoft 0:fccb789424fc 119 #endif