Instances of this class handle access to a "generic" implementation of the LVDS interface for the MityDSP. More...
#include <core/DspLvds.h>
Classes | |
union | tuLvdsHeader |
This structure defines the header for all LVDS data packets. More... | |
struct | tuLvdsTrailer |
Trailer added to end of messages placed in RX FIFO. More... | |
Public Types | |
enum | teFIFOLevelMask { eeNoLevels = 0x0000, eeRxNotEmpty = 0x0001, eeRxOneQ = 0x0002, eeRxHalf = 0x0004, eeRxThreeQ = 0x0008, eeRxFull = 0x0010, eeRxAll = 0x00FF, eeTxAEmpty = 0x0100, eeTxBEmpty = 0x0200, eeAllTxEmpty = 0x0F00, eeIdleCountReached = 0x1000 } |
The teFIFOLevelMask enumeration defines the various FIFO levels that may enabled by the tcDspLvds class. More... | |
typedef void(* | tfIsrCallback )(tcDspLvds *, int, void *) |
prototype for the ISR callbacks. | |
Public Member Functions | |
tcDspLvds (void *apAddress, unsigned int anRxPacketLen=gnDefaultRxPacketLen) | |
This constructor is used to open an istance of the tcDspLvds interface. | |
~tcDspLvds () | |
This destructor is used to close up and free the resources tied to the associated LVDS interface. | |
virtual volatile unsigned int * | GetRxFifoDataPtr (void) |
Returns the pointer to the FIFO containing captured LVDS data. | |
virtual unsigned int | GetRxFifoSize (void) |
Returns the number of entries (4-bytes each) in the LVDS receive FIFO. | |
virtual unsigned int | GetTxBufferSize (void) |
Returns the overall size of the TX buffer, in bytes. | |
virtual bool | SetTxBlockSizes (unsigned int anIdleBytes, unsigned int anTxABytes, unsigned int anTxBBytes) |
This routine reserves space in the transmit buffer for idle messages, the transmit "A" messages, and the transmit "B" messages. | |
virtual bool | SetTxBlockSizes (float anIdlePercent, float anTxAPercent, float anTxBPercent) |
Alternate interface to reserves space in the transmit buffer for the different message types. | |
virtual void | GetTxBlockSizes (unsigned int &arIdleBytes, unsigned int &arTxABytes, unsigned int &arTxBBytes) |
This routine returns the space currently reserved in the transmit buffer for idle messages, the transmit "A" messages, and the transmit "B" messages. | |
virtual bool | LoadIdleBuffer (void *apData, unsigned int anNibbles, unsigned int anOffset=0, bool abActivate=true) |
This routine is used to load the specified amount of data into the Idle message area of the transmit buffer. | |
virtual bool | ActivateIdle (unsigned int anNibbles, unsigned int anOffset=0) |
This routine is used to activate the Idle message contained at the specified offset from the start of the Idle message area of the transmit buffer. | |
virtual bool | LoadTxABuffer (void *apData, unsigned int anNibbles, unsigned int anOffset=0, bool abActivate=true) |
This routine is used to load the specified amount of data into the transmit message "A" area of the transmit buffer. | |
virtual bool | ActivateTxA (unsigned int anNibbles, unsigned int anOffset=0) |
This routine is used to activate the transmit "A" message contained at the specified offset from the start of the transmit "A" message area of the transmit buffer. | |
virtual bool | LoadTxBBuffer (void *apData, unsigned int anNibbles, unsigned int anOffset=0, bool abActivate=true) |
This routine is used to load the specified amount of data into the transmit message "B" area of the transmit buffer. | |
virtual bool | ActivateTxB (unsigned int anNibbles, unsigned int anOffset=0) |
This routine is used to activate the transmit "B" message contained at the specified offset from the start of the transmit "B" message area of the transmit buffer. | |
virtual void | SetIdleIntCount (unsigned int anCount) |
This routine is used to set the number of idle packets transmitted before the "idle complete" interrupt is asserted. | |
virtual unsigned int | GetIdleIntCount (void) |
This routine returns the number of idle packets transmitted before the "idle complete" interrupt is asserted. | |
virtual void | EnableInterrupts (teFIFOLevelMask anMask, bool abEnable) |
This routine enables or disables interrupts based upon the mask supplied. | |
virtual void | RegisterIsrCallback (int anMask, tfIsrCallback afCallback, void *apUserArg=NULL) |
This routine registers a callback to be activated whenever the interrupt(s) specified by the provided mask occur. | |
virtual teFIFOLevelMask | GetRxFifoLevel (void) |
This routine returns the current RX FIFO level in terms of the available FIFO level masks. | |
virtual bool | DrainRxFifo (void) |
This routine reads (and discards) entries from the RX FIFO until the FIFO is empty. | |
virtual bool | IsTxAEmpty (void) |
This routine checks whether the TX "A" buffer has been sent. | |
virtual bool | IsTxBEmpty (void) |
This routine checks whether the TX "B" buffer has been sent. | |
virtual unsigned int | GetRxPacketLength (void) |
This routine returns the receive packet length in nibbles. | |
virtual void | SetRxAddress (unsigned int anAddr) |
This routine sets the Receive Address. | |
virtual unsigned int | GetRxAddress (void) |
This routine retrieves the current Receive Address from the LVDS control register. | |
virtual void | SetRxAddrMask (bool anSet) |
This routine sets the Address Mask bit in the LVDS control register. | |
virtual bool | GetRxAddrMask (void) |
This routine retrieves the current Address Mask bit from the LVDS control register. | |
virtual void | EnableLink (bool abEnable) |
This method enables or disables the LVDS link. | |
virtual bool | IsLinkEnabled (void) |
This routine returns the state of the LVDS interface. | |
virtual bool | RxClockDetected (void) |
This routine indicates whether a receive clock has been detected with at least 32 transitions in the last microsecond. | |
virtual void | PromiscuousMode (bool abEnable) |
This method enables or disables "promiscuous" mode for the LVDS link. | |
virtual bool | IsPromiscuous (void) |
This routine indicates whether the interface is in "promiscuous" mode. | |
Static Public Member Functions | |
static int | interrupt_dispatch (Arg arMyObject) |
Static interrupt dispatch routine. | |
Public Attributes | |
unsigned int | mnInterruptCount |
ISR counter (debug). | |
Static Public Attributes | |
static const unsigned int | gnDefaultRxPacketLen = 40 |
default RX packet length (in nibbles) | |
static const unsigned int | gnRxTrailerMagic = 0xBEAD |
psuedo-unique RX trailer pattern | |
static const unsigned char | gnSyncByte = 0x37 |
LVDS sync byte. | |
Protected Types | |
enum | teIntIdx { eeRxEmptyIdx = 0, eeRxOneQIdx = 1, eeRxHalfIdx = 2, eeRxThreeQIdx = 3, eeRxFullIdx = 4, eeTxAIdx = 5, eeTxBIdx = 6, eeIdleCntIdx = 7, eeNumIntLevels = 8 } |
Protected Member Functions | |
void | lvdsInterrupt (void) |
Interrupt service routine for the LVDS class. | |
Protected Attributes | |
LCK_Handle | mhMutex |
To serialize access. | |
unsigned int | mnRxFifoDepth |
depth of firmware RX FIFO. | |
unsigned int | mnTxBufferSize |
size of overall firmware TX buffer | |
unsigned int | mnTxIdleSize |
portion of TX buffer for Idle message(s) | |
unsigned int | mnTxASize |
portion of TX buffer to use for "A" message(s) | |
unsigned int | mnTxBSize |
portion of TX buffer to use for "B" message(s) | |
tfIsrCallback | mfIsrCallback [eeNumIntLevels] |
void * | mpUserArg [eeNumIntLevels] |
volatile unsigned int * | mpBaseAddr |
firmware base address | |
volatile unsigned int * | mpRxFifo |
pointer to LVDS RX FIFO | |
volatile unsigned int * | mpTxFifo |
pointer to LVDS TX FIFO | |
unsigned short | mnMyIntMask |
core interrupt mask | |
int | mnMyIntLevel |
core interrupt level | |
int | mnMyIntVector |
core interrupt vector |
Instances of this class handle access to a "generic" implementation of the LVDS interface for the MityDSP.
typedef void(* MityDSP::tcDspLvds::tfIsrCallback)(tcDspLvds *, int, void *) |
prototype for the ISR callbacks.
The teFIFOLevelMask enumeration defines the various FIFO levels that may enabled by the tcDspLvds class.
enum MityDSP::tcDspLvds::teIntIdx [protected] |
tcDspLvds::tcDspLvds | ( | void * | apAddress, | |
unsigned int | anRxPacketLen = gnDefaultRxPacketLen | |||
) |
This constructor is used to open an istance of the tcDspLvds interface.
[in] | apAddress | Base Address of LVDS core |
[in] | anRxPacketLen | Receive packet length for this interface, in nibbles (default: gnDefaultRxPacketLen=40). |
tcDspLvds::~tcDspLvds | ( | ) |
This destructor is used to close up and free the resources tied to the associated LVDS interface.
int tcDspLvds::interrupt_dispatch | ( | Arg | ahMyObject | ) | [static] |
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 tcDspLvds associated with this ISR. |
volatile unsigned int * tcDspLvds::GetRxFifoDataPtr | ( | void | ) | [virtual] |
Returns the pointer to the FIFO containing captured LVDS data.
This pointer should be treated as read-only.
unsigned int tcDspLvds::GetRxFifoSize | ( | void | ) | [virtual] |
Returns the number of entries (4-bytes each) in the LVDS receive FIFO.
unsigned int tcDspLvds::GetTxBufferSize | ( | void | ) | [virtual] |
Returns the overall size of the TX buffer, in bytes.
bool tcDspLvds::SetTxBlockSizes | ( | unsigned int | anIdleBytes, | |
unsigned int | anTxABytes, | |||
unsigned int | anTxBBytes | |||
) | [virtual] |
This routine reserves space in the transmit buffer for idle messages, the transmit "A" messages, and the transmit "B" messages.
The sum of the sizes of the three areas cannot exceed the overall TX buffer size.
[in] | anIdleBytes | Bytes to reserve in the TX buffer for Idle messages. |
[in] | anTxABytes | Bytes to reserve in the TX buffer for "A" messages. |
[in] | anTxBBytes | Bytes to reserve in the TX buffer for "B" messages. |
bool tcDspLvds::SetTxBlockSizes | ( | float | anIdlePercent, | |
float | anTxAPercent, | |||
float | anTxBPercent | |||
) | [virtual] |
Alternate interface to reserves space in the transmit buffer for the different message types.
Sizes are specified as a percentage of overall TX buffer size.
[in] | anIdlePercent | Percentage of TX buffer to reserve for Idle messages. |
[in] | anTxAPercent | Percentage of TX buffer to reserve for "A" messages. |
[in] | anTxBPercent | Percentage of TX buffer to reserve for "B" messages. |
void tcDspLvds::GetTxBlockSizes | ( | unsigned int & | arIdleBytes, | |
unsigned int & | arTxABytes, | |||
unsigned int & | arTxBBytes | |||
) | [virtual] |
This routine returns the space currently reserved in the transmit buffer for idle messages, the transmit "A" messages, and the transmit "B" messages.
[out] | arIdleBytes | Bytes reserved in the TX buffer for Idle messages. |
[out] | arTxABytes | Bytes reserved in the TX buffer for "A" messages. |
[out] | arTxBBytes | Bytes reserved in the TX buffer for "B" messages. |
bool tcDspLvds::LoadIdleBuffer | ( | void * | apData, | |
unsigned int | anNibbles, | |||
unsigned int | anOffset = 0 , |
|||
bool | abActivate = true | |||
) | [virtual] |
This routine is used to load the specified amount of data into the Idle message area of the transmit buffer.
An offset from the start of the Idle message area may be specified.
By default, the Idle message loaded is immediately activated.
[in] | apData | Pointer to the data to load. |
[in] | anNibbles | Number of nibbles (half-bytes) to load. |
[in] | anOffset | Offset (in bytes) from the start of the Idle message reserved area in the TX buffer. |
[in] | abActivate | If true, activate the newly loaded Idle message immediately. |
bool tcDspLvds::ActivateIdle | ( | unsigned int | anNibbles, | |
unsigned int | anOffset = 0 | |||
) | [virtual] |
This routine is used to activate the Idle message contained at the specified offset from the start of the Idle message area of the transmit buffer.
[in] | anNibbles | Number of nibbles (half-bytes) to in message. |
[in] | anOffset | Offset (in bytes) from the start of the Idle message reserved area in the TX buffer. |
bool tcDspLvds::LoadTxABuffer | ( | void * | apData, | |
unsigned int | anNibbles, | |||
unsigned int | anOffset = 0 , |
|||
bool | abActivate = true | |||
) | [virtual] |
This routine is used to load the specified amount of data into the transmit message "A" area of the transmit buffer.
An offset from the start of the message "A" area may be specified.
By default, the transmit "A" message loaded is immediately activated.
[in] | apData | Pointer to the data to load. |
[in] | anNibbles | Number of nibbles (half-bytes) to load. |
[in] | anOffset | Offset (in bytes) from the start of the TX "A" message reserved area in the TX buffer. |
[in] | abActivate | If true, activate the newly loaded TX "A" message immediately. |
bool tcDspLvds::ActivateTxA | ( | unsigned int | anNibbles, | |
unsigned int | anOffset = 0 | |||
) | [virtual] |
This routine is used to activate the transmit "A" message contained at the specified offset from the start of the transmit "A" message area of the transmit buffer.
[in] | anNibbles | Number of nibbles (half-bytes) to in message. |
[in] | anOffset | Offset (in bytes) from the start of the transmit "A" message reserved area in the TX buffer. |
bool tcDspLvds::LoadTxBBuffer | ( | void * | apData, | |
unsigned int | anNibbles, | |||
unsigned int | anOffset = 0 , |
|||
bool | abActivate = true | |||
) | [virtual] |
This routine is used to load the specified amount of data into the transmit message "B" area of the transmit buffer.
An offset from the start of the message "B" area may be specified.
By default, the transmit "B" message loaded is immediately activated.
[in] | apData | Pointer to the data to load. |
[in] | anNibbles | Number of nibbles (half-bytes) to load. |
[in] | anOffset | Offset (in bytes) from the start of the TX "B" message reserved area in the TX buffer. |
[in] | abActivate | If true, activate the newly loaded TX "B" message immediately. |
bool tcDspLvds::ActivateTxB | ( | unsigned int | anNibbles, | |
unsigned int | anOffset = 0 | |||
) | [virtual] |
This routine is used to activate the transmit "B" message contained at the specified offset from the start of the transmit "B" message area of the transmit buffer.
[in] | anNibbles | Number of nibbles (half-bytes) to in message. |
[in] | anOffset | Offset (in bytes) from the start of the transmit "B" message reserved area in the TX buffer. |
void tcDspLvds::SetIdleIntCount | ( | unsigned int | anCount | ) | [virtual] |
This routine is used to set the number of idle packets transmitted before the "idle complete" interrupt is asserted.
Default is 1.
[in] | anCount | Number of idles before complete interrupt. |
unsigned int tcDspLvds::GetIdleIntCount | ( | void | ) | [virtual] |
This routine returns the number of idle packets transmitted before the "idle complete" interrupt is asserted.
void tcDspLvds::EnableInterrupts | ( | teFIFOLevelMask | anMask, | |
bool | abEnable | |||
) | [virtual] |
This routine enables or disables interrupts based upon the mask supplied.
[in] | anMask | Mask representing the interrupt types to modify. |
[in] | abEnable | if true, enable the specified interrupts, otherwise disable them. |
void tcDspLvds::RegisterIsrCallback | ( | int | anMask, | |
tfIsrCallback | afCallback, | |||
void * | apUserArg = NULL | |||
) | [virtual] |
This routine registers a callback to be activated whenever the interrupt(s) specified by the provided mask occur.
[in] | anMask | Mask representing the interrupt types to use the callback for (masked defined by teFIFOLevelMask). |
[in] | afCallback | The function to call when the specified interrupt(s) occur. |
[in] | apUserArg | An argument to be supplied with the callback. |
tcDspLvds::teFIFOLevelMask tcDspLvds::GetRxFifoLevel | ( | void | ) | [virtual] |
This routine returns the current RX FIFO level in terms of the available FIFO level masks.
bool tcDspLvds::DrainRxFifo | ( | void | ) | [virtual] |
This routine reads (and discards) entries from the RX FIFO until the FIFO is empty.
bool tcDspLvds::IsTxAEmpty | ( | void | ) | [virtual] |
This routine checks whether the TX "A" buffer has been sent.
bool tcDspLvds::IsTxBEmpty | ( | void | ) | [virtual] |
This routine checks whether the TX "B" buffer has been sent.
unsigned int tcDspLvds::GetRxPacketLength | ( | void | ) | [virtual] |
This routine returns the receive packet length in nibbles.
This value does not include the header or payload checksum.
void tcDspLvds::SetRxAddress | ( | unsigned int | anAddr | ) | [virtual] |
This routine sets the Receive Address.
This is the address field code that must match incoming receive packets with the address mask (AM) set to zero. Receive address qualification may be overridden by setting the address mask to '1', or by enabling promiscuous mode.
[in] | anAddr | The desired receive address (0 - 7) |
unsigned int tcDspLvds::GetRxAddress | ( | void | ) | [virtual] |
This routine retrieves the current Receive Address from the LVDS control register.
void tcDspLvds::SetRxAddrMask | ( | bool | abSet | ) | [virtual] |
This routine sets the Address Mask bit in the LVDS control register.
When this bit is clear, incoming packets must match the Receive Address in order to be qualified (unless in promiscuous mode). Otherwise, any incoming packets with their AM bit set to '1' will be accepted.
[in] | abSet | True to set the AM bit in the Control Register, false to clear it. |
bool tcDspLvds::GetRxAddrMask | ( | void | ) | [virtual] |
This routine retrieves the current Address Mask bit from the LVDS control register.
void tcDspLvds::EnableLink | ( | bool | abEnable | ) | [virtual] |
This method enables or disables the LVDS link.
This includes sending clocks/data and processing incoming messages.
[in] | abEnable | True to enable interface, false to disable. |
bool tcDspLvds::IsLinkEnabled | ( | void | ) | [virtual] |
This routine returns the state of the LVDS interface.
bool tcDspLvds::RxClockDetected | ( | void | ) | [virtual] |
This routine indicates whether a receive clock has been detected with at least 32 transitions in the last microsecond.
This may be used to provide feedback as to electrical link status between two endpoints.
void tcDspLvds::PromiscuousMode | ( | bool | abEnable | ) | [virtual] |
This method enables or disables "promiscuous" mode for the LVDS link.
If enabled, all received messages are qualified regardless of the address or address mask settings.
[in] | abEnable | True to enable promiscuous mode, false to disable. |
bool tcDspLvds::IsPromiscuous | ( | void | ) | [virtual] |
This routine indicates whether the interface is in "promiscuous" mode.
void tcDspLvds::lvdsInterrupt | ( | void | ) | [protected] |
Interrupt service routine for the LVDS class.
The ISR reads and disables any pending interrupts. If any of the pending interrupts has a callback registered for it, the routine is called.
"Interrupt-ness" is taken care of by the 'dispatcher' in DSP/BIOS. Installed by the constructor.
const unsigned int MityDSP::tcDspLvds::gnDefaultRxPacketLen = 40 [static] |
default RX packet length (in nibbles)
const unsigned int MityDSP::tcDspLvds::gnRxTrailerMagic = 0xBEAD [static] |
psuedo-unique RX trailer pattern
const unsigned char MityDSP::tcDspLvds::gnSyncByte = 0x37 [static] |
LVDS sync byte.
unsigned int MityDSP::tcDspLvds::mnInterruptCount |
ISR counter (debug).
LCK_Handle MityDSP::tcDspLvds::mhMutex [protected] |
To serialize access.
unsigned int MityDSP::tcDspLvds::mnRxFifoDepth [protected] |
depth of firmware RX FIFO.
unsigned int MityDSP::tcDspLvds::mnTxBufferSize [protected] |
size of overall firmware TX buffer
unsigned int MityDSP::tcDspLvds::mnTxIdleSize [protected] |
portion of TX buffer for Idle message(s)
unsigned int MityDSP::tcDspLvds::mnTxASize [protected] |
portion of TX buffer to use for "A" message(s)
unsigned int MityDSP::tcDspLvds::mnTxBSize [protected] |
portion of TX buffer to use for "B" message(s)
tfIsrCallback MityDSP::tcDspLvds::mfIsrCallback[eeNumIntLevels] [protected] |
void* MityDSP::tcDspLvds::mpUserArg[eeNumIntLevels] [protected] |
volatile unsigned int* MityDSP::tcDspLvds::mpBaseAddr [protected] |
firmware base address
volatile unsigned int* MityDSP::tcDspLvds::mpRxFifo [protected] |
pointer to LVDS RX FIFO
volatile unsigned int* MityDSP::tcDspLvds::mpTxFifo [protected] |
pointer to LVDS TX FIFO
unsigned short MityDSP::tcDspLvds::mnMyIntMask [protected] |
core interrupt mask
int MityDSP::tcDspLvds::mnMyIntLevel [protected] |
core interrupt level
int MityDSP::tcDspLvds::mnMyIntVector [protected] |
core interrupt vector