drivers: can: make the fake CAN driver generally available
Make the fake CAN controller driver available for use in tests outside of the CAN shell test. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
662aed81d2
commit
f30a5969d0
10 changed files with 29 additions and 29 deletions
|
@ -4,6 +4,7 @@ zephyr_library()
|
||||||
zephyr_sources_ifdef(CONFIG_CAN_MCUX_MCAN can_mcux_mcan.c)
|
zephyr_sources_ifdef(CONFIG_CAN_MCUX_MCAN can_mcux_mcan.c)
|
||||||
|
|
||||||
zephyr_library_sources_ifdef(CONFIG_CAN can_common.c)
|
zephyr_library_sources_ifdef(CONFIG_CAN can_common.c)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_CAN_FAKE can_fake.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_CAN_LOOPBACK can_loopback.c)
|
zephyr_library_sources_ifdef(CONFIG_CAN_LOOPBACK can_loopback.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_CAN_MCAN can_mcan.c)
|
zephyr_library_sources_ifdef(CONFIG_CAN_MCAN can_mcan.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_CAN_MCP2515 can_mcp2515.c)
|
zephyr_library_sources_ifdef(CONFIG_CAN_MCP2515 can_mcp2515.c)
|
||||||
|
|
|
@ -111,6 +111,7 @@ source "drivers/can/Kconfig.native_posix_linux"
|
||||||
source "drivers/can/Kconfig.sja1000"
|
source "drivers/can/Kconfig.sja1000"
|
||||||
source "drivers/can/Kconfig.esp32"
|
source "drivers/can/Kconfig.esp32"
|
||||||
source "drivers/can/Kconfig.kvaser"
|
source "drivers/can/Kconfig.kvaser"
|
||||||
|
source "drivers/can/Kconfig.fake"
|
||||||
|
|
||||||
source "drivers/can/transceiver/Kconfig"
|
source "drivers/can/transceiver/Kconfig"
|
||||||
|
|
||||||
|
|
13
drivers/can/Kconfig.fake
Normal file
13
drivers/can/Kconfig.fake
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Fake CAN configuration options
|
||||||
|
|
||||||
|
# Copyright (c) 2022 Vestas Wind Systems A/S
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
config CAN_FAKE
|
||||||
|
bool "Fake CAN driver"
|
||||||
|
default y
|
||||||
|
depends on DT_HAS_ZEPHYR_FAKE_CAN_ENABLED
|
||||||
|
select CAN_HAS_CANFD
|
||||||
|
select CAN_HAS_RX_TIMESTAMP
|
||||||
|
help
|
||||||
|
Enable support for the FFF-based fake CAN driver.
|
|
@ -6,15 +6,14 @@
|
||||||
|
|
||||||
#include <zephyr/device.h>
|
#include <zephyr/device.h>
|
||||||
#include <zephyr/drivers/can.h>
|
#include <zephyr/drivers/can.h>
|
||||||
|
#include <zephyr/drivers/can/can_fake.h>
|
||||||
#include <zephyr/fff.h>
|
#include <zephyr/fff.h>
|
||||||
|
|
||||||
#ifdef CONFIG_ZTEST_NEW_API
|
#ifdef CONFIG_ZTEST_NEW_API
|
||||||
#include <zephyr/ztest.h>
|
#include <zephyr/ztest.h>
|
||||||
#endif /* CONFIG_ZTEST_NEW_API */
|
#endif /* CONFIG_ZTEST_NEW_API */
|
||||||
|
|
||||||
#include "fake_can.h"
|
#define DT_DRV_COMPAT zephyr_fake_can
|
||||||
|
|
||||||
#define DT_DRV_COMPAT test_fake_can
|
|
||||||
|
|
||||||
DEFINE_FAKE_VALUE_FUNC(int, fake_can_start, const struct device *);
|
DEFINE_FAKE_VALUE_FUNC(int, fake_can_start, const struct device *);
|
||||||
|
|
10
dts/bindings/can/zephyr,fake-can.yaml
Normal file
10
dts/bindings/can/zephyr,fake-can.yaml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Copyright (c) 2022 Vestas Wind Systems A/S
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
description: |
|
||||||
|
This binding provides a fake CAN controller for use as either a stub or a mock in Zephyr
|
||||||
|
testing.
|
||||||
|
|
||||||
|
compatible: "zephyr,fake-can"
|
||||||
|
|
||||||
|
include: can-fd-controller.yaml
|
|
@ -1,13 +0,0 @@
|
||||||
# Copyright (c) 2022 Vestas Wind Systems A/S
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
config TEST_FAKE_CAN
|
|
||||||
bool
|
|
||||||
default y
|
|
||||||
depends on DT_HAS_TEST_FAKE_CAN_ENABLED
|
|
||||||
select CAN_HAS_RX_TIMESTAMP
|
|
||||||
select CAN_HAS_CANFD
|
|
||||||
help
|
|
||||||
Enable support for the fake CAN driver.
|
|
||||||
|
|
||||||
source "Kconfig.zephyr"
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
/{
|
/{
|
||||||
fake_can: fake_can {
|
fake_can: fake_can {
|
||||||
compatible = "test-fake-can";
|
compatible = "zephyr,fake-can";
|
||||||
status = "okay";
|
status = "okay";
|
||||||
sjw = <1>;
|
sjw = <1>;
|
||||||
sample-point = <875>;
|
sample-point = <875>;
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
# Copyright (c) 2022 Vestas Wind Systems A/S
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
description: |
|
|
||||||
This binding provides resources required to build and run the
|
|
||||||
tests/drivers/can/shell test in Zephyr.
|
|
||||||
|
|
||||||
compatible: "test-fake-can"
|
|
||||||
|
|
||||||
include: can-fd-controller.yaml
|
|
|
@ -4,11 +4,10 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fake_can.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <zephyr/drivers/can.h>
|
#include <zephyr/drivers/can.h>
|
||||||
|
#include <zephyr/drivers/can/can_fake.h>
|
||||||
#include <zephyr/fff.h>
|
#include <zephyr/fff.h>
|
||||||
#include <zephyr/shell/shell.h>
|
#include <zephyr/shell/shell.h>
|
||||||
#include <zephyr/shell/shell_dummy.h>
|
#include <zephyr/shell/shell_dummy.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue