Instances of this class handle an interface to the high-speed USB device This device is theoretically capable of speeds up to 400 Mbps.
More...
#include <core/DspHsUsb.h>
List of all members.
Classes |
struct | usbBuffer |
| The tsUsbBuffer structure is used to provide internal buffering for incoming and outgoing data. More...
|
Public Member Functions |
| tcDspHsUsb (void *apAddress, int anRxBuffers=256, int anTxBuffers=16, int anThreadPrio=14) |
| This constructor is used to open a DspHsUsb interface with the specified settings (optional).
|
virtual | ~tcDspHsUsb () |
| This destructor is used to close up and free the resources tied to the associated high-speed USB interface.
|
int | put (const void *apBuff, int anLen) |
| This routine places a buffer of characters of arbitrary length onto the TX FIFO.
|
int | get (void *apBuff, int anMaxLen) |
| This routine gets data off the receive FIFO and places it in the supplied buffer.
|
void | enable (bool abState) |
| Enables the HS-USB interface.
|
void | setTimeout (unsigned int anMsec) |
| This method is used to set the firmware RX FIFO timeout.
|
unsigned int | getTimeout (void) |
| This method returns the current firmware RX FIFO timeout.
|
void | registerSemaphores (SEM_Handle ahRxAvail, SEM_Handle ahTxEmpty) |
| This method registers semaphores that are incremented when receive data becomes available (RX FIFO transitions from empty to not empty), and when all transmit data has been sent (TX FIFO transitions from not empty to empty).
|
Static Public Attributes |
static const unsigned int | gnTimeoutMin = 1 |
| min/max RX FIFO timeouts (how long data is allowed to sit in firmware FIFO)
|
static const unsigned int | gnTimeoutMax = 1023 |
Protected Member Functions |
void | usbRxDmaThread (void) |
| This thread pends on RX DMA completion, finishes any odd bytes required, updates the RX FIFO tail, and reenables interrupts to continue processing.
|
void | usbTxDmaThread (void) |
| This thread pends on TX DMA completion, finishes any odd bytes required, updates the TX FIFO head, and reenables interrupts to continue processing.
|
void | usbInterrupt (void) |
| Interrupt service routine for the HS-USB.
|
void | enableRxInts (bool abEnable) |
| This private method enables or disables RX FIFO interrupts as directed.
|
void | enableTxInts (bool abEnable) |
| This private method enables or disables TX FIFO interrupts as directed.
|
Static Protected Member Functions |
static int | interrupt_dispatch (Arg arMyObject) |
| Static interrupt dispatch routine.
|
static int | thread_dispatch (Arg arMyObject, Arg abIsRx) |
| Static thread dispatch routine.
|
Detailed Description
Instances of this class handle an interface to the high-speed USB device This device is theoretically capable of speeds up to 400 Mbps.
- See also:
- tcDspHsUsb Page
Member Typedef Documentation
The tsUsbBuffer structure is used to provide internal buffering for incoming and outgoing data.
The number of buffers available is set by the constructor.
Constructor & Destructor Documentation
tcDspHsUsb::tcDspHsUsb |
( |
void * |
apAddress, |
|
|
int |
anRxBuffers = 256 , |
|
|
int |
anTxBuffers = 16 , |
|
|
int |
anThreadPrio = 14 |
|
) |
| |
This constructor is used to open a DspHsUsb interface with the specified settings (optional).
The interface is not yet enabled for sending/receiving following construction.
- Parameters:
-
[in] | apAddress | Base Address of ADC core. |
[in] | anRxBuffers | Number of RX buffers in pool (each 1/2 size of the firmware TX FIFO). |
[in] | anTxBuffers | Number of RX buffers in pool (each 1/2 size of the firmware RX FIFO). |
[in] | anThreadPrio | Priority to run the RX and TX DMA monitor threads. |
- Returns:
- None.
- See also:
- DspHsUsb.h
tcDspHsUsb::~tcDspHsUsb |
( |
| ) |
|
|
virtual |
This destructor is used to close up and free the resources tied to the associated high-speed USB interface.
- Returns:
- None.
- See also:
- DspHsUsb.h
Member Function Documentation
int tcDspHsUsb::put |
( |
const void * |
apBuff, |
|
|
int |
anLen |
|
) |
| |
This routine places a buffer of characters of arbitrary length onto the TX FIFO.
If the transmitter is idle, it is restarted. If the entire message is not transmitted, it is up to the application to decide whether and when to retry the unsent portion of the data.
- Parameters:
-
[in] | apBuff | Buffer pointer. |
[in] | anLen | Bytes in the supplied buffer. |
- Returns:
- The number of bytes successfully placed on the TX FIFO.
- See also:
- DspHsUsb.h
int tcDspHsUsb::get |
( |
void * |
apBuff, |
|
|
int |
anMaxLen |
|
) |
| |
This routine gets data off the receive FIFO and places it in the supplied buffer.
Data is retrieved until either the FIFO is empty, or the maximum size of the supplied buffer is reached. The routine does not block when no data is available.
- Parameters:
-
[in] | apBuff | Location to store received data. |
[in] | anMaxLen | Maximum number of bytes to store in apBuff. |
- Returns:
- The number of bytes actually read.
void tcDspHsUsb::enable |
( |
bool |
abState | ) |
|
Enables the HS-USB interface.
The FPGA is flushed prior to enabling, and the internal buffer pools are flushed upon disabling.
- Parameters:
-
[in] | abState | When true, interface is enabled. |
- Returns:
- none.
- See also:
- DspHsUsb.h
void tcDspHsUsb::setTimeout |
( |
unsigned int |
anMsec | ) |
|
This method is used to set the firmware RX FIFO timeout.
This value represents the maximum amount of time a small amount of data can sit in the receive FIFO before a timeout interrupt is asserted.
- Parameters:
-
[in] | anMsec | New timeout (in msec, 1 - 1023) |
- Returns:
- none.
- See also:
- DspHsUsb.h
unsigned int tcDspHsUsb::getTimeout |
( |
void |
| ) |
|
This method returns the current firmware RX FIFO timeout.
- Returns:
- Current timeout (in msec, 1 - 1023).
- See also:
- DspHsUsb.h
void tcDspHsUsb::registerSemaphores |
( |
SEM_Handle |
ahRxAvail, |
|
|
SEM_Handle |
ahTxEmpty |
|
) |
| |
This method registers semaphores that are incremented when receive data becomes available (RX FIFO transitions from empty to not empty), and when all transmit data has been sent (TX FIFO transitions from not empty to empty).
- Parameters:
-
[in] | ahRxAvail | Handle for the receive data available semaphore. |
[in] | ahTxEmpty | Handle for the transmit data sent semaphore. |
- Returns:
- none.
- See also:
- DspHsUsb.h
int tcDspHsUsb::interrupt_dispatch |
( |
Arg |
ahMyObject | ) |
|
|
staticprotected |
Static interrupt dispatch routine.
Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.
- Parameters:
-
[in] | ahMyObject | The "this->" pointer for the instance of tcDspHsUsb associated with this ISR. |
- Returns:
- 0
- See also:
- DspHsUsb.h
int tcDspHsUsb::thread_dispatch |
( |
Arg |
arMyObject, |
|
|
Arg |
abIsRx |
|
) |
| |
|
staticprotected |
Static thread dispatch routine.
Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the thread dispatcher.
- Parameters:
-
[in] | arMyObject | The "this->" pointer for the instance of tcDspHsUsb associated with this thread. |
[in] | abIsRx | Boolean indicating whether to launch receive thread (otherwise transmit thread). |
- Returns:
- 0
- See also:
- DspHsUsb.h
void tcDspHsUsb::usbRxDmaThread |
( |
void |
| ) |
|
|
protected |
This thread pends on RX DMA completion, finishes any odd bytes required, updates the RX FIFO tail, and reenables interrupts to continue processing.
- See also:
- DspHsUsb.h
void tcDspHsUsb::usbTxDmaThread |
( |
void |
| ) |
|
|
protected |
This thread pends on TX DMA completion, finishes any odd bytes required, updates the TX FIFO head, and reenables interrupts to continue processing.
- See also:
- DspHsUsb.h
void tcDspHsUsb::usbInterrupt |
( |
void |
| ) |
|
|
protected |
Interrupt service routine for the HS-USB.
The ISR reads and clears any pending interrupts. A DMA transfer is initiated if any data is available to read or write. Interrupts are disabled (re-enabled in DMA monitor thread).
"Interrupt-ness" is taken care of by the 'dispatcher' in DSP/BIOS. Installed by the constructor.
- See also:
- DspHsUsb.h
void tcDspHsUsb::enableRxInts |
( |
bool |
abEnable | ) |
|
|
protected |
This private method enables or disables RX FIFO interrupts as directed.
It is assumed that any required serialization has been provided by the caller of the function.
- Parameters:
-
[in] | abEnable | True to enable interrupts, false to disable. |
- Returns:
- none.
- See also:
- DspHsUsb.h
void tcDspHsUsb::enableTxInts |
( |
bool |
abEnable | ) |
|
|
protected |
This private method enables or disables TX FIFO interrupts as directed.
It is assumed that any required serialization has been provided by the caller of the function.
- Parameters:
-
[in] | abEnable | True to enable interrupts, false to disable. |
- Returns:
- none.
- See also:
- DspHsUsb.h
Member Data Documentation
const unsigned int MityDSP::tcDspHsUsb::gnTimeoutMin = 1 |
|
static |
min/max RX FIFO timeouts (how long data is allowed to sit in firmware FIFO)
const unsigned int MityDSP::tcDspHsUsb::gnTimeoutMax = 1023 |
|
static |
unsigned int MityDSP::tcDspHsUsb::mnInterruptCount |
const int MityDSP::tcDspHsUsb::gnDMA_THRESHOLD = 16 |
|
staticprotected |
volatile unsigned int* MityDSP::tcDspHsUsb::mpBaseAddr |
|
protected |
unsigned short MityDSP::tcDspHsUsb::mnMyIntMask |
|
protected |
int MityDSP::tcDspHsUsb::mnMyIntLevel |
|
protected |
int MityDSP::tcDspHsUsb::mnMyIntVector |
|
protected |
LCK_Handle MityDSP::tcDspHsUsb::mhMutex |
|
protected |
mutex to serialize access
BUF_Handle MityDSP::tcDspHsUsb::mhRxBufferPool |
|
protected |
pool of available RX buffers
BUF_Handle MityDSP::tcDspHsUsb::mhTxBufferPool |
|
protected |
pool of available TX buffers
SEM_Handle MityDSP::tcDspHsUsb::mhRxDmaComplete |
|
protected |
RX DMA complete semaphore for tcDspQdma.
SEM_Handle MityDSP::tcDspHsUsb::mhTxDmaComplete |
|
protected |
TX DMA complete semaphore for tcDspQdma.
SEM_Handle MityDSP::tcDspHsUsb::mhRxAvail |
|
protected |
semaphore set upon transition from RX empty
SEM_Handle MityDSP::tcDspHsUsb::mhTxEmpty |
|
protected |
semaphore set upon transition to TX empty
TSK_Handle MityDSP::tcDspHsUsb::mhRxDmaThread |
|
protected |
thread to reschedule RX DMA transfers
TSK_Handle MityDSP::tcDspHsUsb::mhTxDmaThread |
|
protected |
thread to reschedule RX DMA transfers
int MityDSP::tcDspHsUsb::mnNumRxBuffers |
|
protected |
number of RX buffers to create
int MityDSP::tcDspHsUsb::mnNumTxBuffers |
|
protected |
number of TX buffers to create
int MityDSP::tcDspHsUsb::mnThreadPrio |
|
protected |
DMA receiver thread priority.
head of linked list of RX data
tail of linked list of RX data
new RX buffer to add to list
head of linked list of TX data
tail of linked list of TX data
new TX buffer to add to list
int MityDSP::tcDspHsUsb::mnRxSize |
|
protected |
size of the firmware RX FIFO (bytes)
int MityDSP::tcDspHsUsb::mnTxSize |
|
protected |
size of the firmware TX FIFO (bytes)
volatile bool MityDSP::tcDspHsUsb::mbIsEnabled |
|
protected |
CACHE_L2Mode MityDSP::tcDspHsUsb::msL2Mode |
|
protected |
used for flushing the cache