![](/images/new-backgrounds/1171214/17121439x1.webp)
Introduction | www.ti.com |
User Case 4: An example of how to do host negotiation to support USB
If the HOSTREQ bit in the DEVCTL register is set, host negotiation is performed by the hardware when the device enters suspend mode. The bit is cleared when host negotiation is complete.
User Case 5: An example of how to program the USB DMA controller
Example 4. Programming the USB DMA Controller
//Number of DMA channels #define NUM_CHANNEL 4
//Number of DMA buffers to allocate #define RX_BUFFERS 32
#define TX_BUFFERS 32
//Memory region to place DMA buffers and descriptors #define MEMORY_TARGET ".DDREMIF_0_BUF"
//DMA defines
#define SOP | (Uint32) (1<<31) |
#define EOP | (Uint32) (1<<30) |
#define OWNER | (Uint32) (1<<29) |
#define EOQ | (Uint32) (1<<28) |
#define ZERO_BYTE | (Uint32) (1<<23) |
#define RX_ABORT | (Uint32) (1<<19) |
//DMA channel configuration #define CH0 0
#define CH1 1 #define CH2 2 #define CH3 3
//Loop variable
int I;
//Variable to keep track of errors int error = 0;
//Variable to keep track of the number of descriptors built
int | tx_desc[NUM_CHANNEL]; | // | Current | TX | Buffer | descriptor[channel | number] |
int | rx_desc[NUM_CHANNEL]; | // | Current | RX | Buffer | descriptor[channel | number] |
//Separate data section for bufferDesc. NOTE: CPPI buffers MUST be aligned to
#pragma DATA_SECTION(rx_bufferDesc, MEMORY_TARGET) Uint32 rx_bufferDesc[NUM_CHANNEL][RX_BUFFERS];
#pragma DATA_SECTION(tx_bufferDesc, MEMORY_TARGET) Uint32 tx_bufferDesc[NUM_CHANNEL][TX_BUFFERS];
// Initialize CPPI DMA. | This code | is also included in the controller initialization. | |
//Disable | the RX | DMA | |
//Disable | the TX | DMA | |
for(I = 0; i<NUM_CHANNEL;i++) { // | Initialize CPPI DMA state | ||
0; | |||
0; | |||
0; | |||
0; | |||
0; | |||
0; |
20 | Universal Serial Bus (USB) Controller |