BLE demo for mbed Ported RunningElectronics's SBDBT firmware for BLE. It can communicate with iOS
Dependencies: FatFileSystem mbed
Fork of BTstack by
Diff: usb/UsbDevice.h
- Revision:
- 0:1ed23ab1345f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usb/UsbDevice.h Tue Jun 26 14:27:45 2012 +0000 @@ -0,0 +1,99 @@ + +/* +Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef USB_DEVICE_H +#define USB_DEVICE_H + +#include "mbed.h" +#include "UsbInc.h" +#include "UsbEndpoint.h" +#include "UsbHostMgr.h" + +class UsbHostMgr; +class UsbEndpoint; + +class UsbDevice +{ +protected: + UsbDevice( UsbHostMgr* pMgr, int hub, int port, int addr ); + ~UsbDevice(); + + UsbErr enumerate(); + +public: + bool connected(); + bool enumerated(); + + int getPid(); + int getVid(); + + //UsbErr getConfigurationDescriptor(int config, uint8_t** pBuf); + //UsbErr getInterfaceDescriptor(int config, int item, uint8_t** pBuf); + + UsbErr setConfiguration(int config); + + UsbErr controlSend(byte requestType, byte request, word value, word index, const byte* buf, int len); + UsbErr controlReceive(byte requestType, byte request, word value, word index, const byte* buf, int len); + UsbErr GetDescriptor(int type, int index, const byte* buf, int len); + UsbErr GetString(int index, char* buf, int len); + UsbErr SetInterfaceAlternate(int interface, int alternate); + + uint8_t m_DeviceClass; + uint8_t m_InterfaceClass; + +protected: + void fillControlBuf(byte requestType, byte request, word value, word index, int len); +private: + friend class UsbEndpoint; + friend class UsbHostMgr; + + UsbEndpoint* m_pControlEp; + + UsbHostMgr* m_pMgr; + + bool m_connected; + bool m_enumerated; + + int m_hub; + int m_port; + int m_addr; + + int m_refs; + + uint16_t m_vid; + uint16_t m_pid; + + byte m_controlBuf[8];//8 + //byte m_controlDataBuf[/*128*/256]; + + UsbErr hub_init(); + UsbErr hub_poll(); + UsbErr hub_PortReset(int port); + UsbErr SetPortFeature(int feature, int index); + UsbErr ClearPortFeature(int feature, int index); + UsbErr SetPortReset(int port); + UsbErr GetPortStatus(int port, uint8_t* buf, int size); + int m_hub_ports; +}; + +#endif