With some help from the forum, I was able to get the chip to enumerate the other day, and now that that's working, I'm trying to send data through it using DMA to get the data from the host. I've tried to copy the USBBulkLoopManualInOut project.
To configure the endpoint, I:
- call CyU3PSetEpConfig()
- ep == <endpoint address parsed out of the descriptor, 0x02, 0x04 for output, and 0x86, 0x88 for input
- enable = CyTrue
- epType = <a type code I parsed out of the descriptor, in this case interrupt>
- burstLen = 1
- streams = 0
- pcktSize = <also parsed out of the descriptor, in this case, either 256 or 512
- call CyU3PDmaChannelCreate()
- pass in a pointer to a CyU3PDmaChannel in my endpoint struct to keep track of it
- CyU3PDmaType_t type is CY_U3P_DMA_TYPE_MANUAL_OUT if the high bit of the endpoint address is 1, and CY_U3P_DMA_TYPE_MANUAL_IN otherwise
- if the high bit of the endpoint address is 1, the prodSckId is CY_U3P_UIB_SOCKET_PROD_0 + <the numeric part of the endpoint address, and the consSckId is CY_U3P_CPU_SOCKET_CONS. Otherwise, the prodSckId is CY_U3P_CPU_SOCKET_PROD and the consSckId is CY_U3P_UIB_SOCKET_CONS_0 + the numeric part of the endpoint address.
- dmaMode = CY_U3P_DMA_MODE_BYTE
- notification, prodHeader, prodFooter, consHeader, prodAvailCount are all 0
- cb is NULL
- call CyU3PDmaChannelSetXfer
- pass in the same pointer to a CyU3PDmaChannel, and zero for unlimited transfers
- call CyU3PUsbFlushEp, passing the address from before. Originally I didn't have this, but I figured it couldn't hurt.
So far so good. Nothing returns an error code.
When I go to get data, I:
- call a function I've written to get the CyU3PDmaChannel pointer for the address 2.
- Address 2 is supposed to be an endpoint that will allow me to receive data from the host.
- I've verified with the debugger that it's returning the same handle out of my endpoint struct for the endpoint address I put in.
- I've tried calling CyU3PDmaChannelResume here with that pointer to enable both producer and consumer, but it doesn't seem to do anything.
- call CyU3PDmaChannelGetBuffer(<the previously mentioned pointer>, the address of a buffer struct, either CYU3P_WAIT_FOREVER or CYU3P_NO_WAIT)
- NO_WAIT returns a timeout immediately, even once I've sent data from the Control Center
- WAIT_FOREVER doesn't return at all, even once I've sent data from the Control Center
- CyU3PDmaChannelDiscardBuffer to clean up the buffer.
I'll include my source code, but does anyone know what I'm missing, or what I've done wrong?
Thank you for your help!
FX3_Sx2Substitute.zip 562.2 K