Skip to content

Commit cf890c0

Browse files
committed
add zephyr twister test for USB device level testing
Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
1 parent f7e0834 commit cf890c0

34 files changed

Lines changed: 870 additions & 47 deletions

.github/workflows/arm-gcc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ARM GNU Toolchain
1+
name: MCUXpresso SDK with ARM GCC
22

33
on:
44
push:

.github/workflows/cmake-multi-platform.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
22
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
3-
name: CMake on multiple platforms
3+
name: Native build
44

55
on:
66
push:

.github/workflows/zephyr.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build for Zephyr
1+
name: Zephyr Twister build and tests
22

33
on:
44
push:
@@ -15,7 +15,6 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ubuntu-24.04]
18-
board: [nrf52840dk/nrf52840]
1918
runs-on: ${{ matrix.os }}
2019
steps:
2120
- name: Checkout
@@ -38,20 +37,11 @@ jobs:
3837
with:
3938
manifest: west4nrfsdk.yml
4039

41-
- name: Build ble-keyboard firmware
42-
working-directory: zephyr/examples/ble-keyboard
40+
- name: Run twister build and tests
41+
working-directory: zephyr
4342
shell: bash
4443
run: |
45-
west build -b ${{ matrix.board }} -d build/${{ matrix.board }}
46-
47-
- name: Build usb-keyboard firmware
48-
working-directory: zephyr/examples/usb-keyboard
49-
shell: bash
50-
run: |
51-
west build -b ${{ matrix.board }} -d build/${{ matrix.board }}
52-
53-
- name: Build usb-shell firmware
54-
working-directory: zephyr/examples/usb-shell
55-
shell: bash
56-
run: |
57-
west build -b ${{ matrix.board }} -d build/${{ matrix.board }}
44+
west twister -T . \
45+
-p native_sim/native/64 -p qemu_cortex_m3 \
46+
-p nrf52840dk/nrf52840 -p nrf54lm20dk/nrf54lm20a/cpuapp \
47+
--inline-logs -v

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Configurable Composite (c2) USB device library
22

3+
![Native Build](https://github.com/IntergatedCircuits/c2usb/actions/workflows/cmake-multi-platform.yml/badge.svg)
4+
![Zephyr Build](https://github.com/IntergatedCircuits/c2usb/actions/workflows/zephyr.yml/badge.svg)
5+
![MCUXpresso Build](https://github.com/IntergatedCircuits/c2usb/actions/workflows/arm-gcc.yml/badge.svg)
6+
37
This is a 2nd generation USB device library,
48
designed with an emphasis of maximum flexibility for configurability and composability.
59
The device framework is designed to scale well to designs of any complexity,

c2usb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CPMAddPackage("gh:Neargye/magic_enum@0.9.3")
3838
include(../cmake/get_cpm.cmake)
3939
if(ZEPHYR_HID_RP_MODULE_DIR OR MCUX_HID_RP_MODULE_DIR)
4040
else()
41-
CPMAddPackage("gh:IntergatedCircuits/hid-rp#1cf78a8905c13e3670fe4999523cb04ad01f18ee")
41+
CPMAddPackage("gh:IntergatedCircuits/hid-rp#770f31f71bf602f6d0a9c387dccd4b54dbe6d7c8")
4242
endif()
4343

4444
if(ZEPHYR_ETL_MODULE_DIR OR MCUX_ETL_MODULE_DIR)

c2usb/port/zephyr/Kconfig.shell

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
menuconfig SHELL_BACKEND_C2USB
33
bool "c2usb shell backend"
4+
depends on SHELL
45
help
56
Build c2usb shell backend.
67

c2usb/port/zephyr/udc_mac.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ namespace usb::zephyr
2626
class udc_mac : public df::mac
2727
{
2828
public:
29+
static constexpr usb::speeds supported_speeds()
30+
{
31+
#if !defined(CONFIG_UDC_DRIVER_HIGH_SPEED_SUPPORT_ENABLED) || \
32+
!defined(CONFIG_UDC_DRIVER_HAS_HIGH_SPEED_SUPPORT)
33+
return usb::speeds(usb::speed::FULL);
34+
#else
35+
return usb::speeds(usb::speed::FULL, usb::speed::HIGH);
36+
#endif
37+
}
38+
2939
udc_mac(const ::device* dev, size_t ctrl_ep_buf_size);
3040
udc_mac(const ::device* dev, size_t ctrl_ep_buf_size, usb::power::state power_state);
3141
~udc_mac() override;

c2usb/port/zephyr/usb_shell.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include "port/zephyr/usb_shell.hpp"
1+
// SPDX-License-Identifier: MPL-2.0
2+
#include "usb_shell.hpp"
23
#include <cassert>
34

45
extern "C" const struct shell* c2usb_shell_handle();

c2usb/port/zephyr/usb_shell.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#ifndef __USB_SHELL_HPP
2-
#define __USB_SHELL_HPP
3-
1+
// SPDX-License-Identifier: MPL-2.0
2+
#pragma once
43
#include <atomic>
54
#include <optional>
65
#include <zephyr/shell/shell.h>
@@ -119,5 +118,3 @@ class usb_shell : public usb::df::cdc::acm::function
119118
};
120119

121120
} // namespace usb::zephyr
122-
123-
#endif // __USB_SHELL_HPP

c2usb/usb/base.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct descriptor : public descriptor_header
5858
constexpr descriptor(uint8_t length)
5959
: descriptor_header(length, type())
6060
{}
61+
62+
[[nodiscard]] constexpr bool type_valid() const { return (bDescriptorType == type()); }
6163
};
6264

6365
// TODO: https://github.com/mariusbancila/stduuid

0 commit comments

Comments
 (0)