Skip to content

Commit

Permalink
Upgrade to as5600 with async feature, thanks @barafael. Unfortunately…
Browse files Browse the repository at this point in the history
… it still panics on the .angle() method, although I suspect that it's not the crate's fault but probably AVR not supporting the returned u16 perhaps?: https://internals.rust-lang.org/t/adding-16-bit-pointer-support/2484... the post is about pointers not (stack or heap) values, so need to investigate further. Also adding a simavr wrapper: https://github.com/Patryk27/avr-tester
  • Loading branch information
brainstorm committed Apr 7, 2024
1 parent bba2549 commit f21edb9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ resolver = "2"
panic-halt = "0.2"
embassy-executor = { git = "https://github.com/embassy-rs/embassy", features = ["arch-avr", "executor-thread", "nightly"] }
avr-device = { version = "0.5", features = ["atmega2560", "rt", "critical-section-impl"] }
#avr-tester = "0.2"
arduino-hal = { git = "https://github.com/Rahix/avr-hal", features = ["arduino-mega2560"] }
as5600 = "0.6"
as5600 = { version = "0.8", features = ["async"] }
ufmt = "0.2"

[profile.dev]
panic = "abort"
#lto = true
lto = true
opt-level = "s" # mandatory, otherwise we'll get: "error: ran out of registers during register allocation"

[profile.release]
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ Flash the Arduino Mega 2560 board with:
```sh
cargo run -- -P /dev/ttyUSB0
```

# Prerequisites

```
$ apt-get install avrdude clang pkg-config gcc-avr gdb-avr libelf-dev
$ cargo install ravedude
```
26 changes: 26 additions & 0 deletions tests/angle_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// use avr_tester::*;

// fn avr() -> AvrTester {
// AvrTester::atmega328p()
// .with_clock_of_16_mhz()
// .load("target/atmega2560/debug/yourproject.elf")
// }

// // Assuming `yourproject` implements a ROT-13 encoder:

// #[test]
// fn short_text() {
// let mut avr = avr();

// // Let's give our firmware a moment to initialize:
// avr.run_for_ms(1);

// // Now, let's send the string:
// avr.uart0().write("Hello, World!");

// // ... give the AVR a moment to retrieve it & send back, encoded:
// avr.run_for_ms(1);

// // ... and, finally, let's assert the outcome:
// assert_eq!("Uryyb, Jbeyq!", avr.uart0().read::<String>());
// }

0 comments on commit f21edb9

Please sign in to comment.