Merge pull request #14828 from wosym/candev_native_check
tests/candev: Prevent user from attempting to use native can interface on non-native board
This commit is contained in:
commit
083b73d71b
@ -1,11 +1,21 @@
|
||||
include ../Makefile.tests_common
|
||||
BOARD_WHITELIST := native
|
||||
|
||||
USEMODULE += shell
|
||||
USEMODULE += can
|
||||
USEMODULE += isrpipe
|
||||
|
||||
# define the CAN driver you want to use here
|
||||
CAN_DRIVER ?= native
|
||||
CAN_DRIVER ?= CAN_NATIVE
|
||||
|
||||
# prevent using native driver on non-native board
|
||||
ifeq ($(CAN_DRIVER), CAN_NATIVE)
|
||||
ifneq ($(BOARD), native)
|
||||
$(error native can driver can only be used on native board!)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
ifeq ($(CAN_DRIVER), PERIPH_CAN)
|
||||
# periph_can modules/variables go here
|
||||
@ -15,6 +25,4 @@ else ifeq ($(CAN_DRIVER), CAN_NATIVE)
|
||||
|
||||
endif
|
||||
|
||||
CFLAGS += -DCAN_DRIVER_$(CAN_DRIVER)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
#include "shell.h"
|
||||
#include "can/device.h"
|
||||
|
||||
#ifdef BOARD_NATIVE
|
||||
#if IS_USED(MODULE_CAN_LINUX)
|
||||
|
||||
#include <candev_linux.h>
|
||||
|
||||
@ -192,7 +192,7 @@ int main(void)
|
||||
puts("candev test application\n");
|
||||
|
||||
isrpipe_init(&rxbuf, (uint8_t *)rx_ringbuf, sizeof(rx_ringbuf));
|
||||
#ifdef BOARD_NATIVE
|
||||
#if IS_USED(MODULE_CAN_LINUX)
|
||||
puts("Initializing Linux Can device");
|
||||
candev_linux_init( &linux_dev, &(candev_linux_conf[0])); /* vcan0 */
|
||||
candev = (candev_t *)&linux_dev;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user