MityDSP Documentation Index

MityDSP::tcDspSerial Class Reference

Instances of this class handle sending, receiving, and configuring a serial port. More...

#include <core/DspSerial.h>

List of all members.

Public Types

typedef void(* tfIsrCallback )(bool, bool, bool)
typedef void(* tfIsrCallbackWithArg )(bool, bool, bool, void *)

Public Member Functions

 tcDspSerial (void *apAddress, int anLevel, int anBaud, int anDataBits, int anStopBits, int anParity, bool abHwFlowCtl=false)
 This constructor is used to open a serial interface with the specified baud rate, data bits, stop bits and parity settings.
virtual ~tcDspSerial ()
 Default destructor.
virtual int put (const void *pBuff, int nLen, int nNumRetries=0, int nSleepTime=0)
 This routine places a buffer of characters of arbitrary length onto the TX FIFO.
virtual int get (void *pBuff, int nMaxLen, unsigned int nTimeOut=0)
 This routine gets data off the receive FIFO and places it in the supplied buffer.
bool set_serial_mode (int *apBaud=NULL, int *apData=NULL, int *apStop=NULL, int *apParity=NULL, bool *apHwFlowCtl=NULL)
 Sets the mode of the serial port based upon the parameters supplied.
void set_dtr (bool abAssert)
 This routine changes the state of the Data Terminal Ready (FTR) line.
bool get_dtr (void)
 This routine returns the state of the Data Terminal Ready (FTR) line.
void enable (bool bState)
 This routine changes the state of the serial interface.
int rx_bytes_in_queue (void)
 This routine indicates the amount of data in the RX FIFO.
int tx_bytes_in_queue (void)
 This routine indicates the amount of data in the TX FIFO.
void get_modem_lines (bool &ri, bool &cd, bool &dsr)
 This routine returns the state of the modem control lines.
void set_modem_interrupt (bool abState)
 This routine changes the state of the modem interrupt.
void register_modem_isr_cb (tfIsrCallback afCallback)
 Registers the specified ISR callback for the modem line interrupt.
void register_modem_isr_cb (tfIsrCallbackWithArg afCallback, void *apUserArg=NULL)
 Registers the specified ISR callback for the modem line interrupt.

Static Public Member Functions

static int interrupt_dispatch (Arg arMyObject)
 Static interrupt dispatch routine.

Public Attributes

unsigned char mnIntState
 Last know contents of IER.
unsigned char mnIntIdent
 Last known contents of IIR.
unsigned int mnTxBytes
 Total bytes transmitted.
unsigned int mnRxBytes
 Total bytes received.
unsigned int mnInterruptCount
 ISR counter (debug).

Detailed Description

Instances of this class handle sending, receiving, and configuring a serial port.

An ISR is installed at the supplied vector to process transmit and receive interrupts.

See also:
tcDspSerial Page

Member Typedef Documentation

typedef void(* MityDSP::tcDspSerial::tfIsrCallback)(bool, bool, bool)

prototype for the modem ISR callback (for RI, CD, and DSR)

typedef void(* MityDSP::tcDspSerial::tfIsrCallbackWithArg)(bool, bool, bool, void *)

Constructor & Destructor Documentation

tcDspSerial::tcDspSerial ( void *  apAddress,
int  anLevel,
int  anBaud,
int  anDataBits,
int  anStopBits,
int  anParity,
bool  abHwFlowCtl = false 
)

This constructor is used to open a serial interface with the specified baud rate, data bits, stop bits and parity settings.

Parameters:
[in] apAddress The base address of the serial port's UART.
[in] anLevel The interrupt vector used by the UART.
[in] anBaud The serial port baud rate setting:

  • UART_9600 - 9600 bps.
  • UART_19200 - 19200 bps.
  • UART_38400 - 38400 bps.
  • UART_56000 - 56000 bps.
  • UART_57600 - 57600 bps.
  • UART_115200 - 115200 bps.
  • UART_230400 - 138240 bps.
  • UART_460800 - 138240 bps.
  • UART_921600 - 138240 bps.
  • X - X bps.
[in] anDataBits The desired data bit setting:

  • UART_LCR_CHR6 - 6 data bits.
  • UART_LCR_CHR7 - 7 data bits.
  • UART_LCR_CHR8 - 8 data bits.
[in] anStopBits The desired stop bit setting:

  • UART_LCR_1_STOP - 1 stop bit.
  • UART_LCR_2_STOP - 2 stop bits.
[in] anParity The desired parity setting:

  • UART_LCR_NOPARITY - no parity.
  • UART_LCR_EVENPARITY - even parity.
  • UART_LCR_ODDPARITY - odd parity.
[in] abHwFlowCtl Enable or disable flow control (default: false)
Returns:
None.
See also:
DspUart.h
tcDspSerial::~tcDspSerial (  )  [virtual]

Default destructor.


Member Function Documentation

int tcDspSerial::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.

Parameters:
[in] ahMyObject The "this->" pointer for the instance of tcDspSerial associated with this ISR.
Returns:
0
int tcDspSerial::put ( const void *  pBuff,
int  nLen,
int  nNumRetries = 0,
int  nSleepTime = 0 
) [virtual]

This routine places a buffer of characters of arbitrary length onto the TX FIFO.

If the transmitter is idle, it is restarted. An optional number of retries (and the retry period) may be specified.

Parameters:
[in] pBuff Buffer pointer.
[in] nLen Bytes in the supplied buffer.
[in] nNumRetries Number of times to retry if send is incomplete (default 0).
[in] nSleepTime Number of milliseconds to sleep between retries.
Returns:
The number of bytes successfully placed on the TX FIFO.
int tcDspSerial::get ( void *  pBuff,
int  nMaxLen,
unsigned int  nTimeOut = 0 
) [virtual]

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 and nTimeOut is 0 (default value).

This method is thread safe, if a call is made to get() that is blocking (a non-zero TimeOut is provided), all additional calls will be blocked until the initial get() method returns.

Parameters:
[in] pBuff Location to store received data.
[in] nMaxLen Maximum number of bytes to store in pBuff.
[in] nTimeOut Time in low resolution clock ticks to wait for data. Default is zero (no blocking if no data available). SYS_FOREVER will wait until at least one byte is ready.
Returns:
The number of bytes actually read.
bool tcDspSerial::set_serial_mode ( int *  apBaud = NULL,
int *  apData = NULL,
int *  apStop = NULL,
int *  apParity = NULL,
bool *  apHwFlowCtl = NULL 
)

Sets the mode of the serial port based upon the parameters supplied.

If a parameter is NULL (default), then the parameter remains unchanged.

Parameters:
[in] apBaud Pointer to the serial port baud rate setting:

  • UART_9600 - 9600 bps.
  • UART_19200 - 19200 bps.
  • UART_38400 - 38400 bps.
  • UART_56000 - 56000 bps.
  • UART_57600 - 57600 bps.
  • UART_115200 - 115200 bps.
  • UART_138240 - 138240 bps.
  • UART_BASE_SPEED / X - X bps.
[in] apData Pointer to the desired data bit setting:

  • UART_LCR_CHR6 - 6 data bits.
  • UART_LCR_CHR7 - 7 data bits.
  • UART_LCR_CHR8 - 8 data bits.
[in] apStop Pointer to the desired stop bit setting:

  • UART_LCR_1_STOP - 1 stop bit.
  • UART_LCR_2_STOP - 2 stop bits.
[in] apParity Pointer to the desired parity setting:

  • UART_LCR_NOPARITY - no parity.
  • UART_LCR_EVENPARITY - even parity.
  • UART_LCR_ODDPARITY - odd parity.
[in] apHwFlowCtl Bool pointer to enable or disable flow control.
Returns:
True if successful.
See also:
DspUart.h
void tcDspSerial::set_dtr ( bool  abAssert  ) 

This routine changes the state of the Data Terminal Ready (FTR) line.

Parameters:
[in] abAssert Boolean indicating whether or not DTR should be asserted.
Returns:
None.
bool tcDspSerial::get_dtr ( void   ) 

This routine returns the state of the Data Terminal Ready (FTR) line.

Returns:
True if DTR is asserted, false otherwise.
void tcDspSerial::enable ( bool  bState  ) 

This routine changes the state of the serial interface.

When disabled, all inputs are ignored, and all outputs are dropped.

Parameters:
[in] bState Boolean indicating whether or not port is enabled.
Returns:
None.
int tcDspSerial::rx_bytes_in_queue ( void   ) 

This routine indicates the amount of data in the RX FIFO.

Returns:
Number of bytes of data stored in the RX FIFO.
int tcDspSerial::tx_bytes_in_queue ( void   ) 

This routine indicates the amount of data in the TX FIFO.

Returns:
Number of bytes of data stored in the TX FIFO.
void tcDspSerial::get_modem_lines ( bool &  arRi,
bool &  arCd,
bool &  arDsr 
)

This routine returns the state of the modem control lines.

Parameters:
[out] arRi Ring Indicator state
[out] arCd Carrier Detect state
[out] arDsr Data Set Ready state
Returns:
None.
void tcDspSerial::set_modem_interrupt ( bool  abEnable  ) 

This routine changes the state of the modem interrupt.

Parameters:
[in] abEnable Boolean indicating whether or not the interrupt is enabled.
Returns:
None.
void tcDspSerial::register_modem_isr_cb ( tfIsrCallback  afCallback  ) 

Registers the specified ISR callback for the modem line interrupt.

Parameters:
[in] afCallback The callback to associate with the interrupt (or NULL for none).
Returns:
None.
void tcDspSerial::register_modem_isr_cb ( tfIsrCallbackWithArg  afCallback,
void *  apUserArg = NULL 
)

Registers the specified ISR callback for the modem line interrupt.

Parameters:
[in] afCallback The callback to associate with the interrupt (or NULL for none).
[in] apUserArg An argument to be supplied with the callback.
Returns:
None.

Member Data Documentation

Last know contents of IER.

Last known contents of IIR.

Total bytes transmitted.

Total bytes received.

ISR counter (debug).


  
Generated on Fri Sep 23 16:33:54 2011 for MityDSP Core by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.