Skip to content
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

Update to embedded-hal 1.0 #1723

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions src/bare-metal/microcontrollers/embedded-hal.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
# `embedded-hal`

The [`embedded-hal`](https://crates.io/crates/embedded-hal) crate provides a
number of traits covering common microcontroller peripherals.
The [`embedded-hal`] crate provides a number of traits covering common
microcontroller peripherals:

- GPIO
- ADC
- I2C, SPI, UART, CAN
- RNG
- Timers
- Watchdogs
- PWM
- Delay timers
- I2C and SPI buses and devices

Other crates then implement
[drivers](https://github.com/rust-embedded/awesome-embedded-rust#driver-crates)
in terms of these traits, e.g. an accelerometer driver might need an I2C or SPI
bus implementation.
Similar traits for byte streams (e.g. UARTs), CAN buses and RNGs and broken out
into [`embedded-io`], [`embedded-can`] and [`rand_core`] respectively.

Other crates then implement [drivers] in terms of these traits, e.g. an
accelerometer driver might need an I2C or SPI device instance.

<details>

- The traits cover using the peripherals but not initialising or configuring
them, as initialisation and configuration is usually highly platform-specific.
- There are implementations for many microcontrollers, as well as other
platforms such as Linux on Raspberry Pi.
- There is work in progress on an `async` version of `embedded-hal`, but it
isn't stable yet.
- [`embedded-hal-async`] provides async versions of the traits.
- [`embedded-hal-nb`] provides another approach to non-blocking I/O, based on
the [`nb`] crate.

</details>

[drivers]: https://github.com/rust-embedded/awesome-embedded-rust#driver-crates
[`embedded-can`]: https://crates.io/crates/embedded-can
[`embedded-hal`]: https://crates.io/crates/embedded-hal
[`embedded-hal-async`]: https://crates.io/crates/embedded-hal-async
[`embedded-hal-nb`]: https://crates.io/crates/embedded-hal-nb
[`embedded-io`]: https://crates.io/crates/embedded-io
[`nb`]: https://crates.io/crates/nb
[`rand_core`]: https://crates.io/crates/rand_core
126 changes: 20 additions & 106 deletions src/bare-metal/microcontrollers/examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/bare-metal/microcontrollers/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
publish = false

[dependencies]
cortex-m-rt = "0.7.3"
cortex-m-rt = "0.7.4"
embedded-hal = "1.0.0"
microbit-v2 = "0.13.0"
nrf52833-hal = "0.17.0"
microbit-v2 = "0.14.0"
nrf52833-hal = "0.17.1"
nrf52833-pac = { version = "0.12.2", features = ["rt"] }
panic-halt = "0.2.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
extern crate panic_halt as _;

use cortex_m_rt::entry;
use microbit::hal::prelude::*;
use embedded_hal::digital::OutputPin;
use microbit::Board;

#[entry]
Expand Down
Loading
Loading