Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of USBHostC270_example by
USBHostC270.h
00001 #include "USBHostConf.h" 00002 #include "USBHost.h" 00003 #include "BaseUvc.h" 00004 #include "decodeMJPEG.h" 00005 00006 // Logitech C270 00007 #define C270_VID 0x046d 00008 #define C270_PID 0x0825 00009 #define C270_160x120 2 00010 #define C270_176x144 3 00011 #define C270_320x176 4 00012 #define C270_320x240 5 00013 #define C270_352x288 6 00014 #define C270_432x240 7 00015 #define C270_640x480 1 00016 #define C270_544x288 8 00017 #define C270_640x360 9 00018 #define C270_752x416 10 00019 #define C270_800x448 11 00020 #define C270_800x600 12 00021 00022 #define C270_MJPEG 2 00023 #define C270_YUV2 1 00024 00025 #define C270_EN 0x81 00026 #define C270_MPS 192 00027 #define C270_IF_ALT 1 00028 00029 #define TEST_ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; 00030 00031 class IsochronousEp; 00032 class BaseUvc; 00033 /** 00034 * A class to communicate a C270 00035 */ 00036 class USBHostC270 : public IUSBEnumerator, public BaseUvc, public decodeMJPEG { 00037 public: 00038 /** 00039 * Constructor 00040 * 00041 */ 00042 USBHostC270(int formatIndex = C270_MJPEG, int frameIndex = C270_160x120, uint32_t interval = _5FPS); 00043 00044 /** 00045 * Check if a C270 device is connected 00046 * 00047 * @return true if a MSD device is connected 00048 */ 00049 bool connected(); 00050 00051 /** 00052 * Try to connect to a C270 device 00053 * 00054 * @return true if connection was successful 00055 */ 00056 bool connect(); 00057 00058 /** 00059 * read jpeg image 00060 * 00061 * @param buf read buffer 00062 * @param size buffer size 00063 * @param timeout_ms timeout default 15sec 00064 * @return jpeg size if read success else -1 00065 */ 00066 int readJPEG(uint8_t* buf, int size, int timeout_ms = 15*1000); 00067 00068 protected: 00069 //From IUSBEnumerator 00070 virtual void setVidPid(uint16_t vid, uint16_t pid); 00071 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 00072 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00073 00074 private: 00075 bool dev_connected; 00076 00077 int c270_intf; 00078 bool c270_device_found; 00079 bool c270_vid_pid_found; 00080 int _formatIndex; 00081 int _frameIndex; 00082 uint32_t _interval; 00083 uint8_t _seq; 00084 uint8_t* _buf; 00085 int _pos; 00086 int _size; 00087 00088 virtual void outputJPEG(uint8_t c, int status); // from decodeMJPEG 00089 void callback_motion_jpeg(uint16_t frame, uint8_t* buf, int len); 00090 void init(); 00091 void onDisconnect(); 00092 };
Generated on Mon Jul 18 2022 19:52:39 by
1.7.2
