![](/images/new-backgrounds/1171214/17121433x1.webp)
www.ti.com | Introduction |
User Case 2: An example of how to program the USB Endpoints in peripheral mode
Example 2. Programming the USB Endpoints in Peripheral 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; //
//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 = 0;
//The following code should be run after receiving a USB reset from the host.
//Initialize the endpoint FIFO. RX and TX will be allocated the same sizes.
//Force Data Toggle is optional for interrupt traffic. Uncomment if needed.
//
//Uncomment below to configure the endpoint for ISO and not respond with a
//handshake packet.
//
//
//After receiving a successful
//to the specified address immediately following the status stage.
Universal Serial Bus (USB) Controller | 17 |