Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions boards/posix/native_posix/native_posix.dts
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,16 @@
sample-point = <875>;
bus-speed = <125000>;
};

can0: can {
status = "disabled";
compatible = "zephyr,native-posix-linux-can";
/* adjust zcan0 to desired host interface or create an alternative
* name, e.g.: sudo ip link property add dev vcan0 altname zcan0
*/
host-interface = "zcan0";
sjw = <1>;
sample-point = <875>;
bus-speed = <125000>;
};
};
15 changes: 15 additions & 0 deletions drivers/can/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ zephyr_library_sources_ifdef(CONFIG_CAN_STM32FD can_stm32fd.c)
zephyr_library_sources_ifdef(CONFIG_CAN_STM32H7 can_stm32h7.c)
zephyr_library_sources_ifdef(CONFIG_CAN_RCAR can_rcar.c)

if(CONFIG_CAN_NATIVE_POSIX_LINUX)
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Linux)
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/l2)
zephyr_library_compile_definitions(NO_POSIX_CHEATS)
zephyr_library_compile_definitions(_BSD_SOURCE)
zephyr_library_compile_definitions(_DEFAULT_SOURCE)
zephyr_library_sources(
can_native_posix_linux.c
can_native_posix_linux_socketcan.c
)
else()
message(FATAL_ERROR "CONFIG_CAN_NATIVE_POSIX_LINUX only available on Linux")
endif()
endif()

zephyr_library_sources_ifdef(CONFIG_CAN_SJA1000 can_sja1000.c)
zephyr_library_sources_ifdef(CONFIG_CAN_ESP32_TWAI can_esp32_twai.c)

Expand Down
2 changes: 1 addition & 1 deletion drivers/can/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ source "drivers/can/Kconfig.mcp2515"
source "drivers/can/Kconfig.mcan"
source "drivers/can/Kconfig.rcar"
source "drivers/can/Kconfig.loopback"

source "drivers/can/Kconfig.native_posix_linux"
source "drivers/can/Kconfig.sja1000"
source "drivers/can/Kconfig.esp32"

Expand Down
30 changes: 30 additions & 0 deletions drivers/can/Kconfig.native_posix_linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Native Linux SocketCAN configuration options

# Copyright (c) 2022 Martin Jäger <martin@libre.solar>
# SPDX-License-Identifier: Apache-2.0

config CAN_NATIVE_POSIX_LINUX
bool "Native Linux SocketCAN Driver"
default y
depends on DT_HAS_ZEPHYR_NATIVE_POSIX_LINUX_CAN_ENABLED
help
Enable native Linux SocketCAN Driver

if CAN_NATIVE_POSIX_LINUX

config CAN_NATIVE_POSIX_LINUX_RX_THREAD_PRIORITY
int "Priority for internal RX thread"
default 2
help
Priority level of the internal thread which is run for
handling of incoming packets.

config CAN_MAX_FILTER
int "Maximum number of concurrent active filters"
default 5
range 1 32
help
Defines the array size of the callback/msgq pointers.
Must be at least the size of concurrent reads.

endif # CAN_NATIVE_POSIX_LINUX
Loading