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
BaseUsbHostIntEp.cpp
- Committer:
- va009039
- Date:
- 2012-12-04
- Revision:
- 0:b7d6879637a8
- Child:
- 1:3b7bc4f87a61
File content as of revision 0:b7d6879637a8:
// BaseUsbHostIntEp.cpp 2012/12/4
#include "mbed.h"
#include "rtos.h"
#include "BaseUsbHost.h"
#define DEBUG
#include "BaseUsbHostDebug.h"
#define TEST
#include "BaseUsbHostTest.h"
InterruptEp::InterruptEp(int addr, uint8_t ep, uint16_t size, int lowSpeed)
:BaseEp(addr, ep, size, lowSpeed)
{
HCTD* td = new_HCTD();
TEST_ASSERT(td);
m_pED->TailTd = td;
m_pED->HeadTd = td;
HCCA* pHcca = reinterpret_cast<HCCA*>(LPC_USB->HcHCCA);
TEST_ASSERT(pHcca);
int n = 0;
m_pED->Next = pHcca->InterruptTable[n];
pHcca->InterruptTable[n] = reinterpret_cast<uint32_t>(m_pED);
LPC_USB->HcControl |= OR_CONTROL_PLE;
}
int InterruptEp::read(uint8_t* buf, int len, int millisec)
{
if (m_td_queue_count == 0) {
HCTD* data_td = m_pED->TailTd;
TEST_ASSERT(data_td);
data_td->Control |= TD_IN;
data_td->CurrBufPtr = buf;
data_td->BufEnd = const_cast<uint8_t*>(buf)+len-1;
HCTD* blank_td = new_HCTD();
TEST_ASSERT(blank_td);
data_td->Next = reinterpret_cast<uint32_t>(blank_td);
m_pED->TailTd = blank_td;
m_td_queue_count++;
DBG_ED(m_pED);
LPC_USB->HcControl |= OR_CONTROL_PLE; // Enable Periodic
}
HCTD* td = get_queue_HCTD(millisec);
if (td) {
DBG_TD(td);
int ret = len;
if (td->CurrBufPtr) {
ret = td->CurrBufPtr - buf;
}
delete_HCTD(td);
m_td_queue_count--;
return ret;
}
return USB_TIMEOUT;
}