Archived
continue workshop
This commit is contained in:
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"
|
||||
Generated
+1032
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,32 @@
|
||||
[package]
|
||||
edition = "2024"
|
||||
name = "rust-app"
|
||||
version = "0.1.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[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" }
|
||||
]
|
||||
Binary file not shown.
@@ -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");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
MEMORY
|
||||
{
|
||||
/* NOTE 1 K = 1 KiBi = 1024 bytes */
|
||||
FLASH : ORIGIN = 0x00000000, LENGTH = 512K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::Timer;
|
||||
use rust_app 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 mut col1 = Output::new(
|
||||
periphs.P0_28,
|
||||
embassy_nrf::gpio::Level::Low,
|
||||
embassy_nrf::gpio::OutputDrive::Standard,
|
||||
);
|
||||
row1.set_high();
|
||||
col1.set_low();
|
||||
loop {
|
||||
defmt::debug!("blinking LED");
|
||||
row1.toggle();
|
||||
Timer::after_millis(1000).await;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use rust_app as _;
|
||||
use embassy_executor::Spawner;
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) -> ! {
|
||||
defmt::info!("Hello, world!");
|
||||
loop {}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embedded_io_async::Write;
|
||||
use rust_app as _;
|
||||
|
||||
use embassy_nrf::{
|
||||
peripherals,
|
||||
uarte::{self, Baudrate},
|
||||
};
|
||||
embassy_nrf::bind_interrupts!(
|
||||
struct Irqs {
|
||||
UARTE0 => uarte::InterruptHandler<peripherals::UARTE0>;
|
||||
}
|
||||
);
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) -> ! {
|
||||
let periphs = embassy_nrf::init(embassy_nrf::config::Config::default());
|
||||
|
||||
defmt::println!("-- microbit v2 UART echo application --");
|
||||
let mut uarte_config = uarte::Config::default();
|
||||
uarte_config.baudrate = Baudrate::BAUD115200;
|
||||
|
||||
let uart = uarte::Uarte::new(
|
||||
periphs.UARTE0,
|
||||
periphs.P1_08,
|
||||
periphs.P0_06,
|
||||
Irqs,
|
||||
uarte_config,
|
||||
);
|
||||
let (mut uart_tx, mut uart_rx) =
|
||||
uart.split_with_idle(periphs.TIMER0, periphs.PPI_CH0, periphs.PPI_CH1);
|
||||
let mut rx_buf: [u8; 64] = [0; 64];
|
||||
loop {
|
||||
match uart_rx.read_until_idle(&mut rx_buf).await {
|
||||
Ok(read_bytes) => match uart_tx.write_all(&rx_buf[0..read_bytes]).await {
|
||||
Ok(_) => {
|
||||
defmt::trace!("read {} bytes", &read_bytes);
|
||||
}
|
||||
Err(e) => defmt::error!("UART transmission error: {}", e),
|
||||
},
|
||||
Err(e) => defmt::error!("UART reception error: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#![no_std]
|
||||
|
||||
use defmt_rtt as _;
|
||||
use embassy_nrf as _;
|
||||
use panic_probe as _;
|
||||
@@ -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"
|
||||
Generated
+1032
File diff suppressed because it is too large.
Load diff
@@ -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" }
|
||||
]
|
||||
@@ -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");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
MEMORY
|
||||
{
|
||||
/* NOTE 1 K = 1 KiBi = 1024 bytes */
|
||||
FLASH : ORIGIN = 0x00000000, LENGTH = 512K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#![no_std]
|
||||
|
||||
use defmt_rtt as _;
|
||||
use embassy_nrf as _;
|
||||
use panic_probe as _;
|
||||
@@ -0,0 +1,5 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
components = [ "llvm-tools-preview", "clippy" ]
|
||||
targets = [ "thumbv7em-none-eabihf" ]
|
||||
profile = "default"
|
||||
Reference in new issue
Block a user