drivers: can: set default initial bitrates via Kconfig
Set the default initial bitrates globally via Kconfig. The initial bitrates can still be overridden using the "bus-speed" and "bus-speed-data" devicetree properties. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
0887986b88
commit
0f7cd6128e
5 changed files with 24 additions and 7 deletions
|
@ -23,6 +23,21 @@ config CAN_INIT_PRIORITY
|
||||||
help
|
help
|
||||||
CAN driver device initialization priority.
|
CAN driver device initialization priority.
|
||||||
|
|
||||||
|
config CAN_DEFAULT_BITRATE
|
||||||
|
int "Default CAN bitrate"
|
||||||
|
default 125000
|
||||||
|
help
|
||||||
|
Default initial CAN bitrate in bits/s. This can be overridden per CAN controller using the
|
||||||
|
"bus-speed" devicetree property.
|
||||||
|
|
||||||
|
config CAN_DEFAULT_BITRATE_DATA
|
||||||
|
int "Default CAN data phase bitrate"
|
||||||
|
default 1000000
|
||||||
|
depends on CAN_FD_MODE
|
||||||
|
help
|
||||||
|
Default initial CAN data phase bitrate in bits/s. This can be overridden per CAN controller
|
||||||
|
using the "bus-speed-data" devicetree property.
|
||||||
|
|
||||||
config CAN_SHELL
|
config CAN_SHELL
|
||||||
bool "CAN shell"
|
bool "CAN shell"
|
||||||
depends on SHELL
|
depends on SHELL
|
||||||
|
|
|
@ -5,9 +5,9 @@ include: base.yaml
|
||||||
properties:
|
properties:
|
||||||
bus-speed:
|
bus-speed:
|
||||||
type: int
|
type: int
|
||||||
required: true
|
|
||||||
description: |
|
description: |
|
||||||
Initial bitrate in bit/s.
|
Initial bitrate in bit/s. If this is unset, the initial bitrate is set to
|
||||||
|
CONFIG_CAN_DEFAULT_BITRATE.
|
||||||
sample-point:
|
sample-point:
|
||||||
type: int
|
type: int
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -5,9 +5,9 @@ include: can-controller.yaml
|
||||||
properties:
|
properties:
|
||||||
bus-speed-data:
|
bus-speed-data:
|
||||||
type: int
|
type: int
|
||||||
required: true
|
|
||||||
description: |
|
description: |
|
||||||
Initial data phase bitrate in bit/s.
|
Initial data phase bitrate in bit/s. If this is unset, the initial data phase bitrate is set
|
||||||
|
to CONFIG_CAN_DEFAULT_BITRATE_DATA.
|
||||||
sample-point-data:
|
sample-point-data:
|
||||||
type: int
|
type: int
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -374,10 +374,11 @@ struct can_driver_config {
|
||||||
.phy = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(node_id, phys)), \
|
.phy = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(node_id, phys)), \
|
||||||
.min_bitrate = DT_CAN_TRANSCEIVER_MIN_BITRATE(node_id, _min_bitrate), \
|
.min_bitrate = DT_CAN_TRANSCEIVER_MIN_BITRATE(node_id, _min_bitrate), \
|
||||||
.max_bitrate = DT_CAN_TRANSCEIVER_MAX_BITRATE(node_id, _max_bitrate), \
|
.max_bitrate = DT_CAN_TRANSCEIVER_MAX_BITRATE(node_id, _max_bitrate), \
|
||||||
.bus_speed = DT_PROP(node_id, bus_speed), \
|
.bus_speed = DT_PROP_OR(node_id, bus_speed, CONFIG_CAN_DEFAULT_BITRATE), \
|
||||||
.sample_point = DT_PROP_OR(node_id, sample_point, 0), \
|
.sample_point = DT_PROP_OR(node_id, sample_point, 0), \
|
||||||
IF_ENABLED(CONFIG_CAN_FD_MODE, \
|
IF_ENABLED(CONFIG_CAN_FD_MODE, \
|
||||||
(.bus_speed_data = DT_PROP_OR(node_id, bus_speed_data, 0), \
|
(.bus_speed_data = DT_PROP_OR(node_id, bus_speed_data, \
|
||||||
|
CONFIG_CAN_DEFAULT_BITRATE_DATA), \
|
||||||
.sample_point_data = DT_PROP_OR(node_id, sample_point_data, 0),)) \
|
.sample_point_data = DT_PROP_OR(node_id, sample_point_data, 0),)) \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
LOG_MODULE_REGISTER(app);
|
LOG_MODULE_REGISTER(app);
|
||||||
|
|
||||||
#define CAN_INTERFACE DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus))
|
#define CAN_INTERFACE DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus))
|
||||||
#define CAN_BITRATE (DT_PROP(DT_CHOSEN(zephyr_canbus), bus_speed) / 1000)
|
#define CAN_BITRATE (DT_PROP_OR(DT_CHOSEN(zephyr_canbus), bus_speed, \
|
||||||
|
CONFIG_CAN_DEFAULT_BITRATE) / 1000)
|
||||||
|
|
||||||
static struct gpio_dt_spec led_green_gpio = GPIO_DT_SPEC_GET_OR(
|
static struct gpio_dt_spec led_green_gpio = GPIO_DT_SPEC_GET_OR(
|
||||||
DT_ALIAS(green_led), gpios, {0});
|
DT_ALIAS(green_led), gpios, {0});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue