Skip to content

Commit 63c13b7

Browse files
henrikbrixandersenMaureenHelm
authored andcommitted
drivers: can: add Kconfig option for specifying the sample point margin
Add a Kconfig option for setting the maximum acceptable deviation in sample point location (permille). Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent f484c3c commit 63c13b7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

drivers/can/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ config CAN_DEFAULT_BITRATE_DATA
3838
Default initial CAN data phase bitrate in bits/s. This can be overridden per CAN controller
3939
using the "bitrate-data" devicetree property.
4040

41+
config CAN_SAMPLE_POINT_MARGIN
42+
int "Maximum acceptable sample point location deviation"
43+
default 50
44+
range 0 1000
45+
help
46+
Maximum acceptable deviation in sample point location (permille). A value of 50 means +/-
47+
5 percentage points margin allowed.
48+
4149
config CAN_SHELL
4250
bool "CAN shell"
4351
depends on SHELL

drivers/can/can_common.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212

1313
LOG_MODULE_REGISTER(can_common, CONFIG_CAN_LOG_LEVEL);
1414

15-
/* Maximum acceptable deviation in sample point location (permille) */
16-
#define SAMPLE_POINT_MARGIN 50
17-
1815
/* CAN sync segment is always one time quantum */
1916
#define CAN_SYNC_SEG 1
2017

@@ -402,7 +399,7 @@ int z_impl_can_set_bitrate(const struct device *dev, uint32_t bitrate)
402399
return ret;
403400
}
404401

405-
if (ret > SAMPLE_POINT_MARGIN) {
402+
if (ret > CONFIG_CAN_SAMPLE_POINT_MARGIN) {
406403
return -ERANGE;
407404
}
408405

@@ -448,7 +445,7 @@ int z_impl_can_set_bitrate_data(const struct device *dev, uint32_t bitrate_data)
448445
return ret;
449446
}
450447

451-
if (ret > SAMPLE_POINT_MARGIN) {
448+
if (ret > CONFIG_CAN_SAMPLE_POINT_MARGIN) {
452449
return -ERANGE;
453450
}
454451

0 commit comments

Comments
 (0)