Skip to content

Commit 1c7feb3

Browse files
henrikbrixandersencarlescufi
authored andcommitted
drivers: can: shell: show min/max timing parameters
Include the minimum/maximum timing parameters when showing details about a CAN controller. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent 5e6c733 commit 1c7feb3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/can/can_shell.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ static int cmd_can_stop(const struct shell *sh, size_t argc, char **argv)
273273
static int cmd_can_show(const struct shell *sh, size_t argc, char **argv)
274274
{
275275
const struct device *dev = device_get_binding(argv[1]);
276+
const struct can_timing *timing_min;
277+
const struct can_timing *timing_max;
276278
struct can_bus_err_cnt err_cnt;
277279
enum can_state state;
278280
uint32_t max_bitrate = 0;
@@ -336,6 +338,30 @@ static int cmd_can_show(const struct shell *sh, size_t argc, char **argv)
336338
shell_print(sh, "rx errors: %d", err_cnt.rx_err_cnt);
337339
shell_print(sh, "tx errors: %d", err_cnt.tx_err_cnt);
338340

341+
timing_min = can_get_timing_min(dev);
342+
timing_max = can_get_timing_max(dev);
343+
344+
shell_print(sh, "timing: sjw %u..%u, prop_seg %u..%u, "
345+
"phase_seg1 %u..%u, phase_seg2 %u..%u, prescaler %u..%u",
346+
timing_min->sjw, timing_max->sjw,
347+
timing_min->prop_seg, timing_max->prop_seg,
348+
timing_min->phase_seg1, timing_max->phase_seg1,
349+
timing_min->phase_seg2, timing_max->phase_seg2,
350+
timing_min->prescaler, timing_max->prescaler);
351+
352+
if (IS_ENABLED(CONFIG_CAN_FD_MODE) && (cap & CAN_MODE_FD) != 0) {
353+
timing_min = can_get_timing_data_min(dev);
354+
timing_max = can_get_timing_data_max(dev);
355+
356+
shell_print(sh, "timing data: sjw %u..%u, prop_seg %u..%u, "
357+
"phase_seg1 %u..%u, phase_seg2 %u..%u, prescaler %u..%u",
358+
timing_min->sjw, timing_max->sjw,
359+
timing_min->prop_seg, timing_max->prop_seg,
360+
timing_min->phase_seg1, timing_max->phase_seg1,
361+
timing_min->phase_seg2, timing_max->phase_seg2,
362+
timing_min->prescaler, timing_max->prescaler);
363+
}
364+
339365
return 0;
340366
}
341367

0 commit comments

Comments
 (0)