supported GR-PEACH original: http://developer.mbed.org/users/va009039/code/USBHostC270_example/ The function of Isochronous has moved to USBHost_AddIso library.
Dependencies: USBHost_custom_Addiso
Fork of USBHostC270_example_GR-PEACH by
USBHostC270/USBHostC270.h
- Committer:
- va009039
- Date:
- 2013-03-16
- Revision:
- 9:fecabade834a
- Child:
- 10:387c49b2fc7e
File content as of revision 9:fecabade834a:
#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);
};
