Use Cases
1685
SPRUH82C – April 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Universal Serial Bus 2.0 (USB) Controller
Example 34-5. Programming the USB DMA Controller (continued)
usbRegs->RXCSR.PERI_RXCSR&=0x77FF;
// Clear AUTOCLEAR and DMAReqMode
usbRegs->RXCSR.PERI_RXCSR|=0x2000;
// Set DMAReqEnab
usbRegs->INDEX=index_save;
}
Uint32 readCompletionQueue(Uint16 queueNum) {
Uint32 DescAddress;
DescAddress=(Uint32)usbRegs->QCTRL[queueNum].CTRLD;
DescAddress&=0xFFFFFFE0;
return(DescAddress);
}
void disableCoreRxDMA(Uint16 endPoint) {
Uint16 index_save;
index_save=usbRegs->INDEX;
usbRegs->INDEX=endPoint;
usbRegs->RXCSR.PERI_RXCSR &= 0xDFFF;
// Clear DMAReqEnab
usbRegs->INDEX=index_save;
}
void disableCoreTxDMA(Uint16 endPoint) {
Uint16 index_save;
index_save=usbRegs->INDEX;
usbRegs->INDEX=endPoint;
usbRegs->TXCSR.PERI_TXCSR&=0x7FFF;
// Clear AUTOSET
usbRegs->TXCSR.PERI_TXCSR&=0xEBFF;
// Clear DMAReqEnab & DMAReqMode
usbRegs->INDEX=index_save;
}
// sample peripheral code
Uint16 usbMain(void) {
usb_init();
usb_device_init();
// initialize usb core related vars: index, fifo, etc and DMA related
vars, data buff, rx/txSubmitQ, etc
wait_for_reset();
// wait here until host performs a reset.
cppiDmaInit();
// Init CPPI 4.1 DMA
// ****************** Initialize Receive Buffer Descriptors ************************************
// Host is performing a transfer and the device is going to loop it back out.
// The example below (non commented part of the code) applies for a data transfer made of two 64
bytes packet.
// These two packets are treated as part of a single transfer for Non-
Transparent DMA modes and as two transfers for Transparent
//
DMA mode. This needs to be understood for the below to make sense, especially the last
Descriptor shown below.
// Initialize receive descriptors (HBDs)
initSingleHPDorHBD(0,RECEIVE,BUFFER_DESC,rxCompQ);
//Usage:
initSingleHPDorHBD(descNum,dir,TypeOfDesc,returnQueue)
if (DESCsetup==MULTIPLE_DESC_SETUP) {
initSingleHPDorHBD(1,RECEIVE,BUFFER_DESC,rxCompQ);
//Usage:
initSingleHPDorHBD(descNum,dir,TypeOfDesc,returnQueue)
//
initSingleHPDorHBD(2,RECEIVE,BUFFER_DESC,rxCompQ);
//Usage:
initSingleHPDorHBD(descNum,dir,TypeOfDesc,returnQueue)
//
initSingleHPDorHBD(3,RECEIVE,BUFFER_DESC,rxCompQ);
//Usage:
initSingleHPDorHBD(descNum,dir,TypeOfDesc,returnQueue)
//
:
//
:
}
// Last Receive Descriptor creation (this is the case where two or three Buffer Descriptors are
needed).
// Note again that this example is for a two packet data transfer.
if (DMAmode!=TRANSPARENT) {
// Need to Create the Descriptor to be used for the Null
Packet.