Skip to content

Commit 37f316e

Browse files
committed
can-calc-bittiming: add mcan
Signed-off-by: Kurt Van Dijck <[email protected]>
1 parent e9a298e commit 37f316e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

can-calc-bit-timing.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,23 @@ static void printf_btr_c_can(struct can_bittiming *bt, bool hdr)
307307
}
308308
}
309309

310+
static void printf_btr_mcan(struct can_bittiming *bt, bool hdr)
311+
{
312+
if (hdr) {
313+
printf("%10s", "NBTP");
314+
} else {
315+
uint32_t nbtp;
316+
317+
318+
nbtp = (((bt->brp -1) & 0x1ff) << 16) |
319+
(((bt->sjw -1) & 0x7f) << 25) |
320+
(((bt->prop_seg + bt->phase_seg1 -1) & 0xff) << 8) |
321+
(((bt->phase_seg2 -1) & 0x7f) << 0);
322+
323+
printf("0x%08x", nbtp);
324+
}
325+
}
326+
310327
static struct calc_bittiming_const can_calc_consts[] = {
311328
{
312329
.bittiming_const = {
@@ -483,6 +500,22 @@ static struct calc_bittiming_const can_calc_consts[] = {
483500
{ .clk = 24000000, },
484501
},
485502
.printf_btr = printf_btr_c_can,
503+
}, {
504+
.bittiming_const = {
505+
.name = "mcan-v3.1+",
506+
.tseg1_min = 2,
507+
.tseg1_max = 256,
508+
.tseg2_min = 2,
509+
.tseg2_max = 128,
510+
.sjw_max = 128,
511+
.brp_min = 1,
512+
.brp_max = 512,
513+
.brp_inc = 1,
514+
},
515+
.ref_clk = {
516+
{ .clk = 40000000, },
517+
},
518+
.printf_btr = printf_btr_mcan,
486519
},
487520
};
488521

0 commit comments

Comments
 (0)