testing n-Bed with a Logitech C270 camera
Fork of USBHostC270_example by
Diff: USBHostC270/BaseUvc.h
- Revision:
- 10:387c49b2fc7e
- Parent:
- 9:fecabade834a
- Child:
- 11:6a8eef89eb22
--- a/USBHostC270/BaseUvc.h Sat Mar 16 13:07:55 2013 +0000 +++ b/USBHostC270/BaseUvc.h Sun Mar 17 13:22:13 2013 +0000 @@ -1,5 +1,28 @@ +// BaseUvc.h + #pragma once +// --- UVC -------------------------------------------------- +#define _30FPS 333333 +#define _25FPS 400000 +#define _20FPS 500000 +#define _15FPS 666666 +#define _10FPS 1000000 +#define _5FPS 2000000 +#define _1FPS 10000000 + +#define SET_CUR 0x01 +#define GET_CUR 0x81 +#define GET_MIN 0x82 +#define GET_MAX 0x83 +#define GET_RES 0x84 +#define GET_LEN 0x85 +#define GET_INFO 0x86 +#define GET_DEF 0x87 + +#define VS_PROBE_CONTROL 0x01 +#define VS_COMMIT_CONTROL 0x02 + class BaseEp; struct HCITD { // HostController Isochronous Transfer Descriptor __IO uint32_t Control; // +0 Transfer descriptor control @@ -80,6 +103,10 @@ Control &= ~0xffff0000; Control |= size<<16; } + + inline void setSkip() { + Control |= 1<<14; + } }; struct _HCCA { // Host Controller Communication Area @@ -101,6 +128,37 @@ inline void operator delete(void* p) { free(p); } + + inline void enqueue(_HCED* ed) { + for(int i = 0; i < 32; i++) { + if (InterruptTable[i] == NULL) { + InterruptTable[i] = ed; + } else { + _HCED* nextEd = InterruptTable[i]; + while(nextEd->Next && nextEd->Next != ed) { + nextEd = nextEd->Next; + } + nextEd->Next = ed; + } + } + } + + inline void dequeue(_HCED* ed) { + for(int i = 0; i < 32; i++) { + if (InterruptTable[i] == ed) { + InterruptTable[i] = ed->Next; + } else if (InterruptTable[i]) { + _HCED* nextEd = InterruptTable[i]; + while(nextEd) { + if (nextEd->Next == ed) { + nextEd->Next = ed->Next; + break; + } + nextEd = nextEd->Next; + } + } + } + } }; #define HCTD_QUEUE_SIZE 3 @@ -133,10 +191,11 @@ public: IsochronousEp(int addr, uint8_t ep, uint16_t size); void reset(int delay_ms = 100); - HCITD* isochronousReveive(int millisec=osWaitForever); + HCITD* isochronousReceive(int millisec=osWaitForever); int isochronousSend(uint8_t* buf, int len, int millisec=osWaitForever); HCITD* get_queue_HCITD(int millisec); uint16_t m_PacketSize; + void disconnect(); private: HCITD* new_HCITD(BaseEp* obj); int m_itd_queue_count; @@ -148,7 +207,8 @@ class BaseUvc { public: void poll(int millisec=osWaitForever); - int Control(int req, int cs, int index, uint8_t* buf, int size); + USB_TYPE Control(int req, int cs, int index, uint8_t* buf, int size); + USB_TYPE setInterfaceAlternate(uint8_t intf, uint8_t alt); //ControlEp* m_ctlEp; IsochronousEp* m_isoEp; uint32_t report_cc_count[16]; // ConditionCode @@ -168,4 +228,7 @@ CDummy* m_pCbItem; void (CDummy::*m_pCbMeth)(uint16_t, uint8_t*, int); void (*m_pCb)(uint16_t, uint8_t*, int); +protected: + USBHost * host; + USBDeviceConnected * dev; };