Skip to content

Commit e19b5ab

Browse files
committed
can-calc-bittiming: add stm32 bxcan
Signed-off-by: Kurt Van Dijck <[email protected]>
1 parent e9dd86f commit e19b5ab

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

can-calc-bit-timing.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,22 @@ static void printf_btr_rcar_can(struct can_bittiming *bt, bool hdr)
273273
}
274274
}
275275

276+
static void printf_btr_bxcan(struct can_bittiming *bt, bool hdr)
277+
{
278+
if (hdr) {
279+
printf("%10s", "CAN_BTR");
280+
} else {
281+
uint32_t btr;
282+
283+
btr = (((bt->brp -1) & 0x3ff) << 0) |
284+
(((bt->prop_seg + bt->phase_seg1 -1) & 0xf) << 16) |
285+
(((bt->phase_seg2 -1) & 0x7) << 20) |
286+
(((bt->sjw -1) & 0x3) << 24);
287+
288+
printf("0x%08x", btr);
289+
}
290+
}
291+
276292
static struct calc_bittiming_const can_calc_consts[] = {
277293
{
278294
.bittiming_const = {
@@ -417,6 +433,22 @@ static struct calc_bittiming_const can_calc_consts[] = {
417433
{ .clk = 65000000, },
418434
},
419435
.printf_btr = printf_btr_rcar_can,
436+
}, {
437+
.bittiming_const = {
438+
.name = "bxcan",
439+
.tseg1_min = 1,
440+
.tseg1_max = 16,
441+
.tseg2_min = 1,
442+
.tseg2_max = 8,
443+
.sjw_max = 4,
444+
.brp_min = 1,
445+
.brp_max = 1024,
446+
.brp_inc = 1,
447+
},
448+
.ref_clk = {
449+
{ .clk = 48000000, },
450+
},
451+
.printf_btr = printf_btr_bxcan,
420452
},
421453
};
422454

0 commit comments

Comments
 (0)