![](/media/cache/profiles/45ab12afa05e563bb484781693dffc87.50x50_q85.jpg)
modify for C210 webcam and Startboard Orange.
Dependencies: TextLCD USBHost mbed
Fork of USBHostC270_example by
Norimasa Okamoto さんの http://mbed.org/users/va009039/code/USBHostC270_example/ を C210 webcam と StarBoard Orange での SD カード保存用に変更。
Diff: USBHostC270/USBHostC270.h
- Revision:
- 9:fecabade834a
- Child:
- 10:387c49b2fc7e
diff -r 758190c6c455 -r fecabade834a USBHostC270/USBHostC270.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBHostC270/USBHostC270.h Sat Mar 16 13:07:55 2013 +0000 @@ -0,0 +1,105 @@ +#include "USBHostConf.h" +#include "USBHost.h" +#include "BaseUvc.h" + +#define C270_VID 0x046d +#define C270_PID 0x0825 +#define C270_160x120 2 +#define C270_176x144 3 +#define C270_320x176 4 +#define C270_320x240 5 +#define C270_352x288 6 +#define C270_432x240 7 +#define C270_640x480 1 +#define C270_544x288 8 +#define C270_640x360 9 +#define C270_752x416 10 +#define C270_800x448 11 +#define C270_800x600 12 + +#define C270_MJPEG 2 +#define C270_YUV2 1 + +#define C270_EN 0x81 +#define C270_MPS 192 +#define C270_IF_ALT 1 + +// --- 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 + +#define C270_DEBUG 1 +#ifdef C270_DEBUG +#define C270_DBG(x, ...) std::printf("[%s:%d]"x"\r\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); +#else +#define C270_DBG(...) while(0); +#endif +#define TEST_ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; + +class IsochronousEp; +class BaseUvc; +/** + * A class to communicate a C270 + */ +class USBHostC270 : public IUSBEnumerator, public BaseUvc { +public: + /** + * Constructor + * + */ + USBHostC270(int formatIndex = C270_MJPEG, int frameIndex = C270_160x120, uint32_t interval = _5FPS); + + /** + * Check if a C270 device is connected + * + * @return true if a MSD device is connected + */ + bool connected(); + + /** + * Try to connect to a C270 device + * + * @return true if connection was successful + */ + bool connect(); + +protected: + //From IUSBEnumerator + virtual void setVidPid(uint16_t vid, uint16_t pid); + 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 + virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used + +private: + USBHost * host; + USBDeviceConnected * dev; + bool dev_connected; + + int c270_intf; + bool c270_device_found; + bool c270_vid_pid_found; + int _formatIndex; + int _frameIndex; + uint32_t _interval; + + void init(); + USB_TYPE setInterfaceAlternate(uint8_t intf, uint8_t alt); + USB_TYPE Control(int req, int cs, int index, uint8_t* buf, int size); +}; +