www.beck-ipc.com

@CHIP-RTOS C Library V2.06 - CAN API


CAN_Control

Enable or disable specified channels.   Purge specified FIFO's.

int CAN_Control ( unsigned int port_idx,

  unsigned int enables,
  unsigned int disables,
  unsigned int purge_fifos ) ;

Parameters

port_idx

CAN port specifier:   CAN0_PORT = 0, or CAN1_PORT = 1

enables

Bit field indicating which devices to enable.

disables

Bit field indicating which devices to disable.

purge_fifos

Bit field indicating which FIFO's to clear.

Return Value

Error code -
CAN_EC_SUCCESS = 0:   Success
CAN_EC_INVALID_PARAMS = -1:   port_idx is invalid
CAN_EC_PORT_NOT_OPENED = -3:   Port has not been opened.

Comments

This function provides a way to enable or disable the receiver and the three individual transmit register channels.   Also, any or all of the receiver or transmit FIFO's can be cleared.

The CAN_Open_Port() enables all three transmitters and optionally the receiver as well.   So this provisional API here is not necessarily required for CAN port operation.

The input parameters enables, disables and purge_fifos are each bit fields with the identical bit mapping as follows:

    CAN_RX_SEL = 0x8000, Receiver control flag
    CAN_TX1_SEL = 0x0800, TX1 register control flag
    CAN_TX2_SEL = 0x1000, TX2 register control flag
    CAN_TX3_SEL = 0x2000, TX3 register control flag

A bit set indicates that the action associated with the particular CPU register should be taken for the device designed by the bit.   For example:

    CAN_Control(CAN0_PORT,
                CAN_TX3_SEL,        // = enables
                CAN_TX2_SEL,        // = disables
        CAN_RX_SEL | CAN_TX2_SEL) ; // = purge_fifos

This example API call will enable transmit register #3.   It will disable transmit register #2.   It will purge (delete the contents of) the receiver FIFO and the FIFO associated with transmit register #2.

When transmit FIFO's are purged, any CAN message pending output in the specified hardware transmit register is also aborted.

In the non-sense case where a device's bit is set in both the enables and disables input parameters, indicating that both an enabling and disabling action should be taken on the same device, the enabling will take precedence and the device will be enabled.

Note that when the CAN_TX1 transmit FIFO is feeding more than just the TX1 transmit register (CAN_TXQ1_DRIVES_ALL configuration option), all of the transmit registers fed must be blocked with the disables mask in order to stop transmission from this FIFO.

e.g.
    disables = CAN_TX1_SEL | CAN_TX2_SEL | CAN_TX3_SEL ;

would be needed to stop transmission from the CAN_TX1 FIFO if all three transmit registers were being fed from this FIFO.   And likewise, bits for all channels associated with the queue would need to be set in the enables to obtain a full bandwidth draining of the queue into the available hardware transmit registers.

Inside this API the interrupts are masked for a short period and then re-enabled.   This function is reentrant.

See Also

RTOS API

This library function uses a dynamic link to reach the service offered by RTOS software interrupt.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3
    n/an/an/aV0.90

Supported by @CHIP-RTOS C Library since version

    CLIB
    V2.01

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document