|
|
|
Component
AsynchroSerial
Asynchronous serial communication
Methods:
(Methods are user-callable functions/subroutines intended for
the component functions control. Please see the Embedded Components page for more information.)
-
Enable
- Enables the component - it starts the send and receive functions. Events may be generated ("DisableEvent"/"EnableEvent").
ANSIC prototype: byte Enable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
Disable
- Disables the component - it stops the send and receive functions. No events will be generated.
ANSIC prototype: byte Disable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
EnableEvent
- Enables the events. This method is available if the interrupt service/event property is enabled and at least one event is enabled.
ANSIC prototype: byte EnableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
DisableEvent
- Disables the events. This method is available if the interrupt service/event property is enabled and at least one event is enabled.
ANSIC prototype: byte DisableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
RecvChar
- If any data is received, this method returns one character, otherwise it returns an error code (it does not wait for data). This method is enabled only if the receiver property is enabled.
Note: Because the preferred method to handle error and break exception in the interrupt mode is to use events OnError and OnBreak the return value ERR_RXEMPTY has higher priority than other error codes. As a consequence the information about an exception in interrupt mode is returned only if there is a valid character ready to be read.
ANSIC prototype: byte RecvChar(ComponentName_TComData *Chr)
- Chr: Pointer to ComponentName_TComData - Pointer to a received character
- Return value:byte - Error code, possible codes:
ERR_OK - OK
ERR_SPEED - This device does not work in the active speed mode
ERR_RXEMPTY - No data in receiver
ERR_BREAK - Break character is detected (only when the Interrupt service property is disabled and the Break signal property is enabled)
ERR_COMMON - common error occurred (the GetError method can be used for error specification)
-
SendChar
- Sends one character to the channel. If the component is temporarily disabled (Disable method) SendChar method only stores data into an output buffer. In case of a zero output buffer size, only one character can be stored. Enabling the component (Enable method) starts the transmission of the stored data. This method is available only if the transmitter property is enabled.
ANSIC prototype: byte SendChar(ComponentName_TComData Chr)
- Chr:ComponentName_TComData - Character to send
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_TXFULL - Transmitter is full
-
RecvBlock
- If any data is received, this method returns the block of the data and its length (and incidental error), otherwise it returns an error code (it does not wait for data).
This method is available only if non-zero length of the input buffer is defined and the receiver property is enabled.
If less than requested number of characters is received only the available data is copied from the receive buffer to the user specified destination. The value ERR_EXEMPTY is returned and the value of variable pointed by the Rcv parameter is set to the number of received characters.
ANSIC prototype: byte RecvBlock(ComponentName_TComData *Ptr, word Size, word *Rcv)
- Ptr: Pointer to ComponentName_TComData - Pointer to the block of received data
- Size:word - Size of the block
- Rcv: Pointer to word - Pointer to real number of the received data
- Return value:byte - Error code, possible codes:
ERR_OK - OK
ERR_SPEED - This device does not work in the active speed mode
ERR_RXEMPTY - The receive buffer didn't contain the requested number of data. Only available data has been returned.
ERR_COMMON - common error occurred (the GetError method can be used for error specification)
-
SendBlock
- Sends a block of characters to the channel.
This method is available only if non-zero length of the output buffer is defined and the transmitter property is enabled.
ANSIC prototype: byte SendBlock(ComponentName_TComData *Ptr, word Size, word *Snd)
- Ptr: Pointer to ComponentName_TComData - Pointer to the block of data to send
- Size:word - Size of the block
- Snd: Pointer to word - Pointer to number of data that are sent (moved to buffer)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_TXFULL - It was not possible to send requested number of bytes
-
ClearRxBuf
- Clears the receive buffer.
This method is available only if non-zero length of the input buffer is defined and the receiver property is enabled.
ANSIC prototype: byte ClearRxBuf(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
ClearTxBuf
- Clears the transmit buffer.
This method is available only if non-zero length of the output buffer is defined and the receiver property is enabled.
ANSIC prototype: byte ClearTxBuf(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
CharsInRxBuf
- Returns the number of characters in the input buffer. This method is available only if the receiver property is enabled.
[deprecated method]
ANSIC prototype: byte CharsInRxBuf(word *Chr)
- Chr: Pointer to word - Pointer to the number of characters in the input buffer
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
GetCharsInRxBuf
- Returns the number of characters in the input buffer. This method is available only if the receiver property is enabled.
ANSIC prototype: word GetCharsInRxBuf(void)
- Return value:word - The number of characters in the input buffer.
-
CharsInTxBuf
- Returns the number of characters in the output buffer. This method is available only if the transmitter property is enabled.
[deprecated method]
ANSIC prototype: byte CharsInTxBuf(word *Chr)
- Chr: Pointer to word - Pointer to the number of characters in the output buffer
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
GetCharsInTxBuf
- Returns the number of characters in the output buffer. This method is available only if the transmitter property is enabled.
ANSIC prototype: word GetCharsInTxBuf(void)
- Return value:word - The number of characters in the output buffer.
-
SetBaudRateMode
- This method changes the channel communication speed (baud rate).
This method is enabled only if the user specifies a list of possible period settings at design time (see Timing dialog box - Runtime setting - from a list of values). Each of these settings constitutes a mode and Processor Expert assigns them a mode identifier. The prescaler and compare values corresponding to each mode are calculated at design time. The user may switch modes at runtime by referring to a mode identifier. No run-time calculations are performed, all the calculations are performed at design time.
ANSIC prototype: byte SetBaudRateMode(byte Mod)
- Mod:byte - Timing mode to set
Note: Special constant is generated in the components header file for each mode from the list of values.
This constant can be directly passed to the parameter. Format of the constant is:
<BeanName>_BM_<Timing> e.g. "as1_BM_9600BAUD" for baud rate set to 9600 baud and component name "as1". See header file of the generated code for details.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_VALUE - Invalid ID of the baud rate mode
-
GetError
- Returns a set of errors on the channel (errors that cannot be returned by given methods). The errors accumulate in a set; after calling GetError this set is returned and cleared.
ANSIC prototype: byte GetError(ComponentName_TError *Err)
- Err: Pointer to ComponentName_TError - Pointer to the returned set of errors
- Return value:byte - Error code (if GetError did not succeed), possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
GetBreak
- Tests the internal input break flag, returns it (whether the break has occurred or not) and clears it.
This method is available only if the property Break signal and the property receiver are enabled.
ANSIC prototype: byte GetBreak(bool *Brk)
- Brk: Pointer to bool - Pointer to the returned internal break flag
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
SetBreak
- Sends the break sequence to the output line.
This method is available only if the Break signal property and the transmitter property are enabled.
ANSIC prototype: byte SetBreak(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - This component is disabled by user ERR_TXFULL - A transmission is in progress.
-
TurnTxOn
- Turns on the transmitter. This method is available only if the transmitter property is enabled.
ANSIC prototype: void TurnTxOn(void)
-
TurnTxOff
- Turns off the transmitter. This method is available only if the transmitter property is enabled.
ANSIC prototype: void TurnTxOff(void)
- Methods for Freescale ColdFireV1, HC08, HCS08, RS08, HCS12, HCS12X, 56800/E and MCF derivatives.
-
TurnRxOn
- Turns on the receiver. This method is available only if the receiver property is enabled.
ANSIC prototype: void TurnRxOn(void)
-
TurnRxOff
- Turns off the receiver. This method is available only if the receiver property is enabled.
ANSIC prototype: void TurnRxOff(void)
-
LoopMode
- Enables/disables the loop mode operation. In the loop mode the RxD pin is disconnected from the SCI, and the transmitter output goes into the receiver input.
ANSIC prototype: void LoopMode(bool Loop)
- Loop:bool - Switch loop mode
true - Loop mode enabled
false - Normal mode enabled
- Methods for Freescale ColdFireV1, HC08, HCS08, RS08, HCS12, HCS12X and 56800/E derivatives.
-
SetIdle
- Sends the idle character to the output line.
This method is available only if the transmitter property is enabled.
ANSIC prototype: byte SetIdle(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - This component is disabled by user
- Methods for Freescale ColdFireV1, HC08, HCS08, RS08, HCS12 and HCS12X derivatives.
-
Standby
- Switch the receiver between standby state and normal operation. If the receiver is in standby state, it could be wakeup by action chosen in "Wakeup condition" property or by this method.
ANSIC prototype: void Standby(bool State)
- State:bool - Switch standby state
true - Standby state
false - Normal operation
- Methods for Freescale HC08 EY16, EY16A, GR16, GR16A, GR32A, GR60A, GT16, GZ16, GZ32, GZ60, QB8 and QC16 derivatives.
-
GetArbiterStatus
- Returns the arbiter flags.
ANSIC prototype: byte GetArbiterStatus(byte *status)
- status: Pointer to byte - Status bits (bit 0 - Arbiter counter overflow bit, bit 1 - Arbiter counter running flag, bit 2 - Arbiter time measurement finish flag, bit 3 - Arbitration lost flag)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
ResetArbiterCounter
- Resets the arbiter counter.
ANSIC prototype: byte ResetArbiterCounter(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
GetArbiterCounter
- Returns the content of the arbiter counter register.
ANSIC prototype: byte GetArbiterCounter(word *value)
- value: Pointer to word - Pointer to the content of the arbiter counter (value 0 - 511)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_BUSY - counter is running
-
SetFallingEdgesMeasurement
- Sets the arbiter control register to the falling edges time measurement state. It sets the ESCI arbiter to Bit time measurement mode and selects clock source derived from bus clock.
ANSIC prototype: byte SetFallingEdgesMeasurement(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
SetLowLevelMeasurement
- Sets the arbiter control register to low level measurement state. It sets the ESCI arbiter to Bit time measurement mode and selects clock source derived from one half of the ESCI prescaler clock source.
ANSIC prototype: byte SetLowLevelMeasurement(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
ClearArbiterFlags
- Clears the arbiter flags. It clears the Arbiter counter overflow bit, the Arbiter time measurement finish flag and the Arbitration lost flag.
ANSIC prototype: byte ClearArbiterFlags(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
SetArbitrationMode
- Sets arbitration mode.
ANSIC prototype: byte SetArbitrationMode(byte clock)
- clock:byte - Clock select of the counter. When the value is 0 - one half of the ESCI input clock generated by the ESCI prescaler (RxD is sensed when the counter reaches 38h). When the value is 1 - clock derived from the bus clock - one half or one fourth of the bus clock depending on the CPU (RxD is sensed when the counter reaches 08h).
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
AdjustBaudRate
- Adjusts the baud rate according to a measured value in the arbiter counter (only for the falling edge measurement mode).
ANSIC prototype: byte AdjustBaudRate(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_BUSY - The measurement not yet finished (arbiter time measurement finish flag is not set) ERR_RANGE - The arbiter counter overflow (the measured time is out of range).
- Methods for Freescale ColdFireV1, HCS08, RS08, HCS12 and HCS12X derivatives.
-
SetDirection
- Sets the direction of the TxD pin in the single wire mode. This method is enabled only if SCI output mode is set to single-wire.
ANSIC prototype: void SetDirection(byte direction)
- direction:byte - Direction of the TxD pin in the single wire mode of the SCI device (ComponentName_TXD_INPUT or ComponentName_TXD_OUTPUT).
- Methods for Freescale ColdFireV1, HCS08, RS08, HCS12, HCS12X and 56800/E derivatives.
-
GetRxIdle
- Returns the state of the receiver idle flag.
This method is available only if OnIdle event is disabled and either the Receiver property is enabled or the SCI output mode property is set to Single-wire.
ANSIC prototype: bool GetRxIdle(void)
- Return value:bool - The state of the receiver idle flag.
- Methods for Freescale ColdFireV1, HCS08, RS08, HCS12, HCS12X, 56800/E and MCF derivatives.
-
GetTxComplete
- Returns whether the transmitter is finished transmitting all data, preamble, and break characters and is idle. It can be used to determine when it is safe to switch a line driver (e.g. in RS-485 applications).
This method is available only if event OnTxComplete is disabled.
ANSIC prototype: bool GetTxComplete(void)
- Return value:bool - Transmission process completeness.
- Methods for Freescale ColdFireV1, HCS08 AC, DZ, DE, DN, DV, EL, EN, FL, IB, IC, JE, JM, JS, LG, LH, LL, MM, MP, QB, QE, SC, SE, SG, SH and SV, RS08, HCS12 HY, HA, P and HCS12X derivatives only.
-
EnableRxEdgeDetect
- This method enables the receive input active edge detection interrupt and consequently allows the OnRxActiveEdge event to be invoked.
This method is available only when the Active edge detection property is enabled.
ANSIC prototype: byte EnableRxEdgeDetect(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - This component is disabled by user
-
DisableRxEdgeDetect
- This method disables the receive input active edge detection interrupt and consequently prevents the OnRxActiveEdge event to be invoked.
ANSIC prototype: byte DisableRxEdgeDetect(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode ERR_DISABLED - This component is disabled by user
Note: Some methods can be implemented as macros.
|