|
|
|
Bean
AsynchroSerial
|
Asynchronous serial communication
Methods are user callable functions/subroutines that are means of controlling the bean functions.
|
Methods:
-
Enable
- Enables the bean - 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 bean - 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.
DMA mode: If DMA controller is available on the selected CPU and the receiver is configured to use DMA controller then this method only sets the selected DMA channel. Then the status of the DMA transfer can be checked using GetCharsInRxBuf method. See an example of a typical usage for details about the communication using DMA.
ANSIC prototype: byte RecvChar(BeanName_TComData *Chr)
- Chr: Pointer to BeanName_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)
DMA mode:
If DMA controller is available on the selected CPU and the receiver is configured to use DMA controller then only ERR_OK, ERR_RXEMPTY, and ERR_SPEED error code can be returned from this method.
-
SendChar
- Sends one character to the channel. If the bean 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 bean (Enable method) starts the transmission of the stored data. This method is available only if the transmitter property is enabled.
DMA mode: If DMA controller is available on the selected CPU and the transmitter is configured to use DMA controller then this method only sets selected DMA channel. Then the status of the DMA transfer can be checked using GetCharsInTxBuf method. See an example of a typical usage for details about communication using DMA.
ANSIC prototype: byte SendChar(BeanName_TComData Chr)
- Chr:BeanName_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. DMA mode: If DMA controller is available on the selected CPU and the receiver is configured to use DMA controller then this method only sets the selected DMA channel. Then the status of the DMA transfer can be checked using GetCharsInRxBuf method. See an example of a typical usage for details about communication using DMA.
ANSIC prototype: byte RecvBlock(BeanName_TComData *Ptr,word Size,word *Rcv)
- Ptr: Pointer to BeanName_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) DMA mode: If DMA controller is available on the selected CPU and the receiver is configured to use DMA controller then only ERR_OK, ERR_RXEMPTY, and ERR_SPEED error codes can be returned from this method.
-
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. DMA mode: If DMA controller is available on the selected CPU and the transmitter is configured to use DMA controller then this method only sets the selected DMA channel. Then the status of the DMA transfer can be checked using GetCharsInTxBuf method. See typical usage for details about communication using DMA.
ANSIC prototype: byte SendBlock(BeanName_TComData *Ptr,word Size,word *Snd)
- Ptr: Pointer to BeanName_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. DMA mode: If DMA controller is available on the selected CPU and the receiver is configured to use DMA controller then this method only stops selected DMA channel.
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. DMA mode: If DMA controller is available on the selected CPU and the transmitter is configured to use DMA controller then this method only stops selected DMA channel.
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] DMA mode: If DMA controller is available on the selected CPU and the receiver is configured to use DMA controller then this method returns the number of characters in the receive buffer.
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.
DMA mode: If DMA controller is available on the selected CPU and the receiver is configured to use DMA controller then this method returns the number of characters in the receive buffer.
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] DMA mode: If DMA controller is available on the selected CPU and the transmitter is configured to use DMA controller then this method returns the number of characters in the transmit buffer.
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.
DMA mode: If DMA controller is available on the selected CPU and the transmitter is configured to use DMA controller then this method returns the number of characters in the transmit buffer.
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 can be used 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 beans 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 bean name "as1". See beans header file for details.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed 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(BeanName_TError *Err)
- Err: Pointer to BeanName_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 bean 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 HC08, HCS08, HCS12, HCS12X and 56800 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)
-
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 bean is disabled by user
-
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 HC08, HCS08, HCS12 and HCS12X derivatives.
-
Standby
- Puts the receiver into a standby state.
ANSIC prototype: void Standby(bool State)
- State:bool - Switch standby state
TRUE - Standby state FALSE - Normal operation
- Methods for Freescale HCS08, HCS12 and HCS12X derivatives.
-
SetDirection
- Sets the direction of the TxD pin in the single wire mode
ANSIC prototype: void SetDirection(byte direction)
- direction:byte - Direction of the TxD pin in the single wire mode of the SCI device ('bean name'_TXD_INPUT or 'bean name'_TXD_OUTPUT).
- Methods for Freescale HCS08, HCS12, HCS12X and 56800 derivatives.
-
GetRxIdle
- Returns the state of the receiver idle flag.
This method is available only if event OnIdle is disabled.
ANSIC prototype: bool GetRxIdle(void)
- Return value:bool - The state of the receiver idle flag.
- Methods for Freescale HCS08, HCS12, HCS12X and 56800 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 HCS12X derivatives.
-
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 bean 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 bean is disabled by user
Note: Some methods can be implemented as macros.
|
|
|
Processor ExpertTM and Embedded BeansTM are registered trademarks of UNIS, Ltd.
©1997-2005, UNIS, Ltd.
|
|
|