USB host library, support isochronous,bulk,interrupt and control.

Dependents:   BaseUsbHost_example BaseJpegDecode_example SimpleJpegDecode_example

Import programBaseUsbHost_example

BaseUsbHost example program

Committer:
va009039
Date:
Mon Feb 11 12:00:47 2013 +0000
Revision:
5:8a2d056e9b38
Parent:
4:d931d24c2f81
add GetStringDescriptor()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 4:d931d24c2f81 1 // BaseUsbHostBlkEp.cpp 2013/1/25
va009039 0:b7d6879637a8 2 #include "mbed.h"
va009039 0:b7d6879637a8 3 #include "rtos.h"
va009039 0:b7d6879637a8 4 #include "BaseUsbHost.h"
va009039 4:d931d24c2f81 5 //#define DEBUG
va009039 0:b7d6879637a8 6 #include "BaseUsbHostDebug.h"
va009039 0:b7d6879637a8 7 #define TEST
va009039 0:b7d6879637a8 8 #include "BaseUsbHostTest.h"
va009039 0:b7d6879637a8 9
va009039 0:b7d6879637a8 10 BulkEp::BulkEp(int addr, uint8_t ep, uint16_t size): BaseEp(addr, ep, size)
va009039 0:b7d6879637a8 11 {
va009039 4:d931d24c2f81 12 HCTD* td = new HCTD(this);
va009039 0:b7d6879637a8 13 m_pED->TailTd = td;
va009039 0:b7d6879637a8 14 m_pED->HeadTd = td;
va009039 2:fe1e62051d88 15 TEST_ASSERT(td);
va009039 2:fe1e62051d88 16 if (td == NULL) {
va009039 2:fe1e62051d88 17 return;
va009039 2:fe1e62051d88 18 }
va009039 4:d931d24c2f81 19 m_pED->Next = reinterpret_cast<HCED*>(LPC_USB->HcBulkHeadED);
va009039 0:b7d6879637a8 20 LPC_USB->HcBulkHeadED = reinterpret_cast<uint32_t>(m_pED);
va009039 3:ae77d63a1eda 21
va009039 0:b7d6879637a8 22 DBG_OHCI(LPC_USB->HcBulkHeadED);
va009039 0:b7d6879637a8 23 DBG_ED(m_pED);
va009039 3:ae77d63a1eda 24 }
va009039 0:b7d6879637a8 25
va009039 3:ae77d63a1eda 26 void BulkEp::enable()
va009039 3:ae77d63a1eda 27 {
va009039 0:b7d6879637a8 28 LPC_USB->HcCommandStatus |= OR_CMD_STATUS_BLF;
va009039 0:b7d6879637a8 29 LPC_USB->HcControl |= OR_CONTROL_BLE;
va009039 0:b7d6879637a8 30 }
va009039 0:b7d6879637a8 31
va009039 1:3b7bc4f87a61 32 int BulkEp::bulkReceive(uint8_t* buf, int len, int millisec)
va009039 0:b7d6879637a8 33 {
va009039 3:ae77d63a1eda 34 return send_receive(buf, len, millisec);
va009039 0:b7d6879637a8 35 }
va009039 0:b7d6879637a8 36
va009039 1:3b7bc4f87a61 37 int BulkEp::bulkSend(const uint8_t* buf, int len, int millisec)
va009039 0:b7d6879637a8 38 {
va009039 3:ae77d63a1eda 39 return send_receive(const_cast<uint8_t*>(buf), len, millisec);
va009039 0:b7d6879637a8 40 }