RTEMS 7.0-rc1
Loading...
Searching...
No Matches
Macros | Functions
can-bittiming.c File Reference

This source file is part of CAN/CAN FD bus common support. It implements bit timing calculation. More...

#include <limits.h>
#include <stdlib.h>
#include <dev/can/can.h>
#include <dev/can/can-devcommon.h>

Macros

#define CAN_CALC_MAX_ERROR   50 /* in one-tenth of a percent */
 
#define CAN_CALC_SYNC_SEG   1
 

Functions

int rtems_can_bitrate2bittiming (struct rtems_can_chip *chip, struct rtems_can_bittiming *bt, const struct rtems_can_bittiming_const *btc)
 This function calculates CAN bit timing for given bit rate.
 

Detailed Description

This source file is part of CAN/CAN FD bus common support. It implements bit timing calculation.

Implementation is based on original LinCAN - Linux CAN bus driver Part of OrtCAN project https://ortcan.sourceforge.net/

Function Documentation

◆ rtems_can_bitrate2bittiming()

int rtems_can_bitrate2bittiming ( struct rtems_can_chip chip,
struct rtems_can_bittiming bt,
const struct rtems_can_bittiming_const btc 
)

This function calculates CAN bit timing for given bit rate.

This calculates bit timing values for given bit rate (provided in bt input argument) and controller's maximum/minimal values given by btc argument.

Parameters
chipPointer to rtems_can_chip structure.
btPointer to rtems_can_bittiming structure. Calculated values are stored here.
btcPointer to rtems_can_bittiming_const structure. This provides maximum and minimal bit timing values of the controller.
Returns
Zero on success (and filled bt argument), negative value on error.