Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FatFileSystem TB6612FNG2 mbed
usbbt/usbbt.h@0:de03cbbcd0ff, 2015-11-30 (annotated)
- Committer:
- mbed_Cookbook_SE
- Date:
- Mon Nov 30 09:32:15 2015 +0000
- Revision:
- 0:de03cbbcd0ff
??
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 1 | #ifndef USBBT_H |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 2 | #define USBBT_H |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 3 | #include "UsbHostMgr.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 4 | #include "UsbEndpoint.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 5 | #include "UsbBaseClass.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 6 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 7 | #define HCI_COMMAND_DATA_PACKET 0x01 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 8 | #define HCI_ACL_DATA_PACKET 0x02 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 9 | #define HCI_SCO_DATA_PACKET 0x03 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 10 | #define HCI_EVENT_PACKET 0x04 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 11 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 12 | class usbbt : public UsbBaseClass { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 13 | public: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 14 | usbbt(int dongle = 0); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 15 | int setup(int timeout = 9000); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 16 | int send_packet(uint8_t packet_type, uint8_t* packet, int size); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 17 | void poll(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 18 | ///Setups the result callback |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 19 | /** |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 20 | @param pMethod : callback function |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 21 | */ |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 22 | void setOnPacket( void (*pMethod)(uint8_t, uint8_t*, uint16_t) ); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 23 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 24 | ///Setups the result callback |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 25 | /** |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 26 | @param pItem : instance of class on which to execute the callback method |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 27 | @param pMethod : callback method |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 28 | */ |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 29 | class CDummy; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 30 | template<class T> |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 31 | void setOnPacket( T* pItem, void (T::*pMethod)(uint8_t, uint8_t*, uint16_t) ) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 32 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 33 | m_pCb = NULL; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 34 | m_pCbItem = (CDummy*) pItem; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 35 | m_pCbMeth = (void (CDummy::*)(uint8_t, uint8_t*, uint16_t)) pMethod; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 36 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 37 | void clearOnPacket(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 38 | private: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 39 | int ParseConfiguration(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 40 | void onPacket(uint8_t packet_type, uint8_t* packet, uint16_t size); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 41 | int m_dongle; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 42 | UsbDevice* m_pDev; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 43 | UsbEndpoint* m_pEpIntIn; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 44 | UsbEndpoint* m_pEpBulkIn; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 45 | UsbEndpoint* m_pEpBulkOut; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 46 | Timer m_timer; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 47 | int m_int_seq; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 48 | uint8_t m_int_buf[64]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 49 | int m_bulk_seq; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 50 | uint8_t m_bulk_buf[64]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 51 | CDummy* m_pCbItem; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 52 | void (CDummy::*m_pCbMeth)(uint8_t, uint8_t*, uint16_t); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 53 | void (*m_pCb)(uint8_t, uint8_t*, uint16_t); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 54 | }; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 55 | #endif //USBBT_H |