SynchroMaster
 
 
 Bean SynchroMaster
 
Master for synchronous serial communication

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

Methods:

  • Enable - Enable 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 - Disable 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 - Enable the events.

      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 - Disable the events.

      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).
    DMA mode:
    If DMA controller is available on selected CPU and receiver is configured to use DMA controller then this method only sets the selected DMA channel. Status of the DMA transfer can then be checked using method GetCharsInRxBuf. See typical usage for details about communication using DMA.

      ANSIC prototype: byte RecvChar(BeanName_TComData *Chr)
    • Chr: Pointer to BeanName_TComData - A pointer to the 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_OVERRUN - Overrun error was detected from the last char or block received
      ERR_FAULT - Fault error was detected from the last char or block received. This error may not be supported on some CPUs (see generated code).

  • SendChar - Sends one character to the channel.
    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. The status of the DMA transfer can then be checked using GetCharsInTxBuf method. See the 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_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.
    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. The status of the DMA transfer can then be checked using GetCharsInRxBuf method. See the typical usage for details about communication using DMA.

      ANSIC prototype: byte RecvBlock(BeanName_TComData *Ptr,word Size,word *Rcv)
    • Ptr: Pointer to BeanName_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_SPEED - This device does not work in the active speed mode
      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
      ERR_FAULT - Fault error was detected from the last char or block received. This error may not be supported on some CPUs (see generated code).

  • SendBlock - Send a block of characters to the channel. This method is only available if a non-zero length of output buffer is defined.
    DMA mode:
    If DMA controller is available on the selected CPU and transmitter is configured to use DMA controller then this method only sets the selected DMA channel. The status of the DMA transfer can then be checked using GetCharsInTxBuf method. See the 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_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.
    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 the 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 only available if a non-zero length of output buffer is defined.
    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 the 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.
    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)
    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 - A pointer to 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.
    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.
    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 - Number of characters in the input buffer.

  • CharsInTxBuf - Returns the number of characters in the output buffer.
    (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 - A 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.
    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 - Number of characters in the output buffer.

  • SetBaudRateMode - This method changes the channel communication speed (baud rate). This method can be used only if you specify 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. You may switch modes at runtime by referring only 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. "sm1_BM_31_250KHZ" for shift clock rate set to 31.250 kHz and bean name "sm1". 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
      ERR_VALUE - Invalid ID of the baud rate mode.

  • SetShiftClockPolarity - Sets the shift clock polarity at runtime. Output data will be shifted on the selected edge polarity.

      ANSIC prototype: byte SetShiftClockPolarity(byte Edge)
    • Edge:byte - Edge polarity.
      0-falling edge
      1-rising edge
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK
      ERR_SPEED - This device does not work in the active speed mode
      ERR_DISABLED - Device is disabled
      ERR_RANGE - Parameter out of range

  • Methods for Freescale HC08, HCS08, HCS12, HCS12X and 56800 derivatives
    • SetIdleClockPolarity - Sets the idle clock polarity at runtime. If the communication does not run, the clock signal will have required level.

        ANSIC prototype: byte SetIdleClockPolarity(byte Level)
      • Level:byte - Idle clock polarity:
        0-low
        1-high
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_SPEED - This device does not work in the active speed mode
        ERR_DISABLED - Device is disabled
        ERR_RANGE - Parameter out of range

  • GetError - Returns a set of errors on the channel (errors that cannot be returned in 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 - A 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

  • Methods for HCS08, 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.



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