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: mbed Rejestrator
F401RE-USBHost/USBHostC270/BaseUvc.cpp@0:fa31f8461c63, 2015-04-18 (annotated)
- Committer:
- Waldek
- Date:
- Sat Apr 18 17:01:57 2015 +0000
- Revision:
- 0:fa31f8461c63
working version, stop
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Waldek | 0:fa31f8461c63 | 1 | // BaseUvc.cpp |
Waldek | 0:fa31f8461c63 | 2 | #include "USBHostConf.h" |
Waldek | 0:fa31f8461c63 | 3 | #include "USBHost.h" |
Waldek | 0:fa31f8461c63 | 4 | #include "BaseUvc.h" |
Waldek | 0:fa31f8461c63 | 5 | |
Waldek | 0:fa31f8461c63 | 6 | void BaseUvc::poll() |
Waldek | 0:fa31f8461c63 | 7 | { |
Waldek | 0:fa31f8461c63 | 8 | uint8_t buf[ep_iso_in->getSize()]; |
Waldek | 0:fa31f8461c63 | 9 | int result = host->isochronousReadNB(ep_iso_in, buf, sizeof(buf)); |
Waldek | 0:fa31f8461c63 | 10 | if (result >= 0) { |
Waldek | 0:fa31f8461c63 | 11 | uint16_t frame = 0; |
Waldek | 0:fa31f8461c63 | 12 | onResult(frame, buf, ep_iso_in->getLengthTransferred()); |
Waldek | 0:fa31f8461c63 | 13 | } |
Waldek | 0:fa31f8461c63 | 14 | } |
Waldek | 0:fa31f8461c63 | 15 | |
Waldek | 0:fa31f8461c63 | 16 | USB_TYPE BaseUvc::Control(int req, int cs, int index, uint8_t* buf, int size) |
Waldek | 0:fa31f8461c63 | 17 | { |
Waldek | 0:fa31f8461c63 | 18 | if (req == SET_CUR) { |
Waldek | 0:fa31f8461c63 | 19 | return host->controlWrite(dev, |
Waldek | 0:fa31f8461c63 | 20 | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE, |
Waldek | 0:fa31f8461c63 | 21 | req, cs<<8, index, buf, size); |
Waldek | 0:fa31f8461c63 | 22 | } |
Waldek | 0:fa31f8461c63 | 23 | return host->controlRead(dev, |
Waldek | 0:fa31f8461c63 | 24 | USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE, |
Waldek | 0:fa31f8461c63 | 25 | req, cs<<8, index, buf, size); |
Waldek | 0:fa31f8461c63 | 26 | } |
Waldek | 0:fa31f8461c63 | 27 | |
Waldek | 0:fa31f8461c63 | 28 | USB_TYPE BaseUvc::setInterfaceAlternate(uint8_t intf, uint8_t alt) |
Waldek | 0:fa31f8461c63 | 29 | { |
Waldek | 0:fa31f8461c63 | 30 | return host->controlWrite(dev, USB_HOST_TO_DEVICE | USB_RECIPIENT_INTERFACE, |
Waldek | 0:fa31f8461c63 | 31 | SET_INTERFACE, alt, intf, NULL, 0); |
Waldek | 0:fa31f8461c63 | 32 | } |
Waldek | 0:fa31f8461c63 | 33 | |
Waldek | 0:fa31f8461c63 | 34 | void BaseUvc::onResult(uint16_t frame, uint8_t* buf, int len) |
Waldek | 0:fa31f8461c63 | 35 | { |
Waldek | 0:fa31f8461c63 | 36 | if(m_pCbItem && m_pCbMeth) |
Waldek | 0:fa31f8461c63 | 37 | (m_pCbItem->*m_pCbMeth)(frame, buf, len); |
Waldek | 0:fa31f8461c63 | 38 | else if(m_pCb) |
Waldek | 0:fa31f8461c63 | 39 | m_pCb(frame, buf, len); |
Waldek | 0:fa31f8461c63 | 40 | } |
Waldek | 0:fa31f8461c63 | 41 | |
Waldek | 0:fa31f8461c63 | 42 | void BaseUvc::setOnResult( void (*pMethod)(uint16_t, uint8_t*, int) ) |
Waldek | 0:fa31f8461c63 | 43 | { |
Waldek | 0:fa31f8461c63 | 44 | m_pCb = pMethod; |
Waldek | 0:fa31f8461c63 | 45 | m_pCbItem = NULL; |
Waldek | 0:fa31f8461c63 | 46 | m_pCbMeth = NULL; |
Waldek | 0:fa31f8461c63 | 47 | } |
Waldek | 0:fa31f8461c63 | 48 | |
Waldek | 0:fa31f8461c63 | 49 | void BaseUvc::clearOnResult() |
Waldek | 0:fa31f8461c63 | 50 | { |
Waldek | 0:fa31f8461c63 | 51 | m_pCb = NULL; |
Waldek | 0:fa31f8461c63 | 52 | m_pCbItem = NULL; |
Waldek | 0:fa31f8461c63 | 53 | m_pCbMeth = NULL; |
Waldek | 0:fa31f8461c63 | 54 | } |
Waldek | 0:fa31f8461c63 | 55 |