Skip to content

Commit

Permalink
Merge #379
Browse files Browse the repository at this point in the history
379: Update dependencies r=jonas-schievink a=jonas-schievink

Updates the PACs to 0.11.0, `embedded-dma` and `embedded-storage` dependencies of `nrf-hal-common`, and all example dependencies (notably including RTIC 1.0).

I've removed RTIC from `wdt-demo` since it isn't needed there.

Co-authored-by: Jonas Schievink <[email protected]>
  • Loading branch information
bors[bot] and Jonas Schievink authored Feb 8, 2022
2 parents edce43c + b91791a commit a183676
Show file tree
Hide file tree
Showing 49 changed files with 745 additions and 771 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

- Unified how pins are are returned in `free` calls ([#372]).
- Improvements to the NVMC driver ([#374]).
- Updated `embedded-dma`, `embedded-storage`, and PACs ([#379]).

[#372]: https://github.com/nrf-rs/nrf-hal/pull/372
[#373]: https://github.com/nrf-rs/nrf-hal/pull/373
[#374]: https://github.com/nrf-rs/nrf-hal/pull/374
[#376]: https://github.com/nrf-rs/nrf-hal/pull/376
[#379]: https://github.com/nrf-rs/nrf-hal/pull/379

## [0.14.1]

Expand Down
2 changes: 1 addition & 1 deletion examples/blinky-button-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
rtt-target = {version = "0.2.0", features = ["cortex-m"] }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52832-hal = { features = ["rt"], path = "../../nrf52832-hal" }

[dependencies.embedded-hal]
Expand Down
2 changes: 1 addition & 1 deletion examples/ccm-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
rtt-target = {version = "0.2.0", features = ["cortex-m"] }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
rand_core = "0.6.3"

nrf52810-hal = { path = "../../nrf52810-hal", features = ["rt"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion examples/comp-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "0.5.9", features = ["cortex-m-7"], default-features = false }
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" }

Expand Down
54 changes: 25 additions & 29 deletions examples/comp-demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
#![no_std]
#![no_main]

use embedded_hal::digital::v2::OutputPin;
use {
core::{
panic::PanicInfo,
sync::atomic::{compiler_fence, Ordering},
},
hal::{
comp::*,
gpio::{Level, Output, Pin, PushPull},
},
nrf52840_hal as hal,
rtt_target::{rprintln, rtt_init_print},
};
use {core::panic::PanicInfo, rtt_target::rprintln};

#[rtic::app(device = crate::hal::pac, peripherals = true)]
const APP: () = {
struct Resources {
#[rtic::app(device = nrf52840_hal::pac, peripherals = true)]
mod app {
use embedded_hal::digital::v2::OutputPin;
use nrf52840_hal::clocks::Clocks;
use nrf52840_hal::comp::*;
use nrf52840_hal::gpio::{self, Level, Output, Pin, PushPull};
use rtt_target::{rprintln, rtt_init_print};

#[shared]
struct Shared {}

#[local]
struct Local {
comp: Comp,
led1: Pin<Output<PushPull>>,
}

#[init]
fn init(ctx: init::Context) -> init::LateResources {
let _clocks = hal::clocks::Clocks::new(ctx.device.CLOCK).enable_ext_hfosc();
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
let _clocks = Clocks::new(ctx.device.CLOCK).enable_ext_hfosc();
rtt_init_print!();

let p0 = hal::gpio::p0::Parts::new(ctx.device.P0);
let p0 = gpio::p0::Parts::new(ctx.device.P0);
let led1 = p0.p0_13.into_push_pull_output(Level::High).degrade();
let in_pin = p0.p0_30.into_floating_input();
let ref_pin = p0.p0_31.into_floating_input();
Expand All @@ -38,31 +36,29 @@ const APP: () = {
.enable_interrupt(Transition::Cross)
.enable();

init::LateResources { comp, led1 }
(Shared {}, Local { comp, led1 }, init::Monotonics())
}

#[task(binds = COMP_LPCOMP, resources = [comp, led1])]
#[task(binds = COMP_LPCOMP, local = [comp, led1])]
fn on_comp(ctx: on_comp::Context) {
ctx.resources.comp.reset_event(Transition::Cross);
match ctx.resources.comp.read() {
ctx.local.comp.reset_event(Transition::Cross);
match ctx.local.comp.read() {
CompResult::Above => {
rprintln!("Vin > Vref");
ctx.resources.led1.set_low().ok();
ctx.local.led1.set_low().ok();
}
CompResult::Below => {
rprintln!("Vin < Vref");
ctx.resources.led1.set_high().ok();
ctx.local.led1.set_high().ok();
}
}
}
};
}

#[inline(never)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
cortex_m::interrupt::disable();
rprintln!("{}", info);
loop {
compiler_fence(Ordering::SeqCst);
}
loop {}
}
3 changes: 2 additions & 1 deletion examples/gpiote-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ edition = "2018"
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "0.5.9", features = ["cortex-m-7"], default-features = false }
cortex-m-rtic = { version = "1.0.0", default-features = false }
systick-monotonic = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }

Expand Down
148 changes: 71 additions & 77 deletions examples/gpiote-demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
#![no_std]
#![no_main]

use embedded_hal::digital::v2::InputPin;
use {
core::{
panic::PanicInfo,
sync::atomic::{compiler_fence, Ordering},
},
hal::{
gpio::{Input, Level, Pin, PullUp},
gpiote::*,
ppi::{self, ConfigurablePpi, Ppi},
},
nrf52840_hal as hal,
rtic::cyccnt::U32Ext,
rtt_target::{rprintln, rtt_init_print},
};

#[rtic::app(device = crate::hal::pac, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
const APP: () = {
struct Resources {
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 systick_monotonic::*;
use {
hal::{
gpio::{Input, Level, Pin, PullUp},
gpiote::*,
ppi::{self, ConfigurablePpi, Ppi},
},
nrf52840_hal as hal,
rtt_target::{rprintln, rtt_init_print},
};

#[monotonic(binds = SysTick, default = true)]
type Timer = Systick<1_000_000>;

#[shared]
struct Shared {
gpiote: Gpiote,
}

#[local]
struct Local {
btn1: Pin<Input<PullUp>>,
btn3: Pin<Input<PullUp>>,
btn4: Pin<Input<PullUp>>,
}

#[init]
fn init(mut ctx: init::Context) -> init::LateResources {
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
let _clocks = hal::clocks::Clocks::new(ctx.device.CLOCK).enable_ext_hfosc();
rtt_init_print!();
let p0 = hal::gpio::p0::Parts::new(ctx.device.P0);
Expand Down Expand Up @@ -65,75 +71,63 @@ const APP: () = {
ppi0.set_event_endpoint(gpiote.channel2().event());
ppi0.enable();

// Enable the monotonic timer (CYCCNT)
ctx.core.DCB.enable_trace();
ctx.core.DWT.enable_cycle_counter();
let mono = Systick::new(ctx.core.SYST, 64_000_000);

rprintln!("Press a button");

init::LateResources {
gpiote,
btn1,
btn3,
btn4,
}
}

#[idle]
fn idle(_: idle::Context) -> ! {
loop {
cortex_m::asm::wfi();
}
(
Shared { gpiote },
Local { btn1, btn3, btn4 },
init::Monotonics(mono),
)
}

#[task(binds = GPIOTE, resources = [gpiote], schedule = [debounce])]
fn on_gpiote(ctx: on_gpiote::Context) {
if ctx.resources.gpiote.channel0().is_event_triggered() {
rprintln!("Interrupt from channel 0 event");
}
if ctx.resources.gpiote.port().is_event_triggered() {
rprintln!("Interrupt from port event");
}
// Reset all events
ctx.resources.gpiote.reset_events();
// Debounce
ctx.schedule.debounce(ctx.start + 3_000_000.cycles()).ok();
#[task(binds = GPIOTE, shared = [gpiote])]
fn on_gpiote(mut ctx: on_gpiote::Context) {
ctx.shared.gpiote.lock(|gpiote| {
if gpiote.channel0().is_event_triggered() {
rprintln!("Interrupt from channel 0 event");
}
if gpiote.port().is_event_triggered() {
rprintln!("Interrupt from port event");
}
// Reset all events
gpiote.reset_events();
// Debounce
debounce::spawn_after(50.millis()).ok();
});
}

#[task(resources = [gpiote, btn1, btn3, btn4])]
fn debounce(ctx: debounce::Context) {
let btn1_pressed = ctx.resources.btn1.is_low().unwrap();
let btn3_pressed = ctx.resources.btn3.is_low().unwrap();
let btn4_pressed = ctx.resources.btn4.is_low().unwrap();

if btn1_pressed {
rprintln!("Button 1 was pressed!");
// Manually run "task out" operation (toggle) on channel 1 (toggles led1)
ctx.resources.gpiote.channel1().out();
}
if btn3_pressed {
rprintln!("Button 3 was pressed!");
// Manually run "task clear" on channel 1 (led1 on)
ctx.resources.gpiote.channel1().clear();
}
if btn4_pressed {
rprintln!("Button 4 was pressed!");
// Manually run "task set" on channel 1 (led1 off)
ctx.resources.gpiote.channel1().set();
}
#[task(shared = [gpiote], local = [btn1, btn3, btn4])]
fn debounce(mut ctx: debounce::Context) {
let btn1_pressed = ctx.local.btn1.is_low().unwrap();
let btn3_pressed = ctx.local.btn3.is_low().unwrap();
let btn4_pressed = ctx.local.btn4.is_low().unwrap();

ctx.shared.gpiote.lock(|gpiote| {
if btn1_pressed {
rprintln!("Button 1 was pressed!");
// Manually run "task out" operation (toggle) on channel 1 (toggles led1)
gpiote.channel1().out();
}
if btn3_pressed {
rprintln!("Button 3 was pressed!");
// Manually run "task clear" on channel 1 (led1 on)
gpiote.channel1().clear();
}
if btn4_pressed {
rprintln!("Button 4 was pressed!");
// Manually run "task set" on channel 1 (led1 off)
gpiote.channel1().set();
}
});
}

extern "C" {
fn SWI0_EGU0();
}
};
}

#[inline(never)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
cortex_m::interrupt::disable();
rprintln!("{}", info);
loop {
compiler_fence(Ordering::SeqCst);
}
loop {}
}
5 changes: 3 additions & 2 deletions examples/i2s-controller-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ publish = false
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = { version = "0.7.0", features = ["device"] }
cortex-m-rtic = { version = "0.5.9", features = ["cortex-m-7"], default-features = false }
cortex-m-rtic = { version = "1.0.0", default-features = false }
systick-monotonic = "1.0.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
nrf52840-hal = { features = ["rt"], path = "../../nrf52840-hal" }
heapless = "0.5.5"
heapless = "0.7.10"
small_morse = "0.1.0"

[dependencies.embedded-hal]
Expand Down
Loading

0 comments on commit a183676

Please sign in to comment.