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
Diff: USBHostC270/USBHostC270.h
- Revision:
- 10:387c49b2fc7e
- Parent:
- 9:fecabade834a
--- a/USBHostC270/USBHostC270.h Sat Mar 16 13:07:55 2013 +0000
+++ b/USBHostC270/USBHostC270.h Sun Mar 17 13:22:13 2013 +0000
@@ -1,7 +1,9 @@
#include "USBHostConf.h"
#include "USBHost.h"
#include "BaseUvc.h"
+#include "decodeMJPEG.h"
+// Logitech C270
#define C270_VID 0x046d
#define C270_PID 0x0825
#define C270_160x120 2
@@ -24,33 +26,6 @@
#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;
@@ -58,7 +33,7 @@
/**
* A class to communicate a C270
*/
-class USBHostC270 : public IUSBEnumerator, public BaseUvc {
+class USBHostC270 : public IUSBEnumerator, public BaseUvc, public decodeMJPEG {
public:
/**
* Constructor
@@ -80,6 +55,16 @@
*/
bool connect();
+ /**
+ * read jpeg image
+ *
+ * @param buf read buffer
+ * @param size buffer size
+ * @param timeout_ms timeout default 15sec
+ * @return jpeg size if read success else -1
+ */
+ int readJPEG(uint8_t* buf, int size, int timeout_ms = 15*1000);
+
protected:
//From IUSBEnumerator
virtual void setVidPid(uint16_t vid, uint16_t pid);
@@ -87,8 +72,6 @@
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;
@@ -97,9 +80,13 @@
int _formatIndex;
int _frameIndex;
uint32_t _interval;
+ uint8_t _seq;
+ uint8_t* _buf;
+ int _pos;
+ int _size;
+ virtual void outputJPEG(uint8_t c, int status); // from decodeMJPEG
+ void callback_motion_jpeg(uint16_t frame, uint8_t* buf, int len);
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);
+ void onDisconnect();
};
-
