MityDSP Documentation Index
Classes | Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
MityDSP::tcDspHsUsb Class Reference

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).

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 tsUsbBuffermpRxHead
 head of linked list of RX data
volatile tsUsbBuffermpRxTail
 tail of linked list of RX data
volatile tsUsbBuffermpRxNew
 new RX buffer to add to list
volatile tsUsbBuffermpTxHead
 head of linked list of TX data
volatile tsUsbBuffermpTxTail
 tail of linked list of TX data
volatile tsUsbBuffermpTxNew
 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

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]apAddressBase Address of ADC core.
[in]anRxBuffersNumber of RX buffers in pool (each 1/2 size of the firmware TX FIFO).
[in]anTxBuffersNumber of RX buffers in pool (each 1/2 size of the firmware RX FIFO).
[in]anThreadPrioPriority 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]apBuffBuffer pointer.
[in]anLenBytes 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]apBuffLocation to store received data.
[in]anMaxLenMaximum 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]abStateWhen 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]anMsecNew 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]ahRxAvailHandle for the receive data available semaphore.
[in]ahTxEmptyHandle 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]ahMyObjectThe "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]arMyObjectThe "this->" pointer for the instance of tcDspHsUsb associated with this thread.
[in]abIsRxBoolean 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]abEnableTrue 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]abEnableTrue 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

ISR counter (debug).

const int MityDSP::tcDspHsUsb::gnDMA_THRESHOLD = 16
staticprotected
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


  
Generated on Mon Apr 22 2013 11:33:04 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.