BTstack for EA LPC4088 QSB example program
Dependencies: LPC4088-USBHost mbed
Fork of KL46Z-BTstack_example by
The usage is the same as KL46Z-BTstack_example.
使い方はKL46Z-BTstack_exampleと同じです。
LPC4088-USBHostBTstack/USBHostBTstack.h@6:d946cb517371, 2014-04-25 (annotated)
- Committer:
- va009039
- Date:
- Fri Apr 25 05:34:24 2014 +0000
- Revision:
- 6:d946cb517371
- Parent:
- KL46Z-USBHostBTstack/USBHostBTstack.h@4:cf1b23f4dcd4
run on LPC4088
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 3:54f9b5e0d12d | 1 | #include "USBHostConf.h" |
va009039 | 3:54f9b5e0d12d | 2 | #include "USBHost.h" |
va009039 | 3:54f9b5e0d12d | 3 | #pragma once |
va009039 | 3:54f9b5e0d12d | 4 | |
va009039 | 3:54f9b5e0d12d | 5 | #define TEST_ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; |
va009039 | 3:54f9b5e0d12d | 6 | |
va009039 | 3:54f9b5e0d12d | 7 | /** |
va009039 | 3:54f9b5e0d12d | 8 | * A class to communicate a BTstack |
va009039 | 3:54f9b5e0d12d | 9 | */ |
va009039 | 4:cf1b23f4dcd4 | 10 | class USBHostBTstack : public IUSBEnumerator { |
va009039 | 3:54f9b5e0d12d | 11 | public: |
va009039 | 3:54f9b5e0d12d | 12 | /** |
va009039 | 3:54f9b5e0d12d | 13 | * Constructor |
va009039 | 3:54f9b5e0d12d | 14 | * |
va009039 | 3:54f9b5e0d12d | 15 | */ |
va009039 | 3:54f9b5e0d12d | 16 | USBHostBTstack(); |
va009039 | 3:54f9b5e0d12d | 17 | |
va009039 | 3:54f9b5e0d12d | 18 | /** |
va009039 | 3:54f9b5e0d12d | 19 | * Check if a BTstack device is connected |
va009039 | 3:54f9b5e0d12d | 20 | * |
va009039 | 3:54f9b5e0d12d | 21 | * @return true if a BTstack device is connected |
va009039 | 3:54f9b5e0d12d | 22 | */ |
va009039 | 3:54f9b5e0d12d | 23 | bool connected(); |
va009039 | 3:54f9b5e0d12d | 24 | |
va009039 | 3:54f9b5e0d12d | 25 | /** |
va009039 | 3:54f9b5e0d12d | 26 | * Try to connect to a BTstack device |
va009039 | 3:54f9b5e0d12d | 27 | * |
va009039 | 3:54f9b5e0d12d | 28 | * @return true if connection was successful |
va009039 | 3:54f9b5e0d12d | 29 | */ |
va009039 | 3:54f9b5e0d12d | 30 | bool connect(); |
va009039 | 3:54f9b5e0d12d | 31 | |
va009039 | 3:54f9b5e0d12d | 32 | int open(); |
va009039 | 3:54f9b5e0d12d | 33 | int send_packet(uint8_t packet_type, uint8_t* packet, int size); |
va009039 | 3:54f9b5e0d12d | 34 | void register_packet_handler( void (*pMethod)(uint8_t, uint8_t*, uint16_t)); |
va009039 | 3:54f9b5e0d12d | 35 | void poll(); |
va009039 | 3:54f9b5e0d12d | 36 | |
va009039 | 4:cf1b23f4dcd4 | 37 | protected: |
va009039 | 4:cf1b23f4dcd4 | 38 | //From IUSBEnumerator |
va009039 | 4:cf1b23f4dcd4 | 39 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
va009039 | 4:cf1b23f4dcd4 | 40 | 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 |
va009039 | 4:cf1b23f4dcd4 | 41 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
va009039 | 4:cf1b23f4dcd4 | 42 | |
va009039 | 3:54f9b5e0d12d | 43 | private: |
va009039 | 3:54f9b5e0d12d | 44 | USBHost * host; |
va009039 | 3:54f9b5e0d12d | 45 | USBDeviceConnected * dev; |
va009039 | 4:cf1b23f4dcd4 | 46 | bool dev_connected; |
va009039 | 3:54f9b5e0d12d | 47 | uint8_t int_report[64]; |
va009039 | 3:54f9b5e0d12d | 48 | uint8_t bulk_report[64]; |
va009039 | 4:cf1b23f4dcd4 | 49 | USBEndpoint * int_in; |
va009039 | 4:cf1b23f4dcd4 | 50 | USBEndpoint * bulk_in; |
va009039 | 3:54f9b5e0d12d | 51 | USBEndpoint * bulk_out; |
va009039 | 4:cf1b23f4dcd4 | 52 | bool ep_int_in; |
va009039 | 4:cf1b23f4dcd4 | 53 | bool ep_bulk_in; |
va009039 | 4:cf1b23f4dcd4 | 54 | bool ep_bulk_out; |
va009039 | 4:cf1b23f4dcd4 | 55 | |
va009039 | 4:cf1b23f4dcd4 | 56 | bool btstack_device_found; |
va009039 | 4:cf1b23f4dcd4 | 57 | int btstack_intf; |
va009039 | 3:54f9b5e0d12d | 58 | void (*m_pCb)(uint8_t, uint8_t*, uint16_t); |
va009039 | 4:cf1b23f4dcd4 | 59 | void init(); |
va009039 | 3:54f9b5e0d12d | 60 | }; |
va009039 | 3:54f9b5e0d12d | 61 | |
va009039 | 3:54f9b5e0d12d | 62 | void _debug_bytes(const char* pretty, int line, const char* s, uint8_t* buf, int len); |