SynchroMaster
 
Component SynchroMaster
Master 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 - Enable the component - it starts send and receive functions. Events may be generated ("DisableEvent"/"EnableEvent"). This method cannot be disabled if the Fault mode is enabled. It's intended for re-enabling the module if fault occurred. For more information please see the "Fault mode" property .

      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 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
      ERR_SPEED - This device does not work in the active speed mode

  • EnableEvent - Enable 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
      ERR_SPEED - This device does not work in the active speed mode

  • DisableEvent - Disable 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
      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).

    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 - The valid data is received.
      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. 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. In the polling mode the ERR_FAULT is return until the user clear the fault flag bit, but in the interrupt mode ERR_FAULT is returned only once after the fault error occured. This error is supported only on the CPUs supports the faul mode function - where Fault mode property is available.

  • 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_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.

    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 - The valid data is received.
      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. 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. In the polling mode the ERR_FAULT is return until the user clear the fault flag bit, but in the interrupt mode ERR_FAULT is returned only once after the fault error occured. This error is supported only on the CPUs supports the faul mode function - where Fault mode property is available.

  • SendBlock - Send 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_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.

      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.

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

      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
      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 - Number of characters in the output buffer.

  • SetBaudRateMode - This method changes the channel communication speed (baud rate). This method is available 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 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. "sm1_BM_31_250KHZ" for shift clock rate set to 31.250 kHz and component name "sm1". See component's 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. The method will disable communication (if enabled), change the shift clock polarity end re-enable the communication (if it was enabled before).

      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_RANGE - Parameter out of range
      Version specific information for Freescale 56800/E and HC08 derivatives
      ERR_DISABLED - Device is disabled

  • Methods for Freescale ColdFireV1, HC08, HCS08, RS08, HCS12, HCS12X, MCF and 56800/E derivatives
    • SetIdleClockPolarity - Sets the idle clock polarity at runtime. If the communication does not run, the clock signal will have required level. The method will disable communication (if enabled), change the idle clock polarity end re-enable the communication (if it was enabled before).

        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_RANGE - Parameter out of range
        Version specific information for Freescale 56800/E and HC08 derivatives
        ERR_DISABLED - Device is disabled

  • 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
      ERR_SPEED - This device does not work in the active speed mode

  • Methods for ColdFireV1, HCS08, RS08, HCS12X and HCS12 derivatives.
    • SetDir - This method determines direction of data pin in bidirectional mode. The method is available only 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.