AsynchroSlave
 
 
 Bean AsynchroSlave
 
Asynchronous serial communication - slave

Methods are user callable functions/subroutines that are means of controlling the bean functions.

Methods:

  • Enable - Enables the bean - 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
      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).

      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)

  • SendChar - Sends one character to the channel. This method is available only if the transmitter property is enabled.

      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
      ERR_NOTAVAIL - Slave is not selected yet

  • 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 input buffer is defined.

      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)

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

      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 input buffer is defined.

      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 output buffer is defined.

      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.
    [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 if the Interrupt service is enabled. In pooling mode this method returns true when a character is received, therefore the RecvChar method should be called subsequently (see the typical usage example).

      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.
    [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.

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

  • 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 property Break signal is 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 Break signal property is 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

  • Selected - Return boolean value if slave is selected or not (if it is not selected, send/received methods return error value).

      ANSIC prototype: byte Selected(bool *Sel)
    • Sel: Pointer to bool - Pointer to boolean flag (is the slave selected ?)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK
      ERR_SPEED - This device does not work in the active speed mode

  • 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 - Send 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 family.
    • 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 HC08, HCS08, HCS12, HCS12X and 56800 family.
    • 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 HC08, HCS08, HCS12, HCS12X and 56800 family.
    • 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.


Note: Some methods can be implemented as macros.



Processor ExpertTM and Embedded BeansTM are registered trademarks of UNIS, Ltd.
©1997-2005, UNIS, Ltd.