Pulse Oximeter (NONIN) communicates with mbed via Bluetooth dongle and sends Heart Rate and Oxygen Saturation via GPRS module
Dependencies: C12832 GPS GSM mbed
Fork of myBlueUSB_localfix by
HCITransportUSB.h@0:003889bc474f, 2013-12-07 (annotated)
- Committer:
- nobukuma
- Date:
- Sat Dec 07 14:19:00 2013 +0000
- Revision:
- 0:003889bc474f
http://mbed.org/users/networker/code/myBlueUSB/ rev13??rev12??????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nobukuma | 0:003889bc474f | 1 | #ifndef HCITRANSPORTUSB_H |
nobukuma | 0:003889bc474f | 2 | #define HCITRANSPORTUSB_H |
nobukuma | 0:003889bc474f | 3 | #define MAX_HCL_SIZE 260 |
nobukuma | 0:003889bc474f | 4 | #define MAX_ACL_SIZE 400 |
nobukuma | 0:003889bc474f | 5 | #include "USBHost.h" |
nobukuma | 0:003889bc474f | 6 | |
nobukuma | 0:003889bc474f | 7 | extern int bulk; |
nobukuma | 0:003889bc474f | 8 | |
nobukuma | 0:003889bc474f | 9 | class HCITransportUSB : public HCITransport { |
nobukuma | 0:003889bc474f | 10 | int _device; |
nobukuma | 0:003889bc474f | 11 | u8* _hciBuffer; |
nobukuma | 0:003889bc474f | 12 | u8* _aclBuffer; |
nobukuma | 0:003889bc474f | 13 | |
nobukuma | 0:003889bc474f | 14 | public: |
nobukuma | 0:003889bc474f | 15 | void Open(int device, u8* hciBuffer, u8* aclBuffer) { |
nobukuma | 0:003889bc474f | 16 | _device = device; |
nobukuma | 0:003889bc474f | 17 | _hciBuffer = hciBuffer; |
nobukuma | 0:003889bc474f | 18 | _aclBuffer = aclBuffer; |
nobukuma | 0:003889bc474f | 19 | USBInterruptTransfer(_device,0x81,_hciBuffer,MAX_HCL_SIZE,HciCallback,this); |
nobukuma | 0:003889bc474f | 20 | USBBulkTransfer(_device,0x82,_aclBuffer,MAX_ACL_SIZE,AclCallback,this); |
nobukuma | 0:003889bc474f | 21 | } |
nobukuma | 0:003889bc474f | 22 | |
nobukuma | 0:003889bc474f | 23 | static void HciCallback(int device, int endpoint, int status, u8* data, int len, void* userData) { |
nobukuma | 0:003889bc474f | 24 | HCI* t = ((HCITransportUSB*)userData)->_target; //printf("HCI: %d bytes avail\n", len); |
nobukuma | 0:003889bc474f | 25 | if (t){ |
nobukuma | 0:003889bc474f | 26 | printfBytes("HCICallback:", data, len); |
nobukuma | 0:003889bc474f | 27 | t->HCIRecv(data,len); |
nobukuma | 0:003889bc474f | 28 | } |
nobukuma | 0:003889bc474f | 29 | USBInterruptTransfer(device,0x81,data,MAX_HCL_SIZE,HciCallback,userData); |
nobukuma | 0:003889bc474f | 30 | } |
nobukuma | 0:003889bc474f | 31 | |
nobukuma | 0:003889bc474f | 32 | static void AclCallback(int device, int endpoint, int status, u8* data, int len, void* userData) { |
nobukuma | 0:003889bc474f | 33 | HCI* t = ((HCITransportUSB*)userData)->_target; printf("ACL: %d bytes avail\n", len); |
nobukuma | 0:003889bc474f | 34 | if (t){ |
nobukuma | 0:003889bc474f | 35 | printfBytes("ACLCallback:", data, len); |
nobukuma | 0:003889bc474f | 36 | t->ACLRecv(data,len); |
nobukuma | 0:003889bc474f | 37 | } |
nobukuma | 0:003889bc474f | 38 | printf("ACL Read pending..\n"); |
nobukuma | 0:003889bc474f | 39 | USBBulkTransfer(device,0x82,data,MAX_ACL_SIZE,AclCallback,userData); |
nobukuma | 0:003889bc474f | 40 | } |
nobukuma | 0:003889bc474f | 41 | |
nobukuma | 0:003889bc474f | 42 | virtual void HCISend(const u8* data, int len) { |
nobukuma | 0:003889bc474f | 43 | printfBytes("HCISend:", data, len); |
nobukuma | 0:003889bc474f | 44 | USBControlTransfer(_device,REQUEST_TYPE_CLASS, 0, 0, 0,(u8*)data,len); |
nobukuma | 0:003889bc474f | 45 | } |
nobukuma | 0:003889bc474f | 46 | |
nobukuma | 0:003889bc474f | 47 | virtual int ACLSend(const u8* data, int len) { //printf("send %d bytes to usb\n", len); |
nobukuma | 0:003889bc474f | 48 | if (len > _acl_mtu) { |
nobukuma | 0:003889bc474f | 49 | printf("Max outgoing packet(%d) size exceeded, segmenting necessary, pktlen = %d\n", _acl_mtu, len); |
nobukuma | 0:003889bc474f | 50 | return 0; |
nobukuma | 0:003889bc474f | 51 | } |
nobukuma | 0:003889bc474f | 52 | #ifdef HOST_CONTR_FLOW |
nobukuma | 0:003889bc474f | 53 | if (data_credits == 0) |
nobukuma | 0:003889bc474f | 54 | printf("Waiting for ACL buffers...\n"); |
nobukuma | 0:003889bc474f | 55 | while (data_credits < 1) { |
nobukuma | 0:003889bc474f | 56 | USBLoop(); |
nobukuma | 0:003889bc474f | 57 | } |
nobukuma | 0:003889bc474f | 58 | data_credits--; |
nobukuma | 0:003889bc474f | 59 | #endif |
nobukuma | 0:003889bc474f | 60 | printfBytes("ACLSend:", data, len); |
nobukuma | 0:003889bc474f | 61 | return USBBulkTransfer(_device,0x02,(u8*)data,len); |
nobukuma | 0:003889bc474f | 62 | } |
nobukuma | 0:003889bc474f | 63 | }; |
nobukuma | 0:003889bc474f | 64 | |
nobukuma | 0:003889bc474f | 65 | #endif |