continue workshop

This commit is contained in:
Robin Mueller authored and Robin Mueller committed 2026-06-11 14:11:14 +02:00
1 parent 1f805e672b
commit c9d5328450
32 files changed
+1354 -5

No files matched your search

@@ -0,0 +1,15 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace nRF82840_xxAA with your chip as listed in `probe-rs chip list`
runner = "probe-rs run --chip nRF52833_xxAA --allow-erase-all"
rustflags = [
"-C", "link-arg=-Tlink.x", # use the cortex-m-rt linker script
"-C", "linker=flip-link", # adds stack overflow protection
"-C", "link-arg=-Tdefmt.x", # defmt support
]
[build]
target = "thumbv7em-none-eabihf"
[env]
DEFMT_LOG = "info"
+1032
View File
File diff suppressed because it is too large. Load diff
+30
View File
@@ -0,0 +1,30 @@
[package]
name = "exercises"
version = "0.1.0"
edition = "2024"
[dependencies]
embassy-executor = { version = "0.10.0", features = ["platform-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
embassy-time = { version = "0.5.1", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-nrf = { version = "0.10.0", features = ["defmt", "nrf52833", "time-driver-rtc1", "unstable-pac", "time"] }
defmt = "1.0.1"
defmt-rtt = "1.0.0"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = "0.7.0"
panic-probe = { version = "1.0.0", features = ["print-defmt"] }
embedded-hal = { version = "1.0" }
embedded-hal-async = { version = "1.0" }
embedded-hal-bus = { version = "0.3", features = ["async"] }
embedded-io = { version = "0.7.1", features = ["defmt"] }
embedded-io-async = { version = "0.7.0", features = ["defmt"] }
portable-atomic = "1"
[profile.release]
debug = 2
[package.metadata.embassy]
build = [
{ target = "thumbv7em-none-eabi", artifact-dir = "out/examples/nrf52840" }
]
+31
View File
@@ -0,0 +1,31 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
}
+6
View File
@@ -0,0 +1,6 @@
MEMORY
{
/* NOTE 1 K = 1 KiBi = 1024 bytes */
FLASH : ORIGIN = 0x00000000, LENGTH = 512K
RAM : ORIGIN = 0x20000000, LENGTH = 128K
}
+23
View File
@@ -0,0 +1,23 @@
#![no_std]
#![no_main]
use exercises as _;
use embassy_executor::Spawner;
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
let _periphs = embassy_nrf::init(embassy_nrf::config::Config::default());
// TODOs
//
// Step 1: Initialize the hardware by using the `embassy_nrf::init` method.
// Step 2: print some initial log to the console, for example the exercise name.
// Step 3: Create an Output GPIO driver for ROW1
// Step 4: Create an Output GPIO driver for COL1
// Step 5: Set the GPIOs to the correct state to drive LED D2, which is the LED in
// the upper left corner of the LED matrix
// Step 6: Inside the empty loop, toggle the correct output to toggle the LED.
// Step 7: Led the LED blink with a certain frequency by using embassy_time::Timer
loop {}
}
@@ -0,0 +1,30 @@
#![no_std]
#![no_main]
use embassy_executor::Spawner;
use embassy_time::Timer;
use exercises as _;
use embassy_nrf::gpio::Output;
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
let periphs = embassy_nrf::init(embassy_nrf::config::Config::default());
defmt::println!("-- microbit v2 Blinky application --");
let mut row1 = Output::new(
periphs.P0_21,
embassy_nrf::gpio::Level::Low,
embassy_nrf::gpio::OutputDrive::Standard,
);
let _col1 = Output::new(
periphs.P0_28,
embassy_nrf::gpio::Level::Low,
embassy_nrf::gpio::OutputDrive::Standard,
);
loop {
row1.toggle();
Timer::after_millis(200).await;
}
}
+5
View File
@@ -0,0 +1,5 @@
#![no_std]
use defmt_rtt as _;
use embassy_nrf as _;
use panic_probe as _;