うおーるぼっとをiPhoneでコントロールするプログラムです。 iPhoneとはBTLEで接続しています。

Dependencies:   FatFileSystem HighSpeedAnalogIn TB6612FNG2 mbed

Committer:
jksoft
Date:
Fri May 10 11:48:07 2013 +0000
Revision:
0:373bcb197dc8
?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:373bcb197dc8 1
jksoft 0:373bcb197dc8 2 /*
jksoft 0:373bcb197dc8 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
jksoft 0:373bcb197dc8 4
jksoft 0:373bcb197dc8 5 Permission is hereby granted, free of charge, to any person obtaining a copy
jksoft 0:373bcb197dc8 6 of this software and associated documentation files (the "Software"), to deal
jksoft 0:373bcb197dc8 7 in the Software without restriction, including without limitation the rights
jksoft 0:373bcb197dc8 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jksoft 0:373bcb197dc8 9 copies of the Software, and to permit persons to whom the Software is
jksoft 0:373bcb197dc8 10 furnished to do so, subject to the following conditions:
jksoft 0:373bcb197dc8 11
jksoft 0:373bcb197dc8 12 The above copyright notice and this permission notice shall be included in
jksoft 0:373bcb197dc8 13 all copies or substantial portions of the Software.
jksoft 0:373bcb197dc8 14
jksoft 0:373bcb197dc8 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jksoft 0:373bcb197dc8 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jksoft 0:373bcb197dc8 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jksoft 0:373bcb197dc8 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jksoft 0:373bcb197dc8 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jksoft 0:373bcb197dc8 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jksoft 0:373bcb197dc8 21 THE SOFTWARE.
jksoft 0:373bcb197dc8 22 */
jksoft 0:373bcb197dc8 23
jksoft 0:373bcb197dc8 24 #ifndef USB_ENDPOINT_H
jksoft 0:373bcb197dc8 25 #define USB_ENDPOINT_H
jksoft 0:373bcb197dc8 26
jksoft 0:373bcb197dc8 27 #include "mbed.h"
jksoft 0:373bcb197dc8 28 #include "UsbInc.h"
jksoft 0:373bcb197dc8 29 #include "Usb_td.h"
jksoft 0:373bcb197dc8 30
jksoft 0:373bcb197dc8 31 class UsbDevice;
jksoft 0:373bcb197dc8 32
jksoft 0:373bcb197dc8 33 enum UsbEndpointType
jksoft 0:373bcb197dc8 34 {
jksoft 0:373bcb197dc8 35 USB_CONTROL,
jksoft 0:373bcb197dc8 36 USB_BULK,
jksoft 0:373bcb197dc8 37 USB_INT,
jksoft 0:373bcb197dc8 38 USB_ISO
jksoft 0:373bcb197dc8 39 };
jksoft 0:373bcb197dc8 40
jksoft 0:373bcb197dc8 41 class UsbEndpoint
jksoft 0:373bcb197dc8 42 {
jksoft 0:373bcb197dc8 43 public:
jksoft 0:373bcb197dc8 44 UsbEndpoint( UsbDevice* pDevice, uint8_t ep, bool dir, UsbEndpointType type, uint16_t size, int addr = -1 );
jksoft 0:373bcb197dc8 45 ~UsbEndpoint();
jksoft 0:373bcb197dc8 46 void UsbEndpoint_iso(UsbDevice* pDevice, uint8_t ep, bool dir, UsbEndpointType type, uint16_t size, int addr);
jksoft 0:373bcb197dc8 47
jksoft 0:373bcb197dc8 48 void setNextToken(uint32_t token); //Only for control Eps
jksoft 0:373bcb197dc8 49
jksoft 0:373bcb197dc8 50 UsbErr transfer(volatile uint8_t* buf, uint32_t len);
jksoft 0:373bcb197dc8 51 UsbErr transfer(uint16_t frame, int count, volatile uint8_t* buf, int len); // for isochronous
jksoft 0:373bcb197dc8 52 int m_itdActive;
jksoft 0:373bcb197dc8 53 tdqueue <HCITD*> queue_done_itd;
jksoft 0:373bcb197dc8 54 int status(); //return UsbErr or transfered len
jksoft 0:373bcb197dc8 55
jksoft 0:373bcb197dc8 56 void updateAddr(int addr);
jksoft 0:373bcb197dc8 57 void updateSize(uint16_t size);
jksoft 0:373bcb197dc8 58
jksoft 0:373bcb197dc8 59 //void setOnCompletion( void(*pCb)completed() );
jksoft 0:373bcb197dc8 60 class CDummy;
jksoft 0:373bcb197dc8 61 template <class T>
jksoft 0:373bcb197dc8 62 void setOnCompletion( T* pCbItem, void (T::*pCbMeth)() )
jksoft 0:373bcb197dc8 63 {
jksoft 0:373bcb197dc8 64 m_pCbItem = (CDummy*) pCbItem;
jksoft 0:373bcb197dc8 65 m_pCbMeth = (void (CDummy::*)()) pCbMeth;
jksoft 0:373bcb197dc8 66 }
jksoft 0:373bcb197dc8 67
jksoft 0:373bcb197dc8 68 //static void completed(){}
jksoft 0:373bcb197dc8 69
jksoft 0:373bcb197dc8 70 protected:
jksoft 0:373bcb197dc8 71 void onCompletion();
jksoft 0:373bcb197dc8 72 public:
jksoft 0:373bcb197dc8 73 static void sOnCompletion(uint32_t pTd);
jksoft 0:373bcb197dc8 74
jksoft 0:373bcb197dc8 75 private:
jksoft 0:373bcb197dc8 76 friend class UsbDevice;
jksoft 0:373bcb197dc8 77
jksoft 0:373bcb197dc8 78 UsbDevice* m_pDevice;
jksoft 0:373bcb197dc8 79
jksoft 0:373bcb197dc8 80 bool m_dir;
jksoft 0:373bcb197dc8 81 bool m_setup;
jksoft 0:373bcb197dc8 82 UsbEndpointType m_type;
jksoft 0:373bcb197dc8 83
jksoft 0:373bcb197dc8 84 //bool m_done;
jksoft 0:373bcb197dc8 85 volatile bool m_result;
jksoft 0:373bcb197dc8 86 volatile int m_status;
jksoft 0:373bcb197dc8 87
jksoft 0:373bcb197dc8 88 volatile uint32_t m_len;
jksoft 0:373bcb197dc8 89
jksoft 0:373bcb197dc8 90 volatile uint8_t* m_pBufStartPtr;
jksoft 0:373bcb197dc8 91
jksoft 0:373bcb197dc8 92 volatile HCED* m_pEd; //Ep descriptor
jksoft 0:373bcb197dc8 93
jksoft 0:373bcb197dc8 94 volatile HCTD* m_pTdHead; //Head trf descriptor
jksoft 0:373bcb197dc8 95 volatile HCTD* m_pTdTail; //Tail trf descriptor
jksoft 0:373bcb197dc8 96
jksoft 0:373bcb197dc8 97 CDummy* m_pCbItem;
jksoft 0:373bcb197dc8 98 void (CDummy::*m_pCbMeth)();
jksoft 0:373bcb197dc8 99 };
jksoft 0:373bcb197dc8 100 #endif