beautypg.com

6 industry standard(s) compliance statement, Statement – Texas Instruments TMS320DM357 User Manual

Page 22

background image

1.6

Industry Standard(s) Compliance Statement

Introduction

www.ti.com

Example 4. Programming the USB DMA Controller (continued)

// Increment descriptor counter
tx_desc[ch]++;

}

// Routine to start the RX DMA for a given channel
void start_rx_dma(int ch) {

int index_save;

index_save = usbRegs->INDEX;

// Save the index to restore later

// Must have at least 3 descriptors to receive anything
if (rx_desc[ch] < 2) {error++;} else {

usbRegs->INDEX = ch+1;
usbRegs->RCPPICR = 1; //Enable Rx CPPI DMA
usbRegs->CHANNEL[ch].RCPPIDMASTATEW1 = (Uint32)(&rx_bufferDesc[ch][0]);
CSL_FINS(usbRegs->PERI_RXCSR,USB_PERI_RXCSR_DMAEN,1);

// Update the buffer count register.

This ADDS to the existing value, does not

overwrite.

switch (ch) {

case 0: usbRegs->RBUFCNT0 = rx_desc[ch]; break;
case 1: usbRegs->RBUFCNT1 = rx_desc[ch]; break;
case 2: usbRegs->RBUFCNT2 = rx_desc[ch]; break;
case 3: usbRegs->RBUFCNT3 = rx_desc[ch]; break;

}

}
usbRegs->INDEX = index_save;

// Restore the index to previous value

}

//Function to build Rx DMA descriptors
void add_rx_descriptor(int ch, unsigned char * outBuf, int bytes) {

int index_save;

index_save = usbRegs->INDEX;

// Save the index to restore later

if (bytes < 1) {bytes = 64; error++;}
usbRegs->INDEX = ch+1;

// Link previous buffer to this one if this is not the first descriptor of the channel
if (rx_desc[ch] > 0) rx_bufferDesc[ch][4*(rx_desc[ch]-1)] =

(Uint32)(&rx_bufferDesc[ch][4*rx_desc[ch]]);

rx_bufferDesc[ch][4*rx_desc[ch]+0] = (Uint32)(0x00000000);

// Next descriptor

rx_bufferDesc[ch][4*rx_desc[ch]+1] = (Uint32)outBuf;

// Buffer address

rx_bufferDesc[ch][4*rx_desc[ch]+2] = (0x0000 << 16) | bytes;

// Rx buffer size in bytes

rx_bufferDesc[ch][4*rx_desc[ch]+3] = OWNER | 0;

// OWNER

rx_desc[ch]++;

usbRegs->INDEX = index_save;

// Restore the index to previous value

}

This device conforms to USB 2.0 Specification and On-The-Go Supplement to the USB 2.0 Specification
Rev 1.0a.

22

Universal Serial Bus (USB) Controller

SPRUGH3 – November 2008

Submit Documentation Feedback