diff --git a/README.md b/README.md index 5b03176..61afcfd 100644 --- a/README.md +++ b/README.md @@ -73,15 +73,15 @@ Flashing the softdevice is required. It is NOT part of the built binary. You onl - As a debug client, if you are using - probe-rs: - Erase the flash with `probe-rs erase --chip nrf52840_xxAA` (You may have to supply additional `--allow-erase-all` argument). - - Flash the SoftDevice with `probe-rs download --verify --format hex --chip nRF52840_xxAA s140_nrf52_7.X.X_softdevice.hex` + - Flash the SoftDevice with `probe-rs download --verify --binary-format hex --chip nRF52840_xxAA s140_nrf52_7.X.X_softdevice.hex` - nrfjprog: - Flash the SoftDevice with `nrfjprog --family NRF52 --chiperase --verify --program s140_nrf52_7.0.1_softdevice.hex` To run an example, simply use `cargo run` from the `examples` folder: -- `cd examples && cargo run --bin ble_bas_peripheral --features nrf52840` +- `cd examples && cargo run --bin ble_bas_peripheral --features nrf52840-dk` -Examples can also built for nrf52832 chip targeting S132 softdevice. +Examples can also built for nrf52832 development kit targeting S132 softdevice (feature flag `nrf52832-dk`), or for nrf52833 targeting S140 softdevice on the BBC micro:bit v2 (feature flag `microbit-v2`). In these cases, edit `.cargo/config.toml` as needed. ## Configuring a SoftDevice diff --git a/ci.sh b/ci.sh index 540fab1..8a72557 100755 --- a/ci.sh +++ b/ci.sh @@ -6,8 +6,9 @@ set -euxo pipefail #=============== cd examples -cargo build --target thumbv7em-none-eabihf --features nrf52832 --bins -cargo build --target thumbv7em-none-eabihf --features nrf52840 --bins +cargo build --target thumbv7em-none-eabihf --features nrf52832-dk --bins +cargo build --target thumbv7em-none-eabihf --features microbit-v2 --bins +cargo build --target thumbv7em-none-eabihf --features nrf52840-dk --bins cd .. diff --git a/examples/.cargo/config.toml b/examples/.cargo/config.toml index d9250bd..bfa8b80 100644 --- a/examples/.cargo/config.toml +++ b/examples/.cargo/config.toml @@ -1,4 +1,7 @@ [target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# Pick ONE of these chip targets +#runner = "probe-rs run --chip nRF52832_xxAA" +#runner = "probe-rs run --chip nRF52833_xxAA" runner = "probe-rs run --chip nRF52840_xxAA" [build] diff --git a/examples/Cargo.toml b/examples/Cargo.toml index f99a634..19717cb 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -23,6 +23,12 @@ nrf52832 = [ "nrf-softdevice/s132", "dep:nrf-softdevice-s132" ] +nrf52833 = [ + "embassy-nrf/nrf52833", + "nrf-softdevice/nrf52833", + "nrf-softdevice/s140", + "dep:nrf-softdevice-s140" +] nrf52840 = [ "embassy-nrf/nrf52840", "nrf-softdevice/nrf52840", @@ -30,6 +36,10 @@ nrf52840 = [ "dep:nrf-softdevice-s140" ] +nrf52840-dk = ["nrf52840"] +nrf52832-dk = ["nrf52832"] +microbit-v2 = ["nrf52833"] + [dependencies] embassy-executor = { version = "0.5.0", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"]} embassy-time = { version = "0.3.0", features = ["defmt", "defmt-timestamp-uptime"]} diff --git a/examples/build.rs b/examples/build.rs index 2f84855..3e58a71 100644 --- a/examples/build.rs +++ b/examples/build.rs @@ -16,6 +16,8 @@ use std::path::PathBuf; fn linker_data() -> &'static [u8] { #[cfg(feature = "nrf52832")] return include_bytes!("memory-nrf52832.x"); + #[cfg(feature = "nrf52833")] + return include_bytes!("memory-nrf52833.x"); #[cfg(feature = "nrf52840")] return include_bytes!("memory-nrf52840.x"); @@ -24,9 +26,8 @@ fn linker_data() -> &'static [u8] { feature = "nrf52810", feature = "nrf52811", feature = "nrf52820", - feature = "nrf52833", ))] - panic!("Unable to build examples for currently selected chip due to missing chip-specific linker configuration (memory.x)"); + panic!("Unable to build examples for currently selected chip due to missing chip-specific linker configuration (memory.x)") } fn main() { diff --git a/examples/memory-nrf52833.x b/examples/memory-nrf52833.x new file mode 100644 index 0000000..540041c --- /dev/null +++ b/examples/memory-nrf52833.x @@ -0,0 +1,7 @@ +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + /* NRF52833 with Softdevice S140 7.3.0 */ + FLASH : ORIGIN = 0x00000000 + 156K, LENGTH = 512K - 156K + RAM : ORIGIN = 0x20000000 + 31K, LENGTH = 128K - 31K +} diff --git a/examples/memory-nrf52840.x b/examples/memory-nrf52840.x index 6c6b73b..5b2c22b 100644 --- a/examples/memory-nrf52840.x +++ b/examples/memory-nrf52840.x @@ -1,7 +1,7 @@ MEMORY { /* NOTE 1 K = 1 KiBi = 1024 bytes */ - /* NRF52840 with Softdevice S140 7.0.1 */ - FLASH : ORIGIN = 0x00027000, LENGTH = 868K - RAM : ORIGIN = 0x20020000, LENGTH = 128K + /* NRF52840 with Softdevice S140 7.3.0 */ + FLASH : ORIGIN = 0x00000000 + 156K, LENGTH = 1024K - 156K + RAM : ORIGIN = 0x20000000 + 31K, LENGTH = 256K - 31K } diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs index 5595a1b..1bc8d48 100644 --- a/examples/src/bin/ble_peripheral_onoff.rs +++ b/examples/src/bin/ble_peripheral_onoff.rs @@ -121,10 +121,15 @@ async fn main(spawner: Spawner) { unwrap!(spawner.spawn(softdevice_task(sd))); info!("Bluetooth is OFF"); - info!("Press nrf52840-dk button 1 to enable, button 2 to disable"); + info!("Press button 1 to enable, button 2 to disable"); + #[cfg(feature = "microbit-v2")] + let (b1_pin, b2_pin) = (p.P0_14, p.P0_23); + #[cfg(any(feature = "nrf52840-dk", feature = "nrf52832-dk"))] + let (b1_pin, b2_pin) = (p.P0_11, p.P0_12); + + let button1 = Input::new(b1_pin.degrade(), Pull::Up); + let button2 = Input::new(b2_pin.degrade(), Pull::Up); - let button1 = Input::new(p.P0_11.degrade(), Pull::Up); - let button2 = Input::new(p.P0_12.degrade(), Pull::Up); pin_mut!(button1); pin_mut!(button2); loop {