Content originally posted in LPCWare by gnxp on Mon Feb 23 06:11:42 MST 2015
Hello,
I deleted a similar previous post after realising some gaps in my understanding. This post is to ask my query more clearly.
Environment - LPCUSB for lpc1769(from code RDB CMSIS)
After browsing some forum topics, I decided to use LPCUSB(Bertrik Sikken) as I found the code simple to follow.
I am failing here -
When I transfer more than 64 bytes on BulkIn, I expect to get a BulkIn Ack after transfer is completed.
Procedure is simple -
1. First 'NextBulkIn' call is from my firmware. I set BulkInBusy = true; Step 1 happens only if BulkInBusy is false.
2. Read data from buffer, send to EP. If data>64 bytes, BulkInBusy stays true.
I expect to get a BulkIn ACK interrupt. Read data from buffer again and send to EP. If data <64 this time or 0, set BulkIn to false.
3. This allows me to start from step1 again.
The issue is I don't get any BulkIn ACK interrupts.
###################################################
static void NextBulkIn(U8 bEP)
{
/** Read cnt from buff and do USBHwEPWrite **/
if (cnt < MAX_PACKET_SIZE)
BulkInBusy = false;
}
static void BulkIn(U8 bEP, U8 bEPStatus)
{
if (bEPStatus & EP_STATUS_ERROR)
goto err;
if (bEPStatus & EP_STATUS_STALLED)
goto err;
if (bEPStatus & EP_STATUS_DATA)// No buffer empty
goto err;
NextBulkIn(bEP);
return;
err:
BulkInBusy = false;
}
#########################################################
First call to NextBulkIn is from firmware if BulkInBusy =false;
I am sure interrupts are enabled
##################################################
From Init func,
USBHwRegisterEPIntHandler(BULK_IN_EP, BulkIn);
which calls in LPCUSB
void USBHwRegisterEPIntHandler(U8 bEP, TFnEPIntHandler *pfnHandler)
{
int idx;
idx = EP2IDX(bEP);
ASSERT(idx<32);
/* add handler to list of EP handlers */
_apfnEPIntHandlers[idx / 2] = pfnHandler;
/* enable EP interrupt */
LPC_USB->USBEpIntEn |= (1 << idx);
LPC_USB->USBDevIntEn |= EP_SLOW;
}
From init function
USBHwNakIntEnable(0)
which calls in LPCUSB
void USBHwNakIntEnable(U8 bIntBits)
{
USBHwCmdWrite(CMD_DEV_SET_MODE, bIntBits);
}
############################################################################
So if I am setting cmd data to be 0 for DEV_SET_MODE, I think all ACK's should be enabled.
So if USBEpIntEn , USBDevIntEn and DEV_SET_MODE all are OK, any clues why am I still not receiving any BulkIn ACK interrupts.