]> rtime.felk.cvut.cz Git - can-utils.git/blobdiff - can-calc-bit-timing.c
slcand: add flow control option
[can-utils.git] / can-calc-bit-timing.c
index f49ba0974c8d10f4f9fdeb4f5e5118ee12a1a839..ba50cdc8ce8c09e6acaf26139f6261df41640d69 100644 (file)
@@ -26,7 +26,7 @@
 #define ENOTSUPP       524     /* Operation is not supported */
 #endif
 
-/* usefull defines */
+/* useful defines */
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 #define do_div(a,b) a = (a) / (b)
@@ -192,13 +192,30 @@ static void printf_btr_mcp251x(struct can_bittiming *bt, int hdr)
        if (hdr) {
                printf("CNF1 CNF2 CNF3");
        } else {
-               cnf1 = ((bt->sjw - 1) << 6) | bt->brp;
+               cnf1 = ((bt->sjw - 1) << 6) | (bt->brp - 1);
                cnf2 = 0x80 | ((bt->phase_seg1 - 1) << 3) | (bt->prop_seg - 1);
                cnf3 = bt->phase_seg2 - 1;
                printf("0x%02x 0x%02x 0x%02x", cnf1, cnf2, cnf3);
        }
 }
 
+static void printf_btr_ti_hecc(struct can_bittiming *bt, int hdr)
+{
+       if (hdr) {
+               printf("%10s", "CANBTC");
+       } else {
+               uint32_t can_btc;
+
+               can_btc = (bt->phase_seg2 - 1) & 0x7;
+               can_btc |= ((bt->phase_seg1 + bt->prop_seg - 1)
+                           & 0xF) << 3;
+               can_btc |= ((bt->sjw - 1) & 0x3) << 8;
+               can_btc |= ((bt->brp - 1) & 0xFF) << 16;
+
+               printf("0x%08x", can_btc);
+       }
+}
+
 static struct can_bittiming_const can_calc_consts[] = {
        {
                .name = "sja1000",
@@ -270,6 +287,20 @@ static struct can_bittiming_const can_calc_consts[] = {
                .ref_clk = 33333333,
                .printf_btr = printf_btr_sja1000,
        },
+       {
+               .name = "mscan",
+               .tseg1_min = 4,
+               .tseg1_max = 16,
+               .tseg2_min = 2,
+               .tseg2_max = 8,
+               .sjw_max = 4,
+               .brp_min = 1,
+               .brp_max = 64,
+               .brp_inc = 1,
+
+               .ref_clk = 66660000,    /* mpc5121 */
+               .printf_btr = printf_btr_sja1000,
+       },
        {
                .name = "at91",
                .tseg1_min = 4,
@@ -383,6 +414,20 @@ static struct can_bittiming_const can_calc_consts[] = {
                .ref_clk = 16000000,
                .printf_btr = printf_btr_mcp251x,
        },
+       {
+               .name = "ti_hecc",
+               .tseg1_min = 1,
+               .tseg1_max = 16,
+               .tseg2_min = 1,
+               .tseg2_max = 8,
+               .sjw_max = 4,
+               .brp_min = 1,
+               .brp_max = 256,
+               .brp_inc = 1,
+
+               .ref_clk = 13000000,
+               .printf_btr = printf_btr_ti_hecc,
+       }
 };
 
 static long common_bitrates[] = {