ryan-summers / shared-bus-rtic

Provides macros and type definitions for using shared-bus in an RTIC application
MIT License
16 stars 3 forks source link

Support for platforms without atomics? #3

Closed BlinkyStitt closed 4 years ago

BlinkyStitt commented 4 years ago

I originally opened this on the wrong repo: https://github.com/Rahix/shared-bus/issues/10.

$ cargo check --target thumbv6m-none-eabi
    Checking shared-bus-rtic v0.2.1 (https://github.com/ryan-summers/shared-bus-rtic?branch=feature/spi-full-duplex#fad95b37)
error[E0599]: no method named `compare_exchange` found for struct `core::sync::atomic::AtomicBool` in the current scope
  --> /Users/bwstitt/.cargo/git/checkouts/shared-bus-rtic-b510fcc9e8973e1f/fad95b3/src/lib.rs:73:14
   |
73 |             .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
   |              ^^^^^^^^^^^^^^^^ method not found in `core::sync::atomic::AtomicBool`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `shared-bus-rtic`.

To learn more, run the command again with --verbose.

I'm not sure there's any way to "fix" this. I think it might just be better to say that thumbv6m-none-eabi and other platforms without atomics are not supported.

I'm going to use a platform with thumbv7em-none-eabihf instead of the feather_m0 that I was planning on using since atomics are going to be helpful for a few things.

ryan-summers commented 4 years ago

This is a core component of rust, so I'm somewhat surprised this isn't working. It's not that AtomicBool isn't available, but rather that the method compare_exchange isn't found for it. Can you please provide the output of rustc --version to show which version of Rust you're running?

ryan-summers commented 4 years ago

It looks like Thumbv6 indeed has some issues with atomics. I've added an atomic shim for the crate in #4.

ryan-summers commented 4 years ago

@WyseNynja I've cut a new release with support for all Spi traits as well as support for thumbv6 targets (which don't have the mentioned atomic). To enable support, change your Cargo.toml as follows:

[dependencies.shared-bus-rtic]
version = "0.2.2"
features = ["thumbv6"]
BlinkyStitt commented 4 years ago

Thank you!