The MGSL_PARAMS structure specifies the functional characteristics of a port. This structure is used with the MgslGetParams and MgslSetParams API functions.
WARNING: SOME OPTIONS ARE NOT SUPPORTED BY ALL ADAPTERS!
Check the Adapter Features for which options
are supported by a particular adapter.
typedef struct _MGSL_PARAMS
{
/* common parameters */
ULONG Mode; /* HDLC, async, raw, bisync, monosync */
UCHAR Loopback; /* internal loopback mode flag 1 = enable, 0 = disable */
/* synchronous mode only parameters */
USHORT Flags;
UCHAR Encoding; /* serial encoding */
ULONG ClockSpeed; /* external clock in bits per second, 0 = disable */
UCHAR Addr; /* receive HDLC addr filter, 0xFF = disable */
USHORT CrcType; /* None, CCITT CRC16, CCITT CRC32 */
UCHAR PreambleLength; /* preamble length */
UCHAR PreamblePattern; /* preamble pattern */
/* Async only parameters */
ULONG DataRate; /* async data rate in bits per second */
UCHAR DataBits; /* 7 or 8 bits */
UCHAR StopBits; /* 1 or 2 */
UCHAR Parity; /* None, Even, Odd */
} MGSL_PARAMS, *PMGSL_PARAMS;
The mode member determines which serial protocol the port uses. The following modes are supported:
| MGSL_MODE_ASYNC | Asynchronous mode |
| MGSL_MODE_HDLC | HDLC mode |
| MGSL_MODE_RAW | Raw mode. See Raw, BiSync, Monosync Modes. |
| MGSL_MODE_BISYNC | Bisync mode. See Raw, BiSync, Monosync Modes. |
| MGSL_MODE_MONOSYNC | Monosync mode. See Raw, BiSync, Monosync Modes. |
If the loopback member is set to a non-zero value then the data on the transmit pin is looped back internally in the adapter to the receive pin. Loopback mode is useful for diagnostics. If Loopback is zero then the adapter behaves normally
Flags specify functional characteristics of the port. The HDLC_ prefix is present for historical reasons, but unless otherwise specified the option applies to all modes.
Receive Clock Source (mutually exclusive except as noted below)
| HDLC_FLAG_RXC_DPLL | Receive clock is recovered from the DPLL. The DPLL reference clock speed is specified in the ClockSpeed member of the MGSL_PARAMS structure. May be combined with HDLC_FLAG_RXC_BRG for biphase encoding to temporarily switch the receive clock source to the BRG when a loss of DPLL synchronization is detected. For details see DPLL Clock Recovery |
| HDLC_FLAG_RXC_BRG | Receive clock is generated internally with the baud rate generator (BRG) at the speed specified in the ClockSpeed member of the MGSL_PARAMS structure. |
| HDLC_FLAG_RXC_RXCPIN | Receive clock is taken from the RxClk Input Pin. |
| HDLC_FLAG_RXC_TXCPIN | Receive clock is taken from the TxClk Input Pin. |
Transmit Clock Source (mutually exclusive)
| HDLC_FLAG_TXC_DPLL | Transmit clock is recovered from the DPLL. The DPLL reference clock speed is specified in the ClockSpeed member of the MGSL_PARAMS structure. |
| HDLC_FLAG_TXC_BRG | Transmit clock is generated internally with the baud rate generator (BRG) at the speed specified in the ClockSpeed member of the MGSL_PARAMS structure. |
| HDLC_FLAG_TXC_RXCPIN | Transmit clock is taken from the RxClk Input Pin. |
| HDLC_FLAG_TXC_TXCPIN | Transmit clock is taken from the TxClk Input Pin. |
DPLL Reference Clock Divisor (mutually exclusive)
| HDLC_FLAG_DPLL_DIV32 | The DPLL reference clock divisor is 32. |
| HDLC_FLAG_DPLL_DIV16 | The DPLL reference clock divisor is 16. |
| HDLC_FLAG_DPLL_DIV8 | The DPLL reference clock divisor is 8. |
The remaining flags can be used in any combination.
| HDLC_FLAG_SHARE_ZERO | Flags send by transmitter in idle mode share a common zero. Opening and closing flags never share common zeros. |
| HDLC_FLAG_AUTO_CTS | Don't start transmitting a frame until CTS goes active. If CTS goes inactive during transmission, the transmission is immediately stopped and a transmit status of TxStatus_CtsFailure is returned. |
| HDLC_FLAG_AUTO_DCD | Don't receive frames when DCD is inactive. |
| HDLC_FLAG_AUTO_RTS | Automatically assert RTS at start of transmission and negate RTS when transmission is complete. |
The HDLC encoding determines how the TxD and RxD pins represent data bits or logical 1s and 0s. Note that often NRZI_SPACE is simply called NRZI.
| HDLC_ENCODING_NRZ | No encoding, high = 1, low = 0 Also called NRZ-L |
| HDLC_ENCODING_NRZB | Inverted Encoding, high = 0, low = 1 |
| HDLC_ENCODING_NRZI_MARK | Invert state at start of bit cell for a 1, maintain
state for 0 Also called NRZ-M |
|
HDLC_ENCODING_NRZI_SPACE HDLC_ENCODING_NRZI |
Invert state at start of bit cell for a 0, maintain
state for a 1 Also called NRZ-S or just NRZI |
| HDLC_ENCODING_BIPHASE_MARK | Always invert state at start of bit cell. Invert in
middle of bit cell if 1, maintain state if 0. Also called FM1 |
| HDLC_ENCODING_BIPHASE_SPACE | Always invert state at start of bit cell. Invert in
middle of bit cell if 0, maintain state if 1. Also called FM0 |
| HDLC_ENCODING_BIPHASE_LEVEL | Start of bit cell is high for 1, low for 0. Always
invert in middle of bit cell. Also called Manchester |
| HDLC_ENCODING_DIFF_BIPHASE_LEVEL | Invert at start of bit cell if 1, maintain for 0. Always invert in middle of bit cell. |
The clock speed member determines if the adapter generates a data clock on the AUXCLK pin, and at what frequency the clock is generated. A value of 0 disables the AUXCLK pin. Any other value causes the AUXCLK pin to generate a clock at the specified value in bits per second.
The clock is generated by dividing a set clock frequency by an integer time constant. The time constant is related to the data rate by:
SyncLink GT/GT4/AC Adapters:
Time Constant = (14.7456MHz /Data Rate) - 1
SyncLink ISA Adapter (obsolete):
Time Constant = (14.7456MHz /Data Rate) - 1
SyncLink PCI Adapter (obsolete):
Time Constant = (11.0592MHz /Data Rate) - 1
SyncLink SCC Adapter (obsolete):
Time Constant = (3.6864MHz / (2*Data Rate)) - 2
The following adapters require 2 constants A and B
SyncLink PC Card:
Data Rate = (3.6864MHz / ((A + 1) * 2^B)) where A and B are integers, B >= 1
SyncLink Multiport Adapter (obsolete):
Data Rate = (14.7456MHz / (A * 2^B)) where A and B are integers, B >= 1
If the time constant (or A and B) for a particular speed is an integer (or zero) then the specified data rate can be generated exactly. Otherwise the actual data rate is the data rate specified by the time constant rounded up to the next integer value. For relatively low non standard data rates, the resulting error will be small. The clock frequency allows common data rate to be specified exactly: 2400, 9600, 57600, 115200 etc.
The address field allows HDLC frames to be filtered by hardware based on the 8-bit address field which is the first byte following an opening flag. Frames with the broadcast address of 0xFF are always received regardless of the Addr member value. If Addr is set to 0xFF then all frames are received regardless of the address field value. If an application uses extended addresses then the Addr field should be set to 0xFF and software should examine the address field.
Cyclic Redundancy Check used for HDLC mode.
| HDLC_CRC_NONE | Don't send CRCs on transmit, don't check CRCs on receive. |
| HDLC_CRC_16_CCITT | 16 bit X^16 +
X^12 + X^5 + 1 CRC
Polynomial |
| HDLC_CRC_32_CCITT | 32 bit X^32 +
X^26 + X^23 + X^22 +
X^16 + X^12 + X^11 +
X^10 + X^8 + X^7 +
X^5 + X^4 + X^2 + X +
1 CRC32 Polynomial |
| HDLC_CRC_RETURN_CRC | Combine this value with one of the other CRC settings to return the contents of all received frames (good and CRC error). The CRC value is appended to the end of all returned frames. |
| HDLC_CRC_RETURN_CRCERR_FRAME | Combine this value with one of the other CRC settings to return the contents of all received frames (good and CRC error). The CRC value is appended to the end of the returned frame only for frames with a CRC error. |
For frames up to 4096 bytes in length, CCITT CRC-16 can detect single and double bit errors, errors of an odd number of bits, error bursts of 16 bits or less, and can detect 99.998% of all errors.
32-bit CRCs can be used for frames up to 64KB, detecting 99.999999977% of all errors.
The CRC selection must match that of the remote system.
Normally, no data is returned when indicating a CRC error to an MgslReceive call. Setting HDLC_CRC_RETURN_CRCERR_FRAME returns the frame data including the trailing CRC value.
The preamble is a bit pattern sent on the transmit pin before sending each HDLC frame. The preamble pattern and length are set with the constants listed below. Use the preamble to synchronize a remote phase locked loop or to guarantee a minimum number of flags between frames. Including the opening and closing flags, 3, 4, 6, and 10 flags can be inserted between frames.
| HDLC_PREAMBLE_LENGTH_8BITS | |
| HDLC_PREAMBLE_LENGTH_16BITS | |
| HDLC_PREAMBLE_LENGTH_32BITS | |
| HDLC_PREAMBLE_LENGTH_64BITS | |
| HDLC_PREAMBLE_PATTERN_NONE | do not send preamble (ignore length) |
| HDLC_PREAMBLE_PATTERN_ZEROS | all zeros |
| HDLC_PREAMBLE_PATTERN_ONES | all ones |
| HDLC_PREAMBLE_PATTERN_FLAGS | flags |
| HDLC_PREAMBLE_PATTERN_10 | 1010101... |
| HDLC_PREAMBLE_PATTERN_01 | 0101010... |
These members specify the asynchronous format used when in asynchronous mode. DataRate is the rate in bits per second. DataBits is the number of data bits per character and can be 7 or 8. StopBits is the number of stop bits per character and can be 1 or 2. Parity specifies if a parity bit is added and what kind of parity is used. The parity is specified with one of the following constants: ASYNC_PARITY_NONE, ASYNC_PARITY_EVEN, or ASYNC_PARITY_ODD.
| Previous | Contents | Next |