Fortec Star Diamond Systems DS-MPE-CAN2L Manual page 19

Pcie minicardi/o expansion module with dual canbus ports
Table of Contents

Advertisement

Baud Rate Configuration
set_baudrate() : This function configures the baud rate for the specified CAN port. By default it will not
configure any baud rate. Below code snippet describes the usage of setting baud rate to 500kbps.
// Set 500k Baud rate for CAN#0
ret_val = set_baudrate(can0_fd, CAN_SPEED_500K ) ;
if ( ret_val < 0 )
{
printf("Error while setting the baud rate \n") ;
exit(0) ;
}
// Set 500k Baud rate for CAN#1
ret_val = set_baudrate(can1_fd, CAN_SPEED_500K ) ;
if ( ret_val < 0 )
{
printf("Error while setting the baud rate \n") ;
exit(0) ;
}
In the above code, can0_fd and can1_fd should contain the values returned by
init_can0 and init_can1 function.
Use below macros for setting the different baud rates. These macros can also be
found in can.h file.
CAN_SPEED_1M
CAN_SPEED_800K
CAN_SPEED_500K
CAN_SPEED_250K
CAN_SPEED_125K
CAN_SPEED_100K
CAN_SPEED_50K
CAN_SPEED_20K
CAN_SPEED_10K
CAN Transmit & Receive
can_tx() & can_rx() : These functions are be used to Transmit and Receive the CAN messages respectively.
DS-MPE-CAN2L User Manual Rev A.1
www.diamondsystems.com
Page 17

Advertisement

Table of Contents
loading

Table of Contents