FreescaleCAN
 
 
 Bean FreescaleCAN
 
CAN communication for Freescale implementation

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

Methods:

  • Enable - Enables the bean - it turns on 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

  • Methods for HCS12 and DSP80x derivatives.
    • SetAcceptanceCode - Sets the acceptance code registers. This method writes a code mask directly to the acceptance code registers.

        ANSIC prototype: byte SetAcceptanceCode(dword AccCode1,dword AccCode2)
      • AccCode1:dword - Acceptance code for the message filtering. This acceptance code will be written to the acceptance code registers IDAR0-IDAR3. The most significant byte of the acceptance code will be written to the IDAR0 register and the least significant byte of the acceptance code will be written to the IDAR3 register.
      • AccCode2:dword - Acceptance code for the message filtering. This acceptance code will be written to the acceptance code registers IDAR4-IDAR7. The most significant byte of the acceptance code will be written to the IDAR4 register and the least significant byte of the acceptance code will be written to the IDAR7 register.
      • 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

    • GetAcceptanceCode - Returns a content of the acceptance code registers.

        ANSIC prototype: void GetAcceptanceCode(dword *AccCode1,dword *AccCode2)
      • AccCode1: Pointer to dword - Pointer to the acceptance code for the message filtering. The acceptance code will be read from the acceptance code registers IDAR0-IDAR3. The most significant byte of the acceptance code will be read from the IDAR0 register and the least significant byte of the acceptance code will be read from the IDAR3 register.
      • AccCode2: Pointer to dword - Pointer to the acceptance code for the message filtering. The acceptance code will be read from the acceptance code registers IDAR4-IDAR7. The most significant byte of the acceptance code will be read from the IDAR4 register and the least significant byte of the acceptance code will be read from the IDAR7 register.

    • SetAcceptanceMask - Sets the acceptance mask registers. This method writes an acceptance mask directly to the acceptance mask registers.

        ANSIC prototype: byte SetAcceptanceMask(dword AccMask1,dword AccMask2)
      • AccMask1:dword - Acceptance mask for the message filtering. This acceptance mask will be written to the acceptance mask registers IDMR0-IDMR3. The most significant byte of the acceptance mask will be written to the IDMR0 register and the least significant byte of the acceptance mask will be written to the IDMR3 register.
      • AccMask2:dword - Acceptance mask for the message filtering. This acceptance mask will be written to the acceptance mask registers IDMR4-IDMR7. The most significant byte of the acceptance mask will be written to the IDMR4 register and the least significant byte of the acceptance mask will be written to the IDMR7 register.
      • 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

    • GetAcceptanceMask - Returns the content of acceptance mask registers.

        ANSIC prototype: void GetAcceptanceMask(dword *AccMask1,dword *AccMask2)
      • AccMask1: Pointer to dword - Pointer to the acceptance mask for the message filtering. The acceptance mask will be read from the acceptance mask registers IDMR0-IDMR3. The most significant byte of the acceptance mask will be read from the IDMR0 register and the least significant byte of the acceptance mask will be read from the IDMR3 register.
      • AccMask2: Pointer to dword - Pointer to the acceptance mask for the message filtering. The acceptance mask will be read from the acceptance mask registers IDMR4-IDMR7. The most significant byte of the acceptance mask will be read from the IDMR4 register and the least significant byte of the acceptance mask will be read from the IDMR7 register.

  • Methods for HC08, HCS12 and DSP80x derivatives.
    • SetAcceptanceMode - Sets the acceptance mode register.

        ANSIC prototype: byte SetAcceptanceMode(byte Mode)
      • Mode:byte - Acceptance mode.
        Supported modes:
        TWO_32_FILTERS - Two 32-bit acceptance filters
        FOUR_16_FILTERS - Four 16-bit acceptance filters
        EIGHT_8_FILTERS - Eight 8-bit acceptance filters
        FILTER_CLOSED - Filter closed
      • 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_VALUE - Parameter has incorrect value

  • Methods for HC08, HCS12 and DSP80x derivatives.
    • SendFrame - Sends the frame via the CAN device. Using this method the user can send own message to the CAN bus. This method allows to specify CAN buffer number, message ID, data to be sent and frame type (DATA_FRAME/REMOTE_FRAME).

        ANSIC prototype: byte SendFrame(byte BufferNum,dword MessageID,byte FrameType,byte Length,void* Data)
      • BufferNum:byte - Number of the buffer.
      • MessageID:dword - Identification of the message - ID. Message ID can be specified in the STANDARD format (default) or the EXTENDED format. The most significant bit in the ID is set to specify EXTENDED format. Predefined macro CAN_EXTENDED_FRAME_ID can be used (ID "bitwise or" CAN_EXTENDED_FRAME_ID) to mark ID as extended. If the most significant bit of ID is clear, STANDARD format is used.
      • FrameType:byte - Type of frame
        DATA_FRAME - data frame
        REMOTE_FRAME - remote frame
      • Length:byte - The length of the frame in bytes (0..8)
      • Data:void* - Pointer to data
      • 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_VALUE - Some parameter is out of possible range
        ERR_TXFULL - Transmition buffer is full.

  • GetTransmitErrorCounter - Returns a value of the transmission error counter.

      ANSIC prototype: byte GetTransmitErrorCounter(void)
    • Return value:byte - Returns a value of the transmission error counter

  • GetReceiverErrorCounter - Returns a value of the reception error counter.

      ANSIC prototype: byte GetReceiverErrorCounter(void)
    • Return value:byte - Returns a value of the reception error counter

  • Methods for not DSP83x derivatives.
    • ReadFrame - Reads a frame from the CAN device. The user is informed about CAN reception through OnFullRxBuffer event or GetStateRX method.

        ANSIC prototype: byte ReadFrame(dword *MessageID,byte *FrameType,byte *FrameFormat,byte *Length,void* Data)
      • MessageID: Pointer to dword - Pointer to a message indentification
      • FrameType: Pointer to byte - Pointer to a frame type
        DATA_FRAME - data frame
        REMOTE_FRAME - remote frame
      • FrameFormat: Pointer to byte - Pointer to a frame format
        STANDARD_FORMAT - standard frame 11-bits
        EXTENDED_FORMAT - extended frame 29-bits.

        Note: This parameter is obsolete and will be removed in future releases.
      • Length: Pointer to byte - Pointer to a length of the frame
      • Data:void* - The buffer for 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_DISABLED - This bean is disabled by user
        ERR_RXEMPTY - The receive buffer is empty
        ERR_OVERRUN - The previous message in the receive buffer was overwriten by a new message.

    • GetStateTX - Returns a value of the transmission complete flags.

        ANSIC prototype: byte GetStateTX(void)
      • Return value:byte - Content of the transmitter complete flag register.

    • GetStateRX - Returns a value of the reception complete flag.

        ANSIC prototype: bool GetStateRX(void)
      • Return value:bool - The value of the receiver complete flag of the given buffer.
        Possible values:
        FALSE - message buffer is empty
        TRUE - message buffer isn't empty

  • GetError - Returns the content of the receiver flag register.

      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

  • Methods for HC08, HCS12 and DSP80x derivatives.
    • SetSleepRequest - This method sets the request to enter Sleep Mode, which is an internal power saving mode.

        ANSIC prototype: void SetSleepRequest(void)

    • ClearSleepRequest - This method clears the request to enter Sleep Mode, which is an internal power saving mode.

        ANSIC prototype: void ClearSleepRequest(void)

    • GetSleepAck - Returns the status of sleep mode acknowledge.

        ANSIC prototype: bool GetSleepAck(void)
      • Return value:bool - TRUE - The MSCAN module has entered Sleep Mode
        FALSE - The MSCAN module hasn't entered Sleep Mode.

    • AbortMessage - Requests that scheduled message buffer is aborted.

        ANSIC prototype: byte AbortMessage(byte BufferMask)
      • BufferMask:byte - Buffer mask that specify transmit buffers to be aborted.
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_DISABLED - This bean is disabled by user
        ERR_VALUE - Some parameter is out of possible range

    • GetAbortMessageAck - Returns the status of the abort message acknowledge.

        ANSIC prototype: byte GetAbortMessageAck(void)
      • Return value:byte - Returns the buffer mask that specifies which transmit buffers were aborted.

  • Methods for HC08, HCS12 and DSP80x derivatives.
    • GetAccHitIndicator - Returns the value of acceptance hit generator.

        ANSIC prototype: byte GetAccHitIndicator(void)
      • Return value:byte - The value of the acceptance hit generator.

  • Methods for HCS12 and HCS12X derivatives.
    • SendFrameExt - Sends a frame. This method automatically selects a free transmit buffer for data transmission. The user cannot specify a transmit buffer.

        ANSIC prototype: byte SendFrameExt(dword MessageID,byte FrameType,byte Length,byte *Data)
      • MessageID:dword - Identification of the message - ID. Message ID can be specified in the STANDARD format (default) or the EXTENDED format. The most significant bit in the ID is set to specify EXTENDED format. Predefined macro CAN_EXTENDED_FRAME_ID can be used (ID "bitwise or" CAN_EXTENDED_FRAME_ID) to mark ID as extended. If the most significant bit of ID is clear, STANDARD format is used.
      • FrameType:byte - Type of frame
        DATA_FRAME - data frame
        REMOTE_FRAME - remote frame
      • Length:byte - The length of the frame in bytes (0..8)
      • Data: Pointer to byte - Pointer to data
      • 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_VALUE - Some parameter is out of possible range

  • Methods for HCS12X derivatives.
    • BusOffRecoveryRequest - The method sets the request for recovery from the bus-off mode. The method is available only if the "Bus-off recovery mode" property is set to "User".

        ANSIC prototype: void BusOffRecoveryRequest(void)


Note: Some methods can be implemented as macros.



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