diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc8ea8e..838d0f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,15 +35,15 @@ jobs: - uses: actions-rs/cargo@v1 with: - command: check + command: build args: --all-targets - uses: actions-rs/cargo@v1 with: - command: check - args: --features control-buffer-256 + command: build + args: --all-targets --features control-buffer-256 - uses: actions-rs/cargo@v1 with: - command: check - args: --features defmt + command: build + args: --all-targets --features defmt diff --git a/Cargo.toml b/Cargo.toml index e1da13e..d6415da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,33 +1,6 @@ -[package] -name = "usb-device" -description = "Experimental device-side USB stack for embedded devices." -version = "0.2.9" -edition = "2018" -readme = "README.md" -keywords = ["no-std", "embedded", "usb"] -license = "MIT" -authors = ["Matti Virkkunen "] -repository = "https://github.com/mvirkkunen/usb-device" +[workspace] -[dependencies] -defmt = { version = "0.3", optional = true } - -[dev-dependencies] -rusb = "0.9.1" -rand = "0.8.5" - -[features] -# Use a 256 byte buffer for control transfers instead of 128. -control-buffer-256 = [] - -# Use larger endpoint buffers for highspeed operation (default fullspeed) -# -# Note: usb-device doesn't truly support high speed enumeration yet, so setting this will make -# TestClass only compliant with high speed mode. It may still manage to be enumerated as a full -# speed device, but the descriptors will be invalid. -test-class-high-speed = [] - -[[test]] -name = "test_class_host" -path = "tests/test_class_host/main.rs" -harness = false +members = [ + "usb-device", + "tests/test_class_host" +] \ No newline at end of file diff --git a/README.md b/README.md index 048c6a2..be77a5e 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ Class crates * [usbd-hid](https://github.com/twitchyliquid64/usbd-hid) [![Crates.io](https://img.shields.io/crates/v/usbd-hid.svg)](https://crates.io/crates/usbd-hid) - HID class * [usbd-serial](https://github.com/mvirkkunen/usbd-serial) [![Crates.io](https://img.shields.io/crates/v/usbd-serial.svg)](https://crates.io/crates/usbd-serial) - CDC-ACM serial port class +Development +----------- + +### Testing + +Testing `usb-device` involves a test suite running on a host computer, connected via USB to a target computer (microcontroller) which provides a test device. See [here](https://github.com/rust-embedded-community/usb-device/tree/master/tests) for further details. Others ------ diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..27486f8 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,10 @@ +usb-device testing +================== + +Testing `usb-device` involves a test suite running on a host computer, connected via USB to a target computer (microcontroller) which provides a test device. +For the host part, see the `test_class_host` folder. +For the device part, external crates are required since `usb-device` only provides an interface but not any hardware drivers. +Here is a list of hardware implementations of the test suite: + +* [stm32-usbd-tests](https://github.com/Disasm/stm32-usbd-tests) and [usb-otg-workspace](https://github.com/Disasm/usb-otg-workspace) for STM32 parts. +* [test-usb-device](https://github.com/ianrrees/test-usb-device) for ATSAMD parts. diff --git a/tests/test_class_host/Cargo.toml b/tests/test_class_host/Cargo.toml new file mode 100644 index 0000000..ea300b1 --- /dev/null +++ b/tests/test_class_host/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "usb-device-test-class-host" +description = "Test class host for usb-device." +version = "0.2.9" +edition = "2018" +readme = "../README.md" +keywords = ["no-std", "embedded", "usb"] +license = "MIT" +authors = [ + "Matti Virkkunen ", + "Rust Embedded Community Contributors" +] +repository = "https://github.com/rust-embedded-community/usb-device" + +[dependencies] +usb-device = { path = "../../usb-device" } + +[dev-dependencies] +rusb = "0.9.1" +rand = "0.8.5" + +[[test]] +name = "test_class_host" +path = "main.rs" +harness = false diff --git a/LICENSE b/tests/test_class_host/LICENSE similarity index 95% rename from LICENSE rename to tests/test_class_host/LICENSE index 51b8501..57a6424 100644 --- a/LICENSE +++ b/tests/test_class_host/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Matti Virkkunen +Copyright (c) 2018 Matti Virkkunen and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/CHANGELOG.md b/usb-device/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to usb-device/CHANGELOG.md diff --git a/usb-device/Cargo.toml b/usb-device/Cargo.toml new file mode 100644 index 0000000..396d6fc --- /dev/null +++ b/usb-device/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "usb-device" +description = "Experimental device-side USB stack for embedded devices." +version = "0.2.9" +edition = "2018" +readme = "../README.md" +keywords = ["no-std", "embedded", "usb"] +license = "MIT" +authors = [ + "Matti Virkkunen ", + "Rust Embedded Community Contributors" +] +repository = "https://github.com/rust-embedded-community/usb-device" + +[dependencies] +defmt = { version = "0.3", optional = true } + +[features] +# Use a 256 byte buffer for control transfers instead of 128. +control-buffer-256 = [] + +# Use larger endpoint buffers for highspeed operation (default fullspeed) +# +# Note: usb-device doesn't truly support high speed enumeration yet, so setting this will make +# TestClass only compliant with high speed mode. It may still manage to be enumerated as a full +# speed device, but the descriptors will be invalid. +test-class-high-speed = [] diff --git a/usb-device/LICENSE b/usb-device/LICENSE new file mode 100644 index 0000000..57a6424 --- /dev/null +++ b/usb-device/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Matti Virkkunen and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/src/bus.rs b/usb-device/src/bus.rs similarity index 100% rename from src/bus.rs rename to usb-device/src/bus.rs diff --git a/src/class.rs b/usb-device/src/class.rs similarity index 100% rename from src/class.rs rename to usb-device/src/class.rs diff --git a/src/control.rs b/usb-device/src/control.rs similarity index 100% rename from src/control.rs rename to usb-device/src/control.rs diff --git a/src/control_pipe.rs b/usb-device/src/control_pipe.rs similarity index 100% rename from src/control_pipe.rs rename to usb-device/src/control_pipe.rs diff --git a/src/descriptor.rs b/usb-device/src/descriptor.rs similarity index 100% rename from src/descriptor.rs rename to usb-device/src/descriptor.rs diff --git a/src/device.rs b/usb-device/src/device.rs similarity index 100% rename from src/device.rs rename to usb-device/src/device.rs diff --git a/src/device_builder.rs b/usb-device/src/device_builder.rs similarity index 100% rename from src/device_builder.rs rename to usb-device/src/device_builder.rs diff --git a/src/endpoint.rs b/usb-device/src/endpoint.rs similarity index 100% rename from src/endpoint.rs rename to usb-device/src/endpoint.rs diff --git a/src/lib.rs b/usb-device/src/lib.rs similarity index 100% rename from src/lib.rs rename to usb-device/src/lib.rs diff --git a/src/test_class.rs b/usb-device/src/test_class.rs similarity index 100% rename from src/test_class.rs rename to usb-device/src/test_class.rs