BLE demo for mbed Ported RunningElectronics's SBDBT firmware for BLE. It can communicate with iOS

Dependencies:   FatFileSystem mbed

Fork of BTstack by Norimasa Okamoto

Committer:
todotani
Date:
Wed Feb 20 14:18:38 2013 +0000
Revision:
6:cf06ba884429
Parent:
0:1ed23ab1345f
Change tick timer to 1ms. Change attribute 0xFFF1 as read of DigitalIn p5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:1ed23ab1345f 1
va009039 0:1ed23ab1345f 2 /*
va009039 0:1ed23ab1345f 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
va009039 0:1ed23ab1345f 4
va009039 0:1ed23ab1345f 5 Permission is hereby granted, free of charge, to any person obtaining a copy
va009039 0:1ed23ab1345f 6 of this software and associated documentation files (the "Software"), to deal
va009039 0:1ed23ab1345f 7 in the Software without restriction, including without limitation the rights
va009039 0:1ed23ab1345f 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
va009039 0:1ed23ab1345f 9 copies of the Software, and to permit persons to whom the Software is
va009039 0:1ed23ab1345f 10 furnished to do so, subject to the following conditions:
va009039 0:1ed23ab1345f 11
va009039 0:1ed23ab1345f 12 The above copyright notice and this permission notice shall be included in
va009039 0:1ed23ab1345f 13 all copies or substantial portions of the Software.
va009039 0:1ed23ab1345f 14
va009039 0:1ed23ab1345f 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
va009039 0:1ed23ab1345f 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
va009039 0:1ed23ab1345f 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
va009039 0:1ed23ab1345f 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
va009039 0:1ed23ab1345f 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
va009039 0:1ed23ab1345f 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
va009039 0:1ed23ab1345f 21 THE SOFTWARE.
va009039 0:1ed23ab1345f 22 */
va009039 0:1ed23ab1345f 23
va009039 0:1ed23ab1345f 24 #ifndef USB_DEVICE_H
va009039 0:1ed23ab1345f 25 #define USB_DEVICE_H
va009039 0:1ed23ab1345f 26
va009039 0:1ed23ab1345f 27 #include "mbed.h"
va009039 0:1ed23ab1345f 28 #include "UsbInc.h"
va009039 0:1ed23ab1345f 29 #include "UsbEndpoint.h"
va009039 0:1ed23ab1345f 30 #include "UsbHostMgr.h"
va009039 0:1ed23ab1345f 31
va009039 0:1ed23ab1345f 32 class UsbHostMgr;
va009039 0:1ed23ab1345f 33 class UsbEndpoint;
va009039 0:1ed23ab1345f 34
va009039 0:1ed23ab1345f 35 class UsbDevice
va009039 0:1ed23ab1345f 36 {
va009039 0:1ed23ab1345f 37 protected:
va009039 0:1ed23ab1345f 38 UsbDevice( UsbHostMgr* pMgr, int hub, int port, int addr );
va009039 0:1ed23ab1345f 39 ~UsbDevice();
va009039 0:1ed23ab1345f 40
va009039 0:1ed23ab1345f 41 UsbErr enumerate();
va009039 0:1ed23ab1345f 42
va009039 0:1ed23ab1345f 43 public:
va009039 0:1ed23ab1345f 44 bool connected();
va009039 0:1ed23ab1345f 45 bool enumerated();
va009039 0:1ed23ab1345f 46
va009039 0:1ed23ab1345f 47 int getPid();
va009039 0:1ed23ab1345f 48 int getVid();
va009039 0:1ed23ab1345f 49
va009039 0:1ed23ab1345f 50 //UsbErr getConfigurationDescriptor(int config, uint8_t** pBuf);
va009039 0:1ed23ab1345f 51 //UsbErr getInterfaceDescriptor(int config, int item, uint8_t** pBuf);
va009039 0:1ed23ab1345f 52
va009039 0:1ed23ab1345f 53 UsbErr setConfiguration(int config);
va009039 0:1ed23ab1345f 54
va009039 0:1ed23ab1345f 55 UsbErr controlSend(byte requestType, byte request, word value, word index, const byte* buf, int len);
va009039 0:1ed23ab1345f 56 UsbErr controlReceive(byte requestType, byte request, word value, word index, const byte* buf, int len);
va009039 0:1ed23ab1345f 57 UsbErr GetDescriptor(int type, int index, const byte* buf, int len);
va009039 0:1ed23ab1345f 58 UsbErr GetString(int index, char* buf, int len);
va009039 0:1ed23ab1345f 59 UsbErr SetInterfaceAlternate(int interface, int alternate);
va009039 0:1ed23ab1345f 60
va009039 0:1ed23ab1345f 61 uint8_t m_DeviceClass;
va009039 0:1ed23ab1345f 62 uint8_t m_InterfaceClass;
va009039 0:1ed23ab1345f 63
va009039 0:1ed23ab1345f 64 protected:
va009039 0:1ed23ab1345f 65 void fillControlBuf(byte requestType, byte request, word value, word index, int len);
va009039 0:1ed23ab1345f 66 private:
va009039 0:1ed23ab1345f 67 friend class UsbEndpoint;
va009039 0:1ed23ab1345f 68 friend class UsbHostMgr;
va009039 0:1ed23ab1345f 69
va009039 0:1ed23ab1345f 70 UsbEndpoint* m_pControlEp;
va009039 0:1ed23ab1345f 71
va009039 0:1ed23ab1345f 72 UsbHostMgr* m_pMgr;
va009039 0:1ed23ab1345f 73
va009039 0:1ed23ab1345f 74 bool m_connected;
va009039 0:1ed23ab1345f 75 bool m_enumerated;
va009039 0:1ed23ab1345f 76
va009039 0:1ed23ab1345f 77 int m_hub;
va009039 0:1ed23ab1345f 78 int m_port;
va009039 0:1ed23ab1345f 79 int m_addr;
va009039 0:1ed23ab1345f 80
va009039 0:1ed23ab1345f 81 int m_refs;
va009039 0:1ed23ab1345f 82
va009039 0:1ed23ab1345f 83 uint16_t m_vid;
va009039 0:1ed23ab1345f 84 uint16_t m_pid;
va009039 0:1ed23ab1345f 85
va009039 0:1ed23ab1345f 86 byte m_controlBuf[8];//8
va009039 0:1ed23ab1345f 87 //byte m_controlDataBuf[/*128*/256];
va009039 0:1ed23ab1345f 88
va009039 0:1ed23ab1345f 89 UsbErr hub_init();
va009039 0:1ed23ab1345f 90 UsbErr hub_poll();
va009039 0:1ed23ab1345f 91 UsbErr hub_PortReset(int port);
va009039 0:1ed23ab1345f 92 UsbErr SetPortFeature(int feature, int index);
va009039 0:1ed23ab1345f 93 UsbErr ClearPortFeature(int feature, int index);
va009039 0:1ed23ab1345f 94 UsbErr SetPortReset(int port);
va009039 0:1ed23ab1345f 95 UsbErr GetPortStatus(int port, uint8_t* buf, int size);
va009039 0:1ed23ab1345f 96 int m_hub_ports;
va009039 0:1ed23ab1345f 97 };
va009039 0:1ed23ab1345f 98
va009039 0:1ed23ab1345f 99 #endif