
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
// 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
//Uncomment the desired buffering. If
//FIFO space will be twice the value listed above for fifosize.
//This example uses single buffer.
int double_buffer = 0; //
//int double_buffer = 1; //
//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.
#define FIFO_MAXP 8*(1<<fifosize);
//Set the following variable to the device address. int device_address = 1;
//Set the following variable to the device endpoint number. int device_ep = 1;
//Variable used for endpoint configuration
Uint8 type = 0;
//Variable to keep track of errors int error = 0;
//The following code should be run after resetting the attached device
//Initialize the endpoint FIFO. RX and TX will be allocated the same sizes.
18 | Universal Serial Bus (USB) Controller | |
|
| Submit Documentation Feedback |