SynchroSlave
 
Component SynchroSlave
Slave for synchronous serial communication
Component Level: High
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 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

  • Disable - Disables the component - it stops the send and receive functions. No events will be generated. Note: When this method is called while a transmission is in progress, the data being transmitted/received may be lost.

      ANSIC prototype: byte Disable(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • EnableEvent - Enables the events. This method is available only if the "Interrupt service/event" property is enabled and at least the one of events is set to generate code.

      ANSIC prototype: byte EnableEvent(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • DisableEvent - Disables the events. This method is available only if the "Interrupt service/event" property is enabled and at least the one of events is set to generate code.

      ANSIC prototype: byte DisableEvent(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • RecvChar - If any data is received, this method returns one character, otherwise it returns an error code (it does not wait for data).

    For information about SW overrun behavior please see General info page.


      ANSIC prototype: byte RecvChar(ComponentName_TComData *Chr)
    • Chr: Pointer to ComponentName_TComData - A pointer to the received character
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK
      ERR_RXEMPTY - No data in receiver
      ERR_OVERRUN - Overrun error is detected from the last char or block received. In polling mode, this error code is returned only when the hardware supports detection of the overrun error. If interrupt service is enabled, and input buffer allocated by the bean is full, the bean behaviour depends on Input buffer size property : if property is 0, last received data-word is preserved (and previous is overwritten), if property is greater than 0, new received data-word are ignored.
      ERR_FAULT - Fault error was detected from the last char or block received. This error does not need to be supported on some Cpu (see generated code).

  • SendChar - Sends one character to the channel.

      ANSIC prototype: byte SendChar(ComponentName_TComData Chr)
    • Chr:ComponentName_TComData - Character to send
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK
      ERR_DISABLED - Device is disabled (only if output DMA is supported and enabled)
      ERR_TXFULL - Transmitter is full

  • RecvBlock - If any data received, this method returns the block of the data and its length (and incidental error), otherwise it returns error code (it does not wait for data).
    If less than requested number of characters is received only the available data is copied from the receive buffer to the user specified destination and the ERR_EXEMPTY value is returned.
    This method is available only if non-zero length of input buffer is defined.

    For information about SW overrun behavior please see General info page.


      ANSIC prototype: byte RecvBlock(ComponentName_TComData *Ptr, word Size, word *Rcv)
    • Ptr: Pointer to ComponentName_TComData - A pointer to the block of received data
    • Size:word - The size of the block
    • Rcv: Pointer to word - Pointer to a variable where an actual number of copied characters is stored
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK
      ERR_RXEMPTY - It was not possible to read requested number of bytes from the buffer
      ERR_OVERRUN - Overrun error was detected from the last char or block received. If interrupt service is enabled, and input buffer allocated by the bean is full, the bean behaviour depends on Input buffer size property : if property is 0, last received data-word is preserved (and previous is overwritten), if property is greater than 0, new received data-word are ignored.
      ERR_FAULT - Fault error was detected from the last char or block received. This error may not be supported on some Cpu (see generated code).

  • SendBlock - Sends a block of characters to the channel. This method is only available if a non-zero length of output buffer is defined.

      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_DISABLED - Device is disabled (only if output DMA is supported and enabled)
      ERR_TXFULL - It was not possible to send requested number of bytes

  • ClearRxBuf - Clears the receive buffer. This method is available only if a non-zero length of input buffer is defined.

      ANSIC prototype: byte ClearRxBuf(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • ClearTxBuf - Clears the transmit buffer. This method is only available if a non-zero length of output buffer is defined.

      ANSIC prototype: byte ClearTxBuf(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • CharsInRxBuf - Returns the number of characters in the input buffer.
    Note: If the Interrupt service is disabled, and the Ignore empty character is set to yes, and a character has been received, then this method returns 1 although it was an empty character.
    (deprecated method - Use the GetCharsInRxBuf method instead!)

      ANSIC prototype: byte CharsInRxBuf(word *Chr)
    • Chr: Pointer to word - A pointer to number of characters in the input buffer
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • GetCharsInRxBuf - Returns the number of characters in the input buffer.
    In polling mode (Interrupt service is disabled) if the peripheral does not support finding out number of data-word in its HW input buffer, the method returns 0 if the buffer is empty and returns 1 if the buffer is not empty.
    Note: If the Interrupt service is disabled, and the Ignore empty character is set to yes, and a character has been received, then this method returns 1 although it was an empty character.

      ANSIC prototype: word GetCharsInRxBuf(void)
    • Return value:word - Number of characters in the input buffer.

  • CharsInTxBuf - Returns the number of characters in the output buffer.
    (deprecated method - Use the GetCharsInRxBuf method instead!)

      ANSIC prototype: byte CharsInTxBuf(word *Chr)
    • Chr: Pointer to word - A pointer to the number of characters in the output buffer
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • GetCharsInTxBuf - Returns the number of characters in the output buffer. In polling mode (Interrupt service is disabled) if the peripheral does not support finding out number of data-word in its HW output buffer, the method returns 0 if the buffer is not full, and returns 1 if the buffer is full.

      ANSIC prototype: word GetCharsInTxBuf(void)
    • Return value:word - Number of characters in the output buffer.

  • GetError - Returns a set of errors on the channel (errors that cannot be returned in given methods). The component accumulates errors in a set; after calling GetError this set is returned and cleared. This method is available only if the "Interrupt service/event" property is enabled.

      ANSIC prototype: byte GetError(ComponentName_TError *Err)
    • Err: Pointer to ComponentName_TError - A pointer to the returned set of errors
    • Return value:byte - Error code (if GetError did not succeed), possible codes:
      ERR_OK - OK

  • Methods for ColdFireV1, HCS08, RS08, HCS12X and HCS12 derivatives.
    • SetDir - This method determines direction of data pin in bidirectional mode. The method is only available if 'Bidirectional mode' property is set to 'Enabled'.

        ANSIC prototype: void SetDir(bool OutBuf)
      • OutBuf:bool - Direction to set - false=Input, true=Output.


Note: Some methods can be implemented as macros.