USB Host Driver with Socket Modem support. Works with revision 323 of mbed-src but broken with any later version.

Dependencies:   FATFileSystem

Fork of F401RE-USBHost by Norimasa Okamoto

Committer:
fritz291
Date:
Fri Jun 26 19:30:55 2015 +0000
Revision:
26:53970cabf56d
Parent:
18:61554f238584
Fixed small error in testAT function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 13:8774c07f12a5 1 // BaseUvc.cpp
va009039 13:8774c07f12a5 2 #include "USBHostConf.h"
va009039 13:8774c07f12a5 3 #include "USBHost.h"
va009039 13:8774c07f12a5 4 #include "BaseUvc.h"
va009039 13:8774c07f12a5 5
va009039 18:61554f238584 6 void BaseUvc::poll() {
va009039 13:8774c07f12a5 7 uint8_t buf[ep_iso_in->getSize()];
va009039 13:8774c07f12a5 8 int result = host->isochronousReadNB(ep_iso_in, buf, sizeof(buf));
va009039 13:8774c07f12a5 9 if (result >= 0) {
va009039 18:61554f238584 10 const uint16_t frame = 0;
va009039 13:8774c07f12a5 11 onResult(frame, buf, ep_iso_in->getLengthTransferred());
va009039 13:8774c07f12a5 12 }
va009039 13:8774c07f12a5 13 }
va009039 13:8774c07f12a5 14
va009039 18:61554f238584 15 USB_TYPE BaseUvc::Control(int req, int cs, int index, uint8_t* buf, int size) {
va009039 13:8774c07f12a5 16 if (req == SET_CUR) {
va009039 13:8774c07f12a5 17 return host->controlWrite(dev,
va009039 13:8774c07f12a5 18 USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE,
va009039 13:8774c07f12a5 19 req, cs<<8, index, buf, size);
va009039 13:8774c07f12a5 20 }
va009039 13:8774c07f12a5 21 return host->controlRead(dev,
va009039 13:8774c07f12a5 22 USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE,
va009039 13:8774c07f12a5 23 req, cs<<8, index, buf, size);
va009039 13:8774c07f12a5 24 }
va009039 13:8774c07f12a5 25
va009039 18:61554f238584 26 USB_TYPE BaseUvc::setInterfaceAlternate(uint8_t intf, uint8_t alt) {
va009039 13:8774c07f12a5 27 return host->controlWrite(dev, USB_HOST_TO_DEVICE | USB_RECIPIENT_INTERFACE,
va009039 13:8774c07f12a5 28 SET_INTERFACE, alt, intf, NULL, 0);
va009039 13:8774c07f12a5 29 }
va009039 13:8774c07f12a5 30
va009039 13:8774c07f12a5 31 void BaseUvc::onResult(uint16_t frame, uint8_t* buf, int len)
va009039 13:8774c07f12a5 32 {
va009039 13:8774c07f12a5 33 if(m_pCbItem && m_pCbMeth)
va009039 13:8774c07f12a5 34 (m_pCbItem->*m_pCbMeth)(frame, buf, len);
va009039 13:8774c07f12a5 35 else if(m_pCb)
va009039 13:8774c07f12a5 36 m_pCb(frame, buf, len);
va009039 13:8774c07f12a5 37 }
va009039 13:8774c07f12a5 38
va009039 13:8774c07f12a5 39 void BaseUvc::setOnResult( void (*pMethod)(uint16_t, uint8_t*, int) )
va009039 13:8774c07f12a5 40 {
va009039 13:8774c07f12a5 41 m_pCb = pMethod;
va009039 13:8774c07f12a5 42 m_pCbItem = NULL;
va009039 13:8774c07f12a5 43 m_pCbMeth = NULL;
va009039 13:8774c07f12a5 44 }
va009039 13:8774c07f12a5 45
va009039 13:8774c07f12a5 46 void BaseUvc::clearOnResult()
va009039 13:8774c07f12a5 47 {
va009039 13:8774c07f12a5 48 m_pCb = NULL;
va009039 13:8774c07f12a5 49 m_pCbItem = NULL;
va009039 13:8774c07f12a5 50 m_pCbMeth = NULL;
va009039 13:8774c07f12a5 51 }
va009039 13:8774c07f12a5 52