From eb5f8488b4cdfa96aa1d889adb4421e6d37ae4db Mon Sep 17 00:00:00 2001 From: brainstorm Date: Sun, 24 Mar 2024 20:09:54 +1100 Subject: [PATCH] Initial commit, fails with the following though: $ cargo build Downloaded as5600 v0.6.0 Downloaded 1 crate (14.1 KB) in 0.85s Compiling autocfg v1.1.0 Compiling num-derive v0.4.2 Compiling nb v0.1.3 Compiling embedded-hal v0.2.7 Compiling num-traits v0.2.18 Compiling as5600 v0.6.0 Compiling embassy-avr-as5600-encoder v0.1.0 (/home/rvalls/dev/personal/embassy-avr-as5600-encoder) error[E0658]: `impl Trait` in associated types is unstable --> src/main.rs:8:1 | 8 | #[embassy_executor::main] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #63063 for more information = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable = note: this compiler was built on 2024-03-23; consider upgrading it if it is out of date = note: this error originates in the attribute macro `::embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0658`. error: could not compile `embassy-avr-as5600-encoder` (bin "embassy-avr-as5600-encoder") due to 1 previous error --- .cargo/config.toml | 4 ++++ .gitignore | 2 ++ Cargo.toml | 23 +++++++++++++++++++++++ avr-specs/avr-atmega328p.json | 25 +++++++++++++++++++++++++ rust-toolchain.toml | 4 ++++ src/main.rs | 11 +++++++++++ 6 files changed, 69 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 avr-specs/avr-atmega328p.json create mode 100644 rust-toolchain.toml create mode 100644 src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..cac83ac --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ +[build] +target = "avr-specs/avr-atmega328p.json" +[unstable] +build-std = ["core"] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9d37c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..db5bba8 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +edition = "2021" +name = "embassy-avr-as5600-encoder" +version = "0.1.0" +authors = ["brainstorm "] +resolver = "2" + +[dependencies] +panic-halt = "0.2" +embassy-executor = { git = "https://github.com/embassy-rs/embassy", features = ["arch-avr", "nightly", "executor-thread"] } +avr-device = { version = "0.5", features = ["atmega328p", "rt"] } +as5600 = "0.6.0" + +[profile.dev] +panic = "abort" +lto = true +opt-level = "s" + +[profile.release] +panic = "abort" +codegen-units = 1 +lto = true +opt-level = "s" diff --git a/avr-specs/avr-atmega328p.json b/avr-specs/avr-atmega328p.json new file mode 100644 index 0000000..7d7d82c --- /dev/null +++ b/avr-specs/avr-atmega328p.json @@ -0,0 +1,25 @@ +{ + "arch": "avr", + "atomic-cas": false, + "cpu": "atmega328p", + "data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8", + "eh-frame-header": false, + "exe-suffix": ".elf", + "late-link-args": { + "gcc": [ + "-lgcc" + ] + }, + "linker": "avr-gcc", + "llvm-target": "avr-unknown-unknown", + "max-atomic-width": 8, + "no-default-libraries": false, + "pre-link-args": { + "gcc": [ + "-mmcu=atmega328p" + ] + }, + "relocation-model": "static", + "target-c-int-width": "16", + "target-pointer-width": "16" +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..cd4305f --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly" +components = ["rust-src"] +profile = "minimal" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6fc30c1 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,11 @@ +#![no_std] +#![no_main] + +use panic_halt as _; + +use embassy_executor::Spawner; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + loop {} +}