
Introduction | www.ti.com |
Example 4. Programming the USB DMA Controller (continued)
//Increment descriptor counter tx_desc[ch]++;
}
//Routine to start the RX DMA for a given channel void start_rx_dma(int ch) {
int index_save;
index_save = | // Save the index to restore later |
//Must have at least 3 descriptors to receive anything if (rx_desc[ch] < 2) {error++;} else {
//Update the buffer count register. This ADDS to the existing value, does not
overwrite.
switch (ch) {
case 0:
case 1:
case 2:
case 3:
} |
|
} |
|
// Restore the index to previous value | |
} |
|
//Function to build Rx DMA descriptors |
|
|
void add_rx_descriptor(int ch, unsigned char * | outBuf, int bytes) { | |
int index_save; |
|
|
index_save = | // | Save the index to restore later |
if (bytes < 1) {bytes = 64; error++;}
//Link previous buffer to this one if this is not the first descriptor of the channel if (rx_desc[ch] > 0)
(Uint32)(&rx_bufferDesc[ch][4*rx_desc[ch]]);
rx_bufferDesc[ch][4*rx_desc[ch]+0] = (Uint32)(0x00000000); | // Next descriptor | |
rx_bufferDesc[ch][4*rx_desc[ch]+1] = (Uint32)outBuf; | // Buffer address | |
rx_bufferDesc[ch][4*rx_desc[ch]+2] = (0x0000 << 16) bytes; | // Rx buffer size in bytes | |
rx_bufferDesc[ch][4*rx_desc[ch]+3] = OWNER 0; | // OWNER | |
rx_desc[ch]++; |
|
|
// Restore the index to previous value |
}
1.6Industry Standard(s) Compliance Statement
This device conforms to USB 2.0 Specification and
22 | Universal Serial Bus (USB) Controller |