beautypg.com

Texas Instruments TMS320DM357 User Manual

Page 20

background image

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 16-byte

boundaries.
#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.

usbRegs->RCPPICR = 0;

//Disable the RX DMA

usbRegs->TCPPICR = 0;

//Disable the TX DMA

for(I = 0; i

usbRegs->CHANNEL[i].TCPPIDMASTATEW0 = 0;
usbRegs->CHANNEL[i].TCPPIDMASTATEW1 = 0;
usbRegs->CHANNEL[i].TCPPIDMASTATEW2 = 0;
usbRegs->CHANNEL[i].TCPPIDMASTATEW3 = 0;
usbRegs->CHANNEL[i].TCPPIDMASTATEW4 = 0;
usbRegs->CHANNEL[i].TCPPIDMASTATEW5 = 0;

usbRegs->CHANNEL[i].RCPPIDMASTATEW0 = 0;

usbRegs->CHANNEL[i].RCPPIDMASTATEW1 = 0;
usbRegs->CHANNEL[i].RCPPIDMASTATEW2 = 0;
usbRegs->CHANNEL[i].RCPPIDMASTATEW3 = 0;
usbRegs->CHANNEL[i].RCPPIDMASTATEW4 = 0;
usbRegs->CHANNEL[i].RCPPIDMASTATEW5 = 0;

20

Universal Serial Bus (USB) Controller

SPRUGH3 – November 2008

Submit Documentation Feedback