Skip to content

Commit cdcc8be

Browse files
rdu-westonpllee4-weston
authored andcommitted
rebase: rebased jukkar:canbus-driver-for-native_posix to tag zephyr-v2.6.0
Update file name canbus_native_posix_xx.x to can_native_posix_xx.x to keep consistent with can driver for other platforms. Update implementation to work with the current state of zephyr and update samples/net/sockets/can/boards/native_posix.conf. Replace deprecated DEVICE_AND_API_INIT() with DEVICE_DT_INST_DEFINE() and add can_1 and can_2 in native_posix.dts. Signed-off-by: Ruixiang Du <[email protected]>
1 parent 2d0cb8b commit cdcc8be

File tree

8 files changed

+448
-323
lines changed

8 files changed

+448
-323
lines changed

boards/posix/native_posix/Kconfig.defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ config NET_L2_ETHERNET
2323
config ETH_NATIVE_POSIX
2424
default y if NET_L2_ETHERNET
2525

26+
config CAN_NATIVE_POSIX
27+
default y if NET_SOCKETS_CAN
28+
2629
endif # NETWORKING
2730

2831
config FAKE_ENTROPY_NATIVE_POSIX

boards/posix/native_posix/native_posix.dts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@
141141
current-speed = <0>;
142142
};
143143

144+
can1: can_1 {
145+
status = "okay";
146+
compatible = "zephyr,native-posix-can";
147+
label = "CAN_1";
148+
/* Dummy bus-speed entry to comply with can
149+
* DTS binding
150+
*/
151+
bus-speed = <500000>;
152+
};
153+
154+
can2: can_2 {
155+
status = "okay";
156+
compatible = "zephyr,native-posix-can";
157+
label = "CAN_2";
158+
/* Dummy bus-speed entry to comply with can
159+
* DTS binding
160+
*/
161+
bus-speed = <500000>;
162+
};
163+
144164
rng: rng {
145165
status = "okay";
146166
compatible = "zephyr,native-posix-rng";

drivers/can/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if(CONFIG_CAN_NATIVE_POSIX)
2020
zephyr_library_compile_definitions(_BSD_SOURCE)
2121
zephyr_library_compile_definitions(_DEFAULT_SOURCE)
2222
zephyr_library_sources(
23-
canbus_native_posix.c
24-
canbus_native_posix_adapt.c
23+
can_native_posix.c
24+
can_native_posix_adapt.c
2525
)
26-
endif()
26+
endif()

drivers/can/Kconfig.native_posix

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
config CAN_NATIVE_POSIX
1010
bool "native_posix CAN Driver"
11-
depends on ARCH_POSIX
11+
depends on ARCH_POSIX && NETWORKING
1212
help
1313
Enable native_posix CAN driver
1414

15+
if CAN_NATIVE_POSIX
16+
1517
config CAN_MAX_FILTER
1618
int "Maximum number of concurrent active filters"
1719
depends on CAN_NATIVE_POSIX
@@ -21,8 +23,52 @@ config CAN_MAX_FILTER
2123
Defines the array size of the callback/msgq pointers.
2224
Must be at least the size of concurrent reads.
2325

24-
config CAN_NATIVE_POSIX_INTERFACE_NAME
25-
string "CANBUS interface name in Linux side"
26-
default "zcan"
26+
## Interface 1
27+
config CAN_NATIVE_POSIX_INTERFACE_1_ENABLE
28+
bool "CANBUS interface 1"
29+
default y
30+
depends on CAN_NATIVE_POSIX
31+
help
32+
This option enables the CANBUS network interface for Native POSIX board.
33+
34+
config CAN_NATIVE_POSIX_INTERFACE_1_NAME
35+
string "CANBUS interface 1 name on Linux side"
36+
depends on CAN_NATIVE_POSIX_INTERFACE_1_ENABLE
37+
default "vcan0"
38+
help
39+
This option sets the CANBUS network interface 1 name in host system.
40+
41+
config CAN_NATIVE_POSIX_INTERFACE_1_SOCKETCAN_NAME
42+
string "Network device name"
43+
depends on CAN_NATIVE_POSIX_INTERFACE_1_ENABLE
44+
default "SOCKET_CAN_1"
45+
help
46+
Name of the network device driver for SocketCAN.
47+
48+
## Interface 2
49+
config CAN_NATIVE_POSIX_INTERFACE_2_ENABLE
50+
bool "CANBUS interface 2"
51+
default y
52+
depends on CAN_NATIVE_POSIX
2753
help
28-
This option sets the CANBUS network interface name in host system.
54+
This option enables the CANBUS network interface for Native POSIX board.
55+
56+
if CAN_NATIVE_POSIX_INTERFACE_2_ENABLE
57+
58+
config CAN_NATIVE_POSIX_INTERFACE_2_NAME
59+
string "CANBUS interface 2 name on Linux side"
60+
depends on CAN_NATIVE_POSIX_INTERFACE_2_ENABLE
61+
default "vcan1"
62+
help
63+
This option sets the CANBUS network interface 1 name in host system.
64+
65+
config CAN_NATIVE_POSIX_INTERFACE_2_SOCKETCAN_NAME
66+
string "Network device name"
67+
depends on CAN_NATIVE_POSIX_INTERFACE_2_ENABLE
68+
default "SOCKET_CAN_2"
69+
help
70+
Name of the network device driver for SocketCAN.
71+
72+
endif # CAN_NATIVE_POSIX_INTERFACE_2_ENABLE
73+
74+
endif # CAN_NATIVE_POSIX

0 commit comments

Comments
 (0)