linux

canSetBusParams

Syntax


#include <canlib.h>
canStatus canSetBusParams(int handle, 
    long freq, 
    unsigned int tseg1,
    unsigned int tseg2, 
    unsigned int sjw, 
    unsigned int noSamp,
    unsigned int syncmode);

Description

This function sets the bus timing parameters for the specified CAN controller.

Input Parameters

handle
An open handle to a CAN controller.
freq
Bit rate (measured in bits per second); or one of the predefined constants BAUD_xxx, which are described below.
tseg1
Time segment 1, that is, the number of quanta from (but not including) the Sync Segment to the sampling point.
tseg2
Time segment 2, that is, the number of quanta from the sampling point to the end of the bit.
sjw
The Syncronization Jump Width; can be 1,2,3, or 4.
noSamp
The number of sampling points; can be 1 or 3.
syncmode
Unsupported and ignored.
Output Parameters

None.

Return Value

canOK (zero) if success
canERR_xxx (negative) if failure.

Default Values

The library provides default values for tseg1, tseg2, sjw and noSamp when freq is specified to one of the following pre-defined constants:

ConstantMeaning
BAUD_1M1 Mbit/s
BAUD_500K500 kbit/s
BAUD_250K250 kbit/s
BAUD_125K125 kbit/s
BAUD_100K100 kbit/s
BAUD_62K62.5 kbit/s
BAUD_50K50 kbit/s

If freq is any other value, no default values are supplied by the library.