Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usb: device: class: gs_usb: allow including header from C++ code #18

Merged
merged 3 commits into from
Sep 20, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ jobs:
EXTRA_TWISTER_FLAGS="--short-build-path -O/tmp/twister-out"
fi
west twister -T app -v --inline-logs --integration $EXTRA_TWISTER_FLAGS

- name: Run tests
working-directory: cannectivity
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
EXTRA_TWISTER_FLAGS="--short-build-path -O/tmp/twister-out"
fi
west twister -T tests -v --inline-logs --integration $EXTRA_TWISTER_FLAGS
8 changes: 8 additions & 0 deletions include/cannectivity/usb/class/gs_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

#include <zephyr/device.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name Geschwister Schneider USB/CAN protocol software/hardware version definitions
* @{
Expand Down Expand Up @@ -631,4 +635,8 @@ struct gs_usb_ops {
int gs_usb_register(const struct device *dev, const struct device **channels, size_t nchannels,
const struct gs_usb_ops *ops, void *user_data);

#ifdef __cplusplus
}
#endif

#endif /* CANNECTIVITY_INCLUDE_USB_CLASS_GS_USB_H_ */
10 changes: 10 additions & 0 deletions tests/subsys/usb/gs_usb/cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Henrik Brix Andersen <[email protected]>
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(cxx LANGUAGES CXX)

FILE(GLOB app_sources src/*.cpp)
target_sources(app PRIVATE ${app_sources})
11 changes: 11 additions & 0 deletions tests/subsys/usb/gs_usb/cxx/app.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 Henrik Brix Andersen <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

&zephyr_udc0 {
gs_usb0: gs_usb0 {
compatible = "gs_usb";
};
};
7 changes: 7 additions & 0 deletions tests/subsys/usb/gs_usb/cxx/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_CPP=y

CONFIG_USB_DEVICE_STACK=y

CONFIG_USB_DEVICE_GS_USB_IDENTIFICATION=y
CONFIG_USB_DEVICE_GS_USB_TIMESTAMP=y
CONFIG_USB_DEVICE_GS_USB_TERMINATION=y
7 changes: 7 additions & 0 deletions tests/subsys/usb/gs_usb/cxx/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright (c) 2024 Henrik Brix Andersen <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <cannectivity/usb/class/gs_usb.h>
33 changes: 33 additions & 0 deletions tests/subsys/usb/gs_usb/cxx/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2024 Henrik Brix Andersen <[email protected]>
# SPDX-License-Identifier: Apache-2.0

common:
tags: usb can
depends_on: usb_device
build_only: true
integration_platforms:
- frdm_k64f
platform_exclude:
- native_sim
tests:
usb.gs_usb.cxx98:
extra_configs:
- CONFIG_STD_CPP98=y
usb.gs_usb.cxx11:
extra_configs:
- CONFIG_STD_CPP11=y
usb.gs_usb.cxx14:
extra_configs:
- CONFIG_STD_CPP14=y
usb.gs_usb.cxx17:
extra_configs:
- CONFIG_STD_CPP17=y
usb.gs_usb.cxx2a:
extra_configs:
- CONFIG_STD_CPP2A=y
usb.gs_usb.cxx20:
extra_configs:
- CONFIG_STD_CPP20=y
usb.gs_usb.cxx2b:
extra_configs:
- CONFIG_STD_CPP2B=y