diff -r 000000000000 -r 4472ee7c6c3e drivers/ecos_lpc2138_sja1000/build_baudrate.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/drivers/ecos_lpc2138_sja1000/build_baudrate.c Wed May 10 16:59:40 2006 +0200 @@ -0,0 +1,126 @@ +#include +#include + + +/* + CiA DS-301, p.20 +*/ +#define MAX_BIT_TIMING 9 +int table_bit_timing_settings[MAX_BIT_TIMING][3] = +{ + {1000, 8, 6}, /* baudrate, number of time quanta per bit, tsync+tseg1 */ + {800, 10, 8}, + {500, 16, 14}, + {250, 16, 14}, + {125, 16, 14}, + {100, 16, 14}, + { 50, 16, 14}, + { 25, 16, 14}, + { 10, 16, 14} +}; + + +void can_timing_registers(double f, int *v) +/* fill the vector v with the proper setting for TIMER 0 and TIMER 1 + regarding the clock and the baudrate */ +{ + int i; + + int BRP, TSEG1, TSEG2; + + double nominal, tq, tscl; + + double tclk = 1 / (f*1e6); /* sec */ + + for(i=0; i