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.
Dependencies: FatFileSystem TB6612FNG2 mbed
uvc/uvcini.cpp@0:de03cbbcd0ff, 2015-11-30 (annotated)
- Committer:
- mbed_Cookbook_SE
- Date:
- Mon Nov 30 09:32:15 2015 +0000
- Revision:
- 0:de03cbbcd0ff
??
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 1 | #include "mbed.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 2 | #include "uvc.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 3 | #define __DEBUG |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 4 | #include "mydbg.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 5 | #include "stcamcfg.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 6 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 7 | const struct stcamcfg stcamcfg_table[] = { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 8 | /* |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 9 | {0x045e, 0x074a, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 10 | 160,120, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 11 | PAYLOAD_MJPEG, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 12 | 0x81, 128, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 13 | 1, 5, 2000000, // 160x120 5.0fps |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 14 | 1, 1, "Microsoft LifeCam VX-700", |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 15 | 8, 3, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 16 | },*/ |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 17 | /* |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 18 | {0x0c45, 0x62c0, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 19 | 160,120, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 20 | PAYLOAD_MJPEG, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 21 | 0x81, 128, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 22 | 1, 5, 2000000, // 160x120 5.0fps |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 23 | 1, 1, "UVCA130AF", |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 24 | 8, 3, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 25 | },*/ |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 26 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 27 | {0x046d, 0x0994, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 28 | 160,120, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 29 | PAYLOAD_MJPEG, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 30 | 0, 0, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 31 | 0, 0, 2000000, // 160x120 10.0fps |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 32 | 0, 0, "Logitech QuickCam Orbit AF", |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 33 | 0, 3, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 34 | }, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 35 | {0x0000, 0x0000, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 36 | 160,120, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 37 | PAYLOAD_MJPEG, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 38 | 0x00, 0, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 39 | 0, 0, 2000000, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 40 | 0, 0, "default", |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 41 | 0, 3, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 42 | }, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 43 | }; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 44 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 45 | inline void LE32(uint32_t n, uint8_t* d) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 46 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 47 | d[0] = (uint8_t)n; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 48 | d[1] = (uint8_t)(n >> 8); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 49 | d[2] = (uint8_t)(n >> 16); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 50 | d[3] = (uint8_t)(n >> 24); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 51 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 52 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 53 | void uvc::SetFormatIndex(int index) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 54 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 55 | DBG_ASSERT(index >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 56 | DBG_ASSERT(index <= 2); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 57 | m_FormatIndex = index; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 58 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 59 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 60 | void uvc::SetFrameIndex(int index) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 61 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 62 | DBG_ASSERT(index >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 63 | DBG_ASSERT(index <= 8); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 64 | m_FrameIndex = index; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 65 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 66 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 67 | void uvc::SetFrameInterval(int val) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 68 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 69 | DBG_ASSERT(val >= 333333); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 70 | DBG_ASSERT(val <= 10000000); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 71 | m_FrameInterval = val; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 72 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 73 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 74 | void uvc::SetPacketSize(int size) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 75 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 76 | DBG_ASSERT(size >= 128); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 77 | DBG_ASSERT(size <= 956); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 78 | m_PacketSize = size; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 79 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 80 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 81 | void uvc::SetImageSize(int width, int height) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 82 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 83 | DBG_ASSERT(width >= 160); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 84 | DBG_ASSERT(width <= 800); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 85 | DBG_ASSERT(height >= 120); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 86 | DBG_ASSERT(height <= 600); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 87 | m_width = width; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 88 | m_height = height; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 89 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 90 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 91 | void uvc::SetPayload(int payload) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 92 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 93 | DBG_ASSERT(payload == PAYLOAD_MJPEG || payload == PAYLOAD_YUY2); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 94 | m_payload = payload; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 95 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 96 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 97 | void uvc::poll() |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 98 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 99 | isochronous(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 100 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 101 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 102 | int uvc::_init() |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 103 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 104 | m_init = true; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 105 | UsbErr rc; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 106 | for(int i = 0; i < 2; i++) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 107 | m_pDev = m_pHost->getDeviceByClass(CLASS_VIDEO, m_cam); // UVC |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 108 | if (m_pDev || i > 0) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 109 | break; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 110 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 111 | rc = Usb_poll(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 112 | if (rc == USBERR_PROCESSING) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 113 | VERBOSE("%p USBERR_PROCESSING\n", this); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 114 | return -1; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 115 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 116 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 117 | DBG("m_pDev=%p\n", m_pDev); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 118 | if (!m_pDev) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 119 | VERBOSE("%p UVC CAMERA(%d) NOT FOUND\n", this, m_cam); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 120 | return -1; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 121 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 122 | DBG_ASSERT(m_pDev); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 123 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 124 | struct stcamcfg cfg; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 125 | for(int i = 0; ; i++) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 126 | cfg = stcamcfg_table[i]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 127 | if (cfg.idVender == 0x0000) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 128 | DBG("not cam config\n"); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 129 | DBG("vid: %04X\n", m_pDev->getVid()); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 130 | DBG("pid: %04X\n", m_pDev->getPid()); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 131 | break; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 132 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 133 | if (cfg.idVender == m_pDev->getVid() && cfg.idProduct == m_pDev->getPid()) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 134 | DBG_ASSERT(cfg.name); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 135 | DBG("found %s\n", cfg.name); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 136 | break; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 137 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 138 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 139 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 140 | if (m_width) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 141 | cfg.width = m_width; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 142 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 143 | if (m_height) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 144 | cfg.height = m_height; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 145 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 146 | if (m_payload != PAYLOAD_UNDEF) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 147 | cfg.payload = m_payload; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 148 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 149 | if (m_FormatIndex) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 150 | cfg.FormatIndex = m_FormatIndex; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 151 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 152 | if (m_FrameIndex) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 153 | cfg.FrameIndex = m_FrameIndex; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 154 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 155 | if (m_FrameInterval) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 156 | cfg.dwFrameInterval = m_FrameInterval; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 157 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 158 | if (m_PacketSize) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 159 | cfg.wMaxPacketSize = m_PacketSize; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 160 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 161 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 162 | _config(&cfg); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 163 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 164 | if (cfg.payload == PAYLOAD_YUY2) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 165 | if (cfg.FormatIndex == 0) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 166 | VERBOSE("YUY2 FORMAT NOT FOUND\n"); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 167 | return -1; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 168 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 169 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 170 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 171 | if (cfg.iso_FrameCount == 0) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 172 | int c = usb_bp_size() / cfg.wMaxPacketSize; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 173 | if (c > 8) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 174 | c = 8; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 175 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 176 | cfg.iso_FrameCount = c; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 177 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 178 | DBG_ASSERT(cfg.iso_FrameCount >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 179 | DBG_ASSERT(cfg.iso_FrameCount <= 8); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 180 | DBG_ASSERT((cfg.iso_FrameCount * cfg.wMaxPacketSize) <= usb_bp_size()); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 181 | if (cfg.iso_itdCount == 0) { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 182 | cfg.iso_itdCount = 3; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 183 | } |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 184 | DBG_ASSERT(cfg.iso_itdCount >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 185 | DBG("cfg.wMaxPacketSize=%d\n", cfg.wMaxPacketSize); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 186 | DBG("cfg.iso_FrameCount=%d\n", cfg.iso_FrameCount); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 187 | DBG("cfg.iso_itdCount=%d\n", cfg.iso_itdCount); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 188 | DBG_ASSERT(cfg.iso_FrameCount >= 1 && cfg.iso_FrameCount <= 8); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 189 | //m_pEpIntIn = new UsbEndpoint(m_pDev, 0x83, true, USB_INT, 16); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 190 | //DBG_ASSERT(m_pEpIntIn); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 191 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 192 | DBG_ASSERT(cfg.bEndpointAddress == 0x81); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 193 | DBG_ASSERT(cfg.wMaxPacketSize >= 128); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 194 | DBG_ASSERT(cfg.wMaxPacketSize <= 956); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 195 | m_PacketSize = cfg.wMaxPacketSize; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 196 | DBG_ASSERT(m_PacketSize); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 197 | m_pEpIsoIn = new UsbEndpoint(m_pDev, cfg.bEndpointAddress, true, USB_ISO, m_PacketSize); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 198 | DBG_ASSERT(m_pEpIsoIn); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 199 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 200 | DBG_ASSERT(cfg.FormatIndex >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 201 | DBG_ASSERT(cfg.FormatIndex <= 2); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 202 | DBG_ASSERT(cfg.FrameIndex >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 203 | DBG_ASSERT(cfg.FrameIndex <= 8); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 204 | DBG_ASSERT(cfg.dwFrameInterval <= 10000000); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 205 | DBG_ASSERT(cfg.dwFrameInterval >= 333333); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 206 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 207 | uint8_t temp1[1]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 208 | temp1[0] = 0x00; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 209 | rc = Control(GET_INFO, VS_PROBE_CONTROL, 1, temp1, sizeof(temp1)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 210 | DBG_ASSERT(rc == USBERR_OK); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 211 | DBG_BYTES("GET_INFO Probe ", temp1, sizeof(temp1)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 212 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 213 | uint8_t temp[34]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 214 | rc = Control(GET_CUR, VS_PROBE_CONTROL, 1, temp, sizeof(temp)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 215 | DBG_ASSERT(rc == USBERR_OK); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 216 | DBG_BYTES("GET_CUR Probe ", temp, sizeof(temp)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 217 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 218 | uint8_t param[34]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 219 | memset(param, 0x00, sizeof(param)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 220 | param[0] = 0x00; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 221 | param[2] = cfg.FormatIndex; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 222 | param[3] = cfg.FrameIndex; // 160x120 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 223 | LE32(cfg.dwFrameInterval, param+4); // Frame Interval |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 224 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 225 | DBG_BYTES("SET_CUR Probe ", param, sizeof(param)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 226 | rc = Control(SET_CUR, VS_PROBE_CONTROL, 1, param, sizeof(param)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 227 | DBG_ASSERT(rc == USBERR_OK); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 228 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 229 | rc = Control(GET_CUR, VS_PROBE_CONTROL, 1, temp, sizeof(temp)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 230 | DBG_ASSERT(rc == USBERR_OK); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 231 | DBG_BYTES("GET_CUR Probe ", temp, sizeof(temp)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 232 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 233 | rc = Control(GET_CUR, VS_COMMIT_CONTROL, 1, temp, sizeof(temp)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 234 | DBG_ASSERT(rc == USBERR_OK); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 235 | DBG_BYTES("GET_CUR Commit", temp, sizeof(temp)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 236 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 237 | DBG_BYTES("SET_CUR Commit", param, sizeof(param)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 238 | rc = Control(SET_CUR, VS_COMMIT_CONTROL, 1, param, sizeof(param)); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 239 | DBG_ASSERT(rc == USBERR_OK); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 240 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 241 | //USBH_SET_INTERFACE(1, 1); // alt=1 size=128 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 242 | DBG_ASSERT(cfg.bInterface >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 243 | DBG_ASSERT(cfg.bAlternate >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 244 | DBG_ASSERT(cfg.bAlternate <= 6); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 245 | //rc = m_pDev->controlSend( |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 246 | // USB_HOST_TO_DEVICE | USB_RECIPIENT_INTERFACE, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 247 | // SET_INTERFACE, cfg.bAlternate, cfg.bInterface, NULL, 0); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 248 | rc = m_pDev->SetInterfaceAlternate(cfg.bInterface, cfg.bAlternate); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 249 | DBG_ASSERT(rc == USBERR_OK); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 250 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 251 | DBG_ASSERT(cfg.iso_FrameCount >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 252 | DBG_ASSERT(cfg.iso_FrameCount <= 8); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 253 | m_FrameCount = cfg.iso_FrameCount; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 254 | DBG_ASSERT(cfg.iso_itdCount >= 1); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 255 | DBG_ASSERT(cfg.iso_itdCount <= 8); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 256 | m_itdCount = cfg.iso_itdCount; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 257 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 258 | LPC_USB->HcControl |= OR_CONTROL_PLE; // PeriodicListEnable |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 259 | LPC_USB->HcControl |= OR_CONTROL_IE; // IsochronousEnable |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 260 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 261 | m_connect = true; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 262 | return 0; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 263 | } |