Texas Instruments TMS320DM357 Switch User Manual


 
Introduction
www.ti.com
UserCase4:AnexampleofhowtodohostnegotiationtosupportUSB
IftheHOSTREQbitintheDEVCTLregisterisset,hostnegotiationisperformedbythehardwarewhen
thedeviceenterssuspendmode.Thebitisclearedwhenhostnegotiationiscomplete.
UserCase5:AnexampleofhowtoprogramtheUSBDMAcontroller
Example4.ProgrammingtheUSBDMAController
//NumberofDMAchannels
#defineNUM_CHANNEL4
//NumberofDMAbufferstoallocate
#defineRX_BUFFERS32
#defineTX_BUFFERS32
//MemoryregiontoplaceDMAbuffersanddescriptors
#defineMEMORY_TARGET".DDREMIF_0_BUF"
//DMAdefines
#defineSOP(Uint32)(1<<31)
#defineEOP(Uint32)(1<<30)
#defineOWNER(Uint32)(1<<29)
#defineEOQ(Uint32)(1<<28)
#defineZERO_BYTE(Uint32)(1<<23)
#defineRX_ABORT(Uint32)(1<<19)
//DMAchannelconfiguration
#defineCH00
#defineCH11
#defineCH22
#defineCH33
//Loopvariable
intI;
//Variabletokeeptrackoferrors
interror=0;
//Variabletokeeptrackofthenumberofdescriptorsbuilt
inttx_desc[NUM_CHANNEL];//CurrentTXBufferdescriptor[channelnumber]
intrx_desc[NUM_CHANNEL];//CurrentRXBufferdescriptor[channelnumber]
//SeparatedatasectionforbufferDesc.NOTE:CPPIbuffersMUSTbealignedto16-byte
boundaries.
#pragmaDATA_SECTION(rx_bufferDesc,MEMORY_TARGET)
Uint32rx_bufferDesc[NUM_CHANNEL][RX_BUFFERS];
#pragmaDATA_SECTION(tx_bufferDesc,MEMORY_TARGET)
Uint32tx_bufferDesc[NUM_CHANNEL][TX_BUFFERS];
//InitializeCPPIDMA.Thiscodeisalsoincludedinthecontrollerinitialization.
usbRegs->RCPPICR=0;//DisabletheRXDMA
usbRegs->TCPPICR=0;//DisabletheTXDMA
for(I=0;i<NUM_CHANNEL;i++){//InitializeCPPIDMAstate
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;
20UniversalSerialBus(USB)ControllerSPRUGH3November2008
SubmitDocumentationFeedback