Skip to content

Commit e9a298e

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

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

can-calc-bit-timing.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,24 @@ static void printf_btr_bxcan(struct can_bittiming *bt, bool hdr)
289289
}
290290
}
291291

292+
static void printf_btr_c_can(struct can_bittiming *bt, bool hdr)
293+
{
294+
if (hdr) {
295+
printf("%s", " BTR BRPEXT");
296+
} else {
297+
uint32_t btr;
298+
uint32_t brpext;
299+
300+
btr = (((bt->brp -1) & 0x3f) << 0) |
301+
(((bt->sjw -1) & 0x3) << 6) |
302+
(((bt->prop_seg + bt->phase_seg1 -1) & 0xf) << 8) |
303+
(((bt->phase_seg2 -1) & 0x7) << 12);
304+
brpext = ((bt->brp -1) >> 6) & 0xf;
305+
306+
printf("0x%04x 0x%04x", btr, brpext);
307+
}
308+
}
309+
292310
static struct calc_bittiming_const can_calc_consts[] = {
293311
{
294312
.bittiming_const = {
@@ -449,6 +467,22 @@ static struct calc_bittiming_const can_calc_consts[] = {
449467
{ .clk = 48000000, },
450468
},
451469
.printf_btr = printf_btr_bxcan,
470+
}, {
471+
.bittiming_const = {
472+
.name = "c_can",
473+
.tseg1_min = 2,
474+
.tseg1_max = 16,
475+
.tseg2_min = 1,
476+
.tseg2_max = 8,
477+
.sjw_max = 4,
478+
.brp_min = 1,
479+
.brp_max = 1024,
480+
.brp_inc = 1,
481+
},
482+
.ref_clk = {
483+
{ .clk = 24000000, },
484+
},
485+
.printf_btr = printf_btr_c_can,
452486
},
453487
};
454488

0 commit comments

Comments
 (0)