Instances of this class handle sending, receiving, and configuring a serial port. More...
#include <core/DspSerial.h>
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). |
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.
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 *) |
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.
[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:
|
[in] | anDataBits | The desired data bit setting:
|
[in] | anStopBits | The desired stop bit setting:
|
[in] | anParity | The desired parity setting:
|
[in] | abHwFlowCtl | Enable or disable flow control (default: false) |
tcDspSerial::~tcDspSerial | ( | ) | [virtual] |
Default destructor.
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.
[in] | ahMyObject | The "this->" pointer for the instance of tcDspSerial associated with this ISR. |
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.
[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. |
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.
[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. |
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.
[in] | apBaud | Pointer to the serial port baud rate setting:
|
[in] | apData | Pointer to the desired data bit setting:
|
[in] | apStop | Pointer to the desired stop bit setting:
|
[in] | apParity | Pointer to the desired parity setting:
|
[in] | apHwFlowCtl | Bool pointer to enable or disable flow control. |
void tcDspSerial::set_dtr | ( | bool | abAssert | ) |
This routine changes the state of the Data Terminal Ready (FTR) line.
[in] | abAssert | Boolean indicating whether or not DTR should be asserted. |
bool tcDspSerial::get_dtr | ( | void | ) |
This routine returns the state of the Data Terminal Ready (FTR) line.
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.
[in] | bState | Boolean indicating whether or not port is enabled. |
int tcDspSerial::rx_bytes_in_queue | ( | void | ) |
This routine indicates the amount of data in the RX FIFO.
int tcDspSerial::tx_bytes_in_queue | ( | void | ) |
This routine indicates the amount of data 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.
[out] | arRi | Ring Indicator state |
[out] | arCd | Carrier Detect state |
[out] | arDsr | Data Set Ready state |
void tcDspSerial::set_modem_interrupt | ( | bool | abEnable | ) |
This routine changes the state of the modem interrupt.
[in] | abEnable | Boolean indicating whether or not the interrupt is enabled. |
void tcDspSerial::register_modem_isr_cb | ( | tfIsrCallback | afCallback | ) |
Registers the specified ISR callback for the modem line interrupt.
[in] | afCallback | The callback to associate with the interrupt (or NULL for none). |
void tcDspSerial::register_modem_isr_cb | ( | tfIsrCallbackWithArg | afCallback, | |
void * | apUserArg = NULL | |||
) |
Registers the specified ISR callback for the modem line interrupt.
[in] | afCallback | The callback to associate with the interrupt (or NULL for none). |
[in] | apUserArg | An argument to be supplied with the callback. |
unsigned char MityDSP::tcDspSerial::mnIntState |
Last know contents of IER.
unsigned char MityDSP::tcDspSerial::mnIntIdent |
Last known contents of IIR.
unsigned int MityDSP::tcDspSerial::mnTxBytes |
Total bytes transmitted.
unsigned int MityDSP::tcDspSerial::mnRxBytes |
Total bytes received.
unsigned int MityDSP::tcDspSerial::mnInterruptCount |
ISR counter (debug).