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.
Dependents: BaseUsbHost_example BaseJpegDecode_example SimpleJpegDecode_example
Diff: BaseUsbHostUvc.cpp
- Revision:
- 1:3b7bc4f87a61
- Child:
- 2:fe1e62051d88
diff -r b7d6879637a8 -r 3b7bc4f87a61 BaseUsbHostUvc.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/BaseUsbHostUvc.cpp Wed Dec 05 13:23:06 2012 +0000
@@ -0,0 +1,74 @@
+// BaseUsbHostUvc.cpp 2012/12/5
+#include "mbed.h"
+#include "rtos.h"
+#include "BaseUsbHost.h"
+#define DEBUG
+#include "BaseUsbHostDebug.h"
+#define TEST
+#include "BaseUsbHostTest.h"
+
+void BaseUvc::poll()
+{
+ HCITD* itd = m_isoEp->isochronousReveive();
+ if (itd) {
+ uint8_t cc = itd->Control>>28;
+ report_cc_count[cc]++;
+ if (cc == 0) { // ConditionCode
+ //DBG_ITD(itd);
+ uint16_t frame = itd->Control & 0xffff;
+ uint8_t* buf = const_cast<uint8_t*>(itd->buf);
+ int mps = m_isoEp->m_PacketSize;
+ for(int i = 0; i < m_isoEp->m_FrameCount; i++) {
+ uint16_t pswn = itd->OffsetPSW[i];
+ cc = pswn>>12;
+ if (cc == 0 || cc == 9) {
+ int len = pswn & 0x7ff;
+ onResult(frame, buf, len);
+ }
+ report_ps_cc_count[cc]++;
+ buf += mps;
+ frame++;
+ }
+ }
+ m_isoEp->delete_HCTD(reinterpret_cast<HCTD*>(itd));
+ }
+}
+
+int BaseUvc::Control(int req, int cs, int index, uint8_t* buf, int size)
+{
+ TEST_ASSERT(m_ctlEp);
+ int rc;
+ if (req == SET_CUR) {
+ rc = m_ctlEp->controlSend(
+ USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE,
+ req, cs<<8, index, buf, size);
+ return rc;
+ }
+ rc = m_ctlEp->controlReceive(
+ USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE,
+ req, cs<<8, index, buf, size);
+ return rc;
+}
+
+void BaseUvc::onResult(uint16_t frame, uint8_t* buf, int len)
+{
+ if(m_pCbItem && m_pCbMeth)
+ (m_pCbItem->*m_pCbMeth)(frame, buf, len);
+ else if(m_pCb)
+ m_pCb(frame, buf, len);
+}
+
+void BaseUvc::setOnResult( void (*pMethod)(uint16_t, uint8_t*, int) )
+{
+ m_pCb = pMethod;
+ m_pCbItem = NULL;
+ m_pCbMeth = NULL;
+}
+
+void BaseUvc::clearOnResult()
+{
+ m_pCb = NULL;
+ m_pCbItem = NULL;
+ m_pCbMeth = NULL;
+}
+