Use Cases
1395
SPRUH91D – March 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Universal Serial Bus 2.0 (USB) Controller
31.3.4 User Case 4: Example of How to Program the USB DMA Controller
Example 31-5. Programming the USB DMA Controller
typedef struct {
Uint32 PktLength:22;
Uint32 ProtSize:5;
Uint32 HostPktType:5; // This should be 16
}HPDWord0;
typedef struct {
Uint32 DstTag:16;
//bits[15:0] always Zero
Uint32 SrcSubChNum:5;
//bits[20:16] always Zero
Uint32 SrcChNum:6;
//bits[26:21]
Uint32 SrcPrtNum:5;
//bits[31:27]
}HPDWord1;
typedef struct {
Uint32 PktRetQueue:12;
//bits[11:0]
Uint32 PktRetQM:2;
//bits[13:12]
Uint32 OnChip:1;
//bit[14]
Uint32 RetPolicy:1;
//bit[15]
Uint32 ProtoSpecific:4;
//bits[19:16]
Uint32 Rsv:6;
//bits[25:20]
Uint32 PktType:5;
//bits[30:26]
Uint32 PktErr:1;
//bit[31]
}HPDWord2;
typedef struct hostPacketDesc {
HPDWord0 HPDword0;
HPDWord1 HPDword1;
HPDWord2 HPDword2;
Uint32 HPDword3buffLength;
Uint32 HPDword4buffAdd;
Uint32 HPDword5nextHBDptr;
Uint32 HPDword6orgBuffLength;
Uint32 HPDword7orgBuffAdd;
} HostPacketDesc;
// The following sample code uses region 0 for all of the ports. Ports/Channels/EPs are not
limited to a single region
void initSingleHPDorHBD(Uint16 descNum, dataDir dir, descType desc, Uint16 returnQueue) {
/*
*******************************************************************************************
Initialize a Single Transmit and Receive Host Packet or Buffer Descriptor
*/
if ((desc==PACKET_DESC) & (dir==TRANSMIT))
region0DescriptorSpace[descNum].HPDword0.HostPktType=16;
//This value
is always fixed. For Packet Type Decriptors=16
else
region0DescriptorSpace[descNum].HPDword0.HostPktType=0;
//Word0,
Word1, and Half of Word2 are Reserved for Buffer Descriptors.
region0DescriptorSpace[descNum].HPDword0.ProtSize=0;
if ((dir==TRANSMIT) & (desc==PACKET_DESC)) {