-
Notifications
You must be signed in to change notification settings - Fork 9
Initialize repo as a workspace #1
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
Merged
jerrysxie
merged 2 commits into
OpenDevicePartnership:main
from
jerrysxie:initialize-the-repo
May 23, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,12 @@ | ||
| [package] | ||
| name = "embedded-rust-template" | ||
| [workspace] | ||
| resolver = "2" | ||
| members = ["mcu-traits"] | ||
|
|
||
| [workspace.package] | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| license = "MIT" | ||
| repository = "https://github.com/OpenDevicePartnership/embedded-rust-template" | ||
| rust-version = "1.85" | ||
|
|
||
| [dependencies] | ||
| # dependencies for all targets | ||
|
|
||
| [target.'cfg(target_os = "none")'.dependencies] | ||
| # dependencies for no-std targets | ||
| repository = "https://github.com/OpenDevicePartnership/embedded-mcu" | ||
|
|
||
| [lints.clippy] | ||
| suspicious = "forbid" | ||
| correctness = "forbid" | ||
| perf = "forbid" | ||
| style = "forbid" | ||
| [workspace.dependencies] | ||
| embedded-services = { git = "https://github.com/OpenDevicePartnership/embedded-services" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,63 +1,5 @@ | ||
| # embedded-rust-template | ||
| Template repository for Embedded Rust development | ||
| # embedded-mcu | ||
|
|
||
| ## Customizing This Template | ||
| This houses a colletion of MCU agnostic traits + libraries to manipulate hardware peripherals. It is similar to embedded-hal except mapping to high level of abstraction like USB C PD and HID. Some of the traits housed here will be upstreamed to embedded-hal if the community aligns to the same vision. | ||
|
|
||
| ### Changing the Target Architecture | ||
|
|
||
| This template is configured for `thumbv8m.main-none-eabihf`, by default, but you can modify it for other targets (i.e. `aarch64-unknown-none`): | ||
|
|
||
| 1. **VSCode Settings**: Update the target in `.vscode/settings.json`: | ||
| ```json | ||
| "rust-analyzer.cargo.target": "your-target-architecture" | ||
| ``` | ||
|
|
||
|
|
||
| This configuration ensures that: | ||
| - Only the specified target architecture is analyzed, not the host platform | ||
| - Code is checked against the no_std environment | ||
|
|
||
| To temporarily analyze code for the host platform instead, you can remove the `rust-analyzer.cargo.target` setting. | ||
|
|
||
| 2. **GitHub Workflows**: Modify the target in two workflow files: | ||
| - `.github/workflows/nostd.yml`: Update the targets in the matrix: | ||
| ```yaml | ||
| matrix: | ||
| target: [your-target-architecture] | ||
| ``` | ||
| - `.github/workflows/check.yml`: If there are any target-specific checks, update them accordingly. | ||
|
|
||
| 3. **Cargo Configuration**: If needed, you can add target-specific configuration in a `.cargo/config.toml` file. | ||
|
|
||
| ### Converting from Binary to Library | ||
|
|
||
| To convert this project from a binary to a library: | ||
|
|
||
| 1. **Cargo.toml**: Update your project structure: | ||
| ```toml | ||
| [lib] | ||
| name = "your_library_name" | ||
| ``` | ||
|
|
||
| 2. **Directory Structure**: | ||
| - For a library, ensure you have a `src/lib.rs` file instead of `src/main.rs` | ||
| - Move your code from `main.rs` to `lib.rs` and adjust as needed | ||
|
|
||
| 3. **No-std Configuration**: If you're creating a no-std library, ensure you have: | ||
| ```rust | ||
| // In lib.rs | ||
| #![cfg_attr(target_os = "none", no_std)] | ||
| // Add other attributes as needed | ||
| ``` | ||
|
|
||
| ### Project Dependencies | ||
|
|
||
| Update the dependencies in `Cargo.toml` based on your target platform: | ||
|
|
||
| ```toml | ||
| [dependencies] | ||
| # Common dependencies for all targets | ||
|
|
||
| [target.'cfg(target_os = "none")'.dependencies] | ||
| # Dependencies for no-std targets | ||
| ``` | ||
| This repo is not intended to link to any MCU specific code. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [package] | ||
| name = "mcu-traits" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| repository.workspace = true | ||
|
|
||
| [dependencies] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #![no_std] | ||
|
|
||
| pub fn add(left: u64, right: u64) -> u64 { | ||
| left + right | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.