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>
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). | |
Public Attributes | |
unsigned int | mnInterruptCount |
ISR counter (debug). | |
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 Types | |
typedef struct MityDSP::tcDspHsUsb::usbBuffer | tsUsbBuffer |
The tsUsbBuffer structure is used to provide internal buffering for incoming and outgoing data. | |
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. | |
Protected Attributes | |
volatile unsigned int * | mpBaseAddr |
unsigned short | mnMyIntMask |
core interrupt mask | |
int | mnMyIntLevel |
core interrupt level | |
int | mnMyIntVector |
core interrupt vector | |
LCK_Handle | mhMutex |
mutex to serialize access | |
BUF_Handle | mhRxBufferPool |
pool of available RX buffers | |
BUF_Handle | mhTxBufferPool |
pool of available TX buffers | |
SEM_Handle | mhRxDmaComplete |
RX DMA complete semaphore for tcDspQdma. | |
SEM_Handle | mhTxDmaComplete |
TX DMA complete semaphore for tcDspQdma. | |
SEM_Handle | mhRxAvail |
semaphore set upon transition from RX empty | |
SEM_Handle | mhTxEmpty |
semaphore set upon transition to TX empty | |
TSK_Handle | mhRxDmaThread |
thread to reschedule RX DMA transfers | |
TSK_Handle | mhTxDmaThread |
thread to reschedule RX DMA transfers | |
int | mnNumRxBuffers |
number of RX buffers to create | |
int | mnNumTxBuffers |
number of TX buffers to create | |
int | mnThreadPrio |
DMA receiver thread priority. | |
volatile tsUsbBuffer * | mpRxHead |
head of linked list of RX data | |
volatile tsUsbBuffer * | mpRxTail |
tail of linked list of RX data | |
volatile tsUsbBuffer * | mpRxNew |
new RX buffer to add to list | |
volatile tsUsbBuffer * | mpTxHead |
head of linked list of TX data | |
volatile tsUsbBuffer * | mpTxTail |
tail of linked list of TX data | |
volatile tsUsbBuffer * | mpTxNew |
new TX buffer to add to list | |
int | mnRxSize |
size of the firmware RX FIFO (bytes) | |
int | mnTxSize |
size of the firmware TX FIFO (bytes) | |
volatile bool | mbIsEnabled |
current interface state | |
CACHE_L2Mode | msL2Mode |
used for flushing the cache | |
Static Protected Attributes | |
static const int | gnDMA_THRESHOLD = 16 |
Instances of this class handle an interface to the high-speed USB device This device is theoretically capable of speeds up to 400 Mbps.
typedef struct MityDSP::tcDspHsUsb::usbBuffer MityDSP::tcDspHsUsb::tsUsbBuffer [protected] |
The tsUsbBuffer structure is used to provide internal buffering for incoming and outgoing data.
The number of buffers available is set by the constructor.
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.
[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. |
tcDspHsUsb::~tcDspHsUsb | ( | ) | [virtual] |
This destructor is used to close up and free the resources tied to the associated high-speed USB interface.
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.
[in] | apBuff | Buffer pointer. |
[in] | anLen | Bytes in the supplied buffer. |
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.
[in] | apBuff | Location to store received data. |
[in] | anMaxLen | Maximum number of bytes to store in apBuff. |
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.
[in] | abState | When true, interface is enabled. |
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.
[in] | anMsec | New timeout (in msec, 1 - 1023) |
unsigned int tcDspHsUsb::getTimeout | ( | void | ) |
This method returns the current firmware RX FIFO timeout.
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).
[in] | ahRxAvail | Handle for the receive data available semaphore. |
[in] | ahTxEmpty | Handle for the transmit data sent semaphore. |
int tcDspHsUsb::interrupt_dispatch | ( | Arg | ahMyObject | ) | [static, protected] |
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.
[in] | ahMyObject | The "this->" pointer for the instance of tcDspHsUsb associated with this ISR. |
int tcDspHsUsb::thread_dispatch | ( | Arg | arMyObject, | |
Arg | abIsRx | |||
) | [static, protected] |
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.
[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). |
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.
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.
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.
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.
[in] | abEnable | True to enable interrupts, false to disable. |
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.
[in] | abEnable | True to enable interrupts, false to disable. |
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 |
ISR counter (debug).
const int MityDSP::tcDspHsUsb::gnDMA_THRESHOLD = 16 [static, protected] |
volatile unsigned int* MityDSP::tcDspHsUsb::mpBaseAddr [protected] |
unsigned short MityDSP::tcDspHsUsb::mnMyIntMask [protected] |
core interrupt mask
int MityDSP::tcDspHsUsb::mnMyIntLevel [protected] |
core interrupt level
int MityDSP::tcDspHsUsb::mnMyIntVector [protected] |
core interrupt vector
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.
volatile tsUsbBuffer* MityDSP::tcDspHsUsb::mpRxHead [protected] |
head of linked list of RX data
volatile tsUsbBuffer* MityDSP::tcDspHsUsb::mpRxTail [protected] |
tail of linked list of RX data
volatile tsUsbBuffer* MityDSP::tcDspHsUsb::mpRxNew [protected] |
new RX buffer to add to list
volatile tsUsbBuffer* MityDSP::tcDspHsUsb::mpTxHead [protected] |
head of linked list of TX data
volatile tsUsbBuffer* MityDSP::tcDspHsUsb::mpTxTail [protected] |
tail of linked list of TX data
volatile tsUsbBuffer* MityDSP::tcDspHsUsb::mpTxNew [protected] |
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] |
current interface state
CACHE_L2Mode MityDSP::tcDspHsUsb::msL2Mode [protected] |
used for flushing the cache