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
BaseUsbHostUvc.cpp
- Committer:
- va009039
- Date:
- 2013-01-06
- Revision:
- 3:ae77d63a1eda
- Parent:
- 2:fe1e62051d88
- Child:
- 4:d931d24c2f81
File content as of revision 3:ae77d63a1eda:
// BaseUsbHostUvc.cpp 2012/12/11
#include "mbed.h"
#include "rtos.h"
#include "BaseUsbHost.h"
#define DEBUG
#include "BaseUsbHostDebug.h"
#define TEST
#include "BaseUsbHostTest.h"
void BaseUvc::poll(int millisec)
{
HCITD* itd = m_isoEp->isochronousReveive(millisec);
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;
int fc = ((itd->Control>>24)&7)+1;
uint8_t* buf = const_cast<uint8_t*>(itd->buf);
int mps = m_isoEp->m_PacketSize;
for(int i = 0; i < fc; 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;
}