1# SPDX-License-Identifier: Apache-2.0
2
3zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/can.h)
4
5zephyr_library()
6zephyr_sources_ifdef(CONFIG_CAN_MCUX_MCAN    can_mcux_mcan.c)
7
8zephyr_library_sources_ifdef(CONFIG_CAN                     can_common.c)
9zephyr_library_sources_ifdef(CONFIG_CAN_FAKE                can_fake.c)
10zephyr_library_sources_ifdef(CONFIG_CAN_LOOPBACK            can_loopback.c)
11zephyr_library_sources_ifdef(CONFIG_CAN_MCAN                can_mcan.c)
12zephyr_library_sources_ifdef(CONFIG_CAN_MCP2515             can_mcp2515.c)
13zephyr_library_sources_ifdef(CONFIG_CAN_MCP251XFD           can_mcp251xfd.c)
14zephyr_library_sources_ifdef(CONFIG_CAN_MCUX_FLEXCAN        can_mcux_flexcan.c)
15zephyr_library_sources_ifdef(CONFIG_CAN_SAM                 can_sam.c)
16zephyr_library_sources_ifdef(CONFIG_CAN_SAM0                can_sam0.c)
17zephyr_library_sources_ifdef(CONFIG_CAN_STM32_BXCAN         can_stm32_bxcan.c)
18zephyr_library_sources_ifdef(CONFIG_CAN_STM32_FDCAN         can_stm32_fdcan.c)
19zephyr_library_sources_ifdef(CONFIG_CAN_STM32H7_FDCAN       can_stm32h7_fdcan.c)
20zephyr_library_sources_ifdef(CONFIG_CAN_TCAN4X5X            can_tcan4x5x.c)
21zephyr_library_sources_ifdef(CONFIG_CAN_RCAR                can_rcar.c)
22zephyr_library_sources_ifdef(CONFIG_CAN_NUMAKER             can_numaker.c)
23zephyr_library_sources_ifdef(CONFIG_CAN_XMC4XXX             can_xmc4xxx.c)
24zephyr_library_sources_ifdef(CONFIG_CAN_SJA1000             can_sja1000.c)
25zephyr_library_sources_ifdef(CONFIG_CAN_ESP32_TWAI          can_esp32_twai.c)
26zephyr_library_sources_ifdef(CONFIG_CAN_KVASER_PCI          can_kvaser_pci.c)
27zephyr_library_sources_ifdef(CONFIG_CAN_NRF                 can_nrf.c)
28zephyr_library_sources_ifdef(CONFIG_CAN_RENESAS_RA_CANFD    can_renesas_ra.c)
29
30zephyr_library_sources_ifdef(CONFIG_USERSPACE        can_handlers.c)
31zephyr_library_sources_ifdef(CONFIG_CAN_SHELL        can_shell.c)
32zephyr_library_sources_ifdef(CONFIG_CAN_NXP_S32_CANXL    can_nxp_s32_canxl.c)
33
34if(CONFIG_CAN_NATIVE_LINUX)
35  if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Linux)
36    zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/l2)
37    zephyr_library_sources(can_native_linux.c)
38
39    if (CONFIG_NATIVE_APPLICATION)
40      set_source_files_properties(can_native_linux_adapt.c
41        PROPERTIES COMPILE_DEFINITIONS
42        "NO_POSIX_CHEATS;_BSD_SOURCE;_DEFAULT_SOURCE")
43      zephyr_library_sources(can_native_linux_adapt.c)
44    else()
45      target_sources(native_simulator INTERFACE can_native_linux_adapt.c)
46    endif()
47  else()
48    message(FATAL_ERROR "CONFIG_CAN_NATIVE_LINUX is only available on Linux")
49  endif()
50endif()
51
52add_subdirectory(transceiver)
53