Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 1 addition & 4 deletions examples/blinky-button-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ edition = "2018"
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
embedded-hal = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52832-hal = { features = ["rt"], path = "../../nrf52832-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
6 changes: 3 additions & 3 deletions examples/blinky-button-demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_main]
#![no_std]

use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::digital::InputPin;
use embedded_hal::digital::OutputPin;
use nrf52832_hal as hal;
use nrf52832_hal::gpio::Level;
use rtt_target::{rprintln, rtt_init_print};
Expand All @@ -19,7 +19,7 @@ fn main() -> ! {
rtt_init_print!();
let p = hal::pac::Peripherals::take().unwrap();
let port0 = hal::gpio::p0::Parts::new(p.P0);
let button = port0.p0_13.into_pullup_input();
let mut button = port0.p0_13.into_pullup_input();
let mut led = port0.p0_17.into_push_pull_output(Level::Low);

rprintln!("Blinky button demo starting");
Expand Down
5 changes: 1 addition & 4 deletions examples/comp-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ publish = false
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
embedded-hal = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
2 changes: 1 addition & 1 deletion examples/comp-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {core::panic::PanicInfo, rtt_target::rprintln};

#[rtic::app(device = nrf52840_hal::pac, peripherals = true)]
mod app {
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::digital::OutputPin;
use nrf52840_hal::clocks::Clocks;
use nrf52840_hal::comp::*;
use nrf52840_hal::gpio::{self, Level, Output, Pin, PushPull};
Expand Down
5 changes: 1 addition & 4 deletions examples/gpiote-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ edition = "2018"
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
embedded-hal = "1.0.0"
systick-monotonic = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
2 changes: 1 addition & 1 deletion examples/gpiote-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {core::panic::PanicInfo, nrf52840_hal as hal, rtt_target::rprintln};

#[rtic::app(device = crate::hal::pac, peripherals = true, dispatchers = [SWI0_EGU0])]
mod app {
use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::InputPin;
use systick_monotonic::*;
use {
hal::{
Expand Down
4 changes: 0 additions & 4 deletions examples/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ publish = false
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]

[dependencies.nrf9160-hal]
features = ["rt"]
path = "../../nrf9160-hal"
Expand Down
5 changes: 1 addition & 4 deletions examples/i2s-controller-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ publish = false
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
embedded-hal = "1.0.0"
systick-monotonic = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }
heapless = "0.7.10"
small_morse = "0.1.0"

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
2 changes: 1 addition & 1 deletion examples/i2s-controller-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Aligned<T: ?Sized>(T);
#[rtic::app(device = crate::hal::pac, peripherals = true, dispatchers = [SWI0_EGU0, SWI1_EGU1])]
mod app {
use crate::{hal, triangle_wave, Aligned};
use embedded_hal::digital::v2::{InputPin, OutputPin};
use embedded_hal::digital::{InputPin, OutputPin};
use heapless::spsc::{Consumer, Producer, Queue};
use small_morse::{encode, State};
use systick_monotonic::*;
Expand Down
5 changes: 1 addition & 4 deletions examples/i2s-peripheral-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ publish = false
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
embedded-hal = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
4 changes: 2 additions & 2 deletions examples/i2s-peripheral-demo/src/main.rs
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment on the change here?

The change from:

use embedded_hal::blocking::spi::Write;

to:

use embedded_hal::spi::SpiBus;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SPI traits changed significantly in embedded-hal 1.0. You can read more about it in the embedded-hal documentation, but one difference is that there is now a single trait for a bus or a device, rather than separate traits for read vs. write vs. transfer.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod app {
spim::{self, Frequency, Mode as SPIMode, Phase, Polarity, Spim},
};
use crate::Aligned;
use embedded_hal::blocking::spi::Write;
use embedded_hal::spi::SpiBus;
use rtt_target::{rprintln, rtt_init_print};

const OFF: [u8; 9] = [0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF];
Expand Down Expand Up @@ -105,7 +105,7 @@ mod app {
10_338..=16_383 => &ORANGE,
_ => &RED,
};
<Spim<SPIM0> as Write<u8>>::write(ctx.local.rgb, color).ok();
<Spim<SPIM0> as SpiBus<u8>>::write(ctx.local.rgb, color).ok();
}
*ctx.local.transfer = i2s.rx(rx_buf).ok();
}
Expand Down
5 changes: 1 addition & 4 deletions examples/lpcomp-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ edition = "2018"
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
embedded-hal = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
2 changes: 1 addition & 1 deletion examples/lpcomp-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {core::panic::PanicInfo, nrf52840_hal as hal, rtt_target::rprintln};

#[rtic::app(device = crate::hal::pac, peripherals = true)]
mod app {
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::digital::OutputPin;
use {
hal::{
gpio::{Level, Output, Pin, PushPull},
Expand Down
4 changes: 0 additions & 4 deletions examples/nvmc-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ embedded-storage = "0.3.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
panic-probe = { version = "0.3.0", features = ["print-rtt"] }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]

[dependencies.nrf52840-hal]
features = ["rt"]
path = "../../nrf52840-hal"
Expand Down
6 changes: 0 additions & 6 deletions examples/pwm-blinky-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ version = "0.1.0"
authors = ["Christopher Hunt <huntchr@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nb = "1.0.0"

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]

[dependencies.nrf9160-hal]
features = ["rt"]
path = "../../nrf9160-hal"
Expand Down
28 changes: 12 additions & 16 deletions examples/pwm-blinky-demo/src/main.rs
Copy link
Copy Markdown

@adamhott adamhott Mar 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please comment on the change of the use of timer and PWM?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about it? embedded-hal 1.0 no longer includes traits for timers, so we have intrinsic methods instead. The names of some of the PWM methods have changed.

Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#![no_main]
#![no_std]

use hal::{gpio, prelude::*, pwm, pwm::Pwm, timer, timer::Timer};
use nb::block;
use hal::{
gpio,
prelude::*,
pwm::{Channel, Pwm},
timer::Timer,
};
#[cfg(feature = "52832")]
use nrf52832_hal as hal;
#[cfg(feature = "52840")]
Expand Down Expand Up @@ -30,11 +34,11 @@ fn main() -> ! {

rprintln!("PWM Blinky demo starting");

let wait_time = 1_000_000u32 / pwm.get_max_duty() as u32;
let wait_time = 1_000_000u32 / pwm.max_duty() as u32;
loop {
for duty in 0..pwm.get_max_duty() {
for duty in 0..pwm.max_duty() {
pwm.set_duty_on_common(duty);
delay(&mut timer, wait_time);
timer.delay(wait_time);
}
}
}
Expand All @@ -45,7 +49,7 @@ fn init_device(p: hal::pac::Peripherals) -> (Pwm<hal::pac::PWM0_NS>, Timer<hal::

let pwm = Pwm::new(p.PWM0_NS);
pwm.set_output_pin(
pwm::Channel::C0,
Channel::C0,
p0.p0_02.into_push_pull_output(gpio::Level::High).degrade(),
);

Expand All @@ -60,7 +64,7 @@ fn init_device(p: hal::pac::Peripherals) -> (Pwm<hal::pac::PWM0>, Timer<hal::pac

let pwm = Pwm::new(p.PWM0);
pwm.set_output_pin(
pwm::Channel::C0,
Channel::C0,
p0.p0_13.into_push_pull_output(gpio::Level::High).degrade(),
);

Expand All @@ -75,19 +79,11 @@ fn init_device(p: hal::pac::Peripherals) -> (Pwm<hal::pac::PWM0>, Timer<hal::pac

let pwm = Pwm::new(p.PWM0);
pwm.set_output_pin(
pwm::Channel::C0,
Channel::C0,
p0.p0_30.into_push_pull_output(gpio::Level::High).degrade(),
);

let timer = Timer::new(p.TIMER0);

(pwm, timer)
}

fn delay<T>(timer: &mut Timer<T>, cycles: u32)
where
T: timer::Instance,
{
timer.start(cycles);
let _ = block!(timer.wait());
}
5 changes: 1 addition & 4 deletions examples/pwm-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ edition = "2018"
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
embedded-hal = "1.0"
systick-monotonic = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]

[dependencies.nrf52840-hal]
features = ["rt"]
path = "../../nrf52840-hal"
2 changes: 1 addition & 1 deletion examples/pwm-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {core::panic::PanicInfo, nrf52840_hal as hal, rtt_target::rprintln};

#[rtic::app(device = crate::hal::pac, peripherals = true, dispatchers = [SWI0_EGU0])]
mod app {
use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::InputPin;
use {
hal::{
gpio::{p0::Parts, Input, Level, Pin, PullUp},
Expand Down
6 changes: 0 additions & 6 deletions examples/qdec-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ version = "0.1.0"
authors = ["Henrik Alsér"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
4 changes: 0 additions & 4 deletions examples/rtc-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
6 changes: 1 addition & 5 deletions examples/spi-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ publish = false

[dependencies]
cortex-m-rt = "0.7.0"
embedded-hal = "1.0.0"
panic-halt = "0.2.0"
embedded-hal-spy = "0.0.5"

[dependencies.embedded-hal]
features = ["unproven"]
version = "0.2"

[dependencies.nrf52832-hal]
path = "../../nrf52832-hal"
Expand Down
13 changes: 4 additions & 9 deletions examples/spi-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

extern crate cortex_m_rt as rt; // v0.5.x

extern crate embedded_hal_spy;
extern crate nrf52832_hal;
extern crate panic_halt;
use embedded_hal::blocking::spi::*;

use cortex_m_rt::entry;
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::digital::OutputPin;
use embedded_hal::spi::SpiBus;
use nrf52832_hal::gpio;
use nrf52832_hal::gpio::p0::*;
use nrf52832_hal::gpio::Level;
Expand Down Expand Up @@ -90,10 +88,7 @@ fn main() -> ! {
}
}

// Wrap interface in embedded-hal-spy to access embedded_hal traits
let mut eh_spi = embedded_hal_spy::new(spi, |_| {});
use embedded_hal::blocking::spi::Write;
match eh_spi.write(reference_data) {
match SpiBus::write(&mut spi, reference_data) {
Ok(_) => {}
Err(_) => {
tests_ok = false;
Expand All @@ -102,7 +97,7 @@ fn main() -> ! {
}

let mut test_vec2 = *reference_data;
match eh_spi.transfer(&mut test_vec2) {
match SpiBus::transfer_in_place(&mut spi, &mut test_vec2) {
Ok(_) => {
for i in 0..test_vec2.len() {
if test_vec2[i] != reference_data[i] {
Expand Down
4 changes: 0 additions & 4 deletions examples/spis-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
4 changes: 0 additions & 4 deletions examples/twi-ssd1306/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ ssd1306 = "0.2.6"
embedded-graphics = "0.4.7"
panic-semihosting = "0.5.3"

[dependencies.embedded-hal]
features = ["unproven"]
version = "0.2"

[dependencies.nrf52832-hal]
path = "../../nrf52832-hal"
optional = true
Expand Down
5 changes: 1 addition & 4 deletions examples/twim-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ edition = "2018"
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "1.0.0", default-features = false }
embedded-hal = "1.0.0"
systick-monotonic = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

[dependencies.embedded-hal]
version = "0.2.3"
features = ["unproven"]
2 changes: 1 addition & 1 deletion examples/twim-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {core::panic::PanicInfo, nrf52840_hal as hal, rtt_target::rprintln};

#[rtic::app(device = crate::hal::pac, peripherals = true, dispatchers = [SWI0_EGU0])]
mod app {
use embedded_hal::digital::v2::InputPin;
use embedded_hal::digital::InputPin;
use systick_monotonic::*;
use {
hal::{
Expand Down
Loading