Texas Instruments TMS320DM357 User Manual
Page 18
Introduction
www.ti.com
User Case 3: An example of how to program the USB endpoints in host mode
Example 3. Programming the USB Endpoints in Host Mode
// DMA channel number.
Valid values are 0, 1, 2, or 3.
int CHAN_NUM = 0;
// Fifo sizes: uncomment the desired size.
// This example uses 64-byte fifo.
// int fifosize = 0;
// 8 bytes
// int fifosize = 1;
// 16 bytes
// int fifosize = 2;
// 32 bytes
int fifosize = 3;
// 64 bytes
// int fifosize = 4;
// 128 bytes
// int fifosize = 5;
// 256 bytes
// int fifosize = 6;
// 512 bytes
// int fifosize = 7;
// 1024 bytes
// int fifosize = 8;
// 2048 bytes
// int fifosize = 9;
// 4096 bytes
// FIFO address.
Leave 64-bytes for endpoint 0.
int fifo_start_address = 8;
// Uncomment the desired buffering.
If double-buffer is selected, actual
// FIFO space will be twice the value listed above for fifosize.
// This example uses single buffer.
int double_buffer = 0;
// Single-buffer
// int double_buffer = 1;
// Double-buffer
// Set the following variable to the device endpoint type: CONTROL ISO BULK or IN
int device_protocol = BULK;
//int device_protocol = ISO;
//int device_protocol = INT;
// USB speeds
#define LOW_SPEED 0
#define FULL_SPEED 1
#define HIGH_SPEED 2
// TXTYPE protocol
#define CONTROL 0
#define ISO 1
#define BULK 2
#define INT 3
// For maximum packet size this formula will usually work, but it can also be
// set to another value if needed.
If non power of 2 value is needed (such as
// 1023) set it explicitly. // Set the following variable to the device address. // Set the following variable to the device endpoint number. // Variable used for endpoint configuration // Variable to keep track of errors // The following code should be run after resetting the attached device // Initialize the endpoint FIFO. RX and TX will be allocated the same sizes. usbRegs->INDEX = CHAN_NUM+1; 18 Universal Serial Bus (USB) Controller SPRUGH3 – November 2008
#define FIFO_MAXP 8*(1<
int device_address = 1;
int device_ep = 1;
Uint8 type = 0;
int error = 0;
usbRegs->RXFIFOSZ = fifosize | ((double_buffer & 1)<<4);
usbRegs->RXFIFOADDR = fifo_start_address;