Merge pull request #143 from ferrous-systems/hello-explanation

point out parts of a embedded program in hello.rs, Cargo.toml
This commit is contained in:
Lotte Steenbrink 2021-05-05 14:34:45 +02:00 committed by GitHub
commit e9e2f15d65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -6,10 +6,13 @@ rustflags = [
] ]
[target.thumbv7em-none-eabihf] [target.thumbv7em-none-eabihf]
# set custom cargo runner to flash & run on embedded target when we call `cargo run`
# for more information, check out https://github.com/knurling-rs/probe-run
runner = "probe-run --chip nRF52840_xxAA" runner = "probe-run --chip nRF52840_xxAA"
rustflags = [ rustflags = [
"-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tlink.x",
] ]
[build] [build]
# cross-compile to this target
target = "thumbv7em-none-eabihf" # = ARM Cortex-M4 target = "thumbv7em-none-eabihf" # = ARM Cortex-M4

View file

@ -1,12 +1,20 @@
#![no_main] // this program does not use the standard library to avoid heap allocations.
// only the `core` library functions are available.
#![no_std] #![no_std]
// this program uses a custom entry point instead of `fn main()`
#![no_main]
use cortex_m::asm; use cortex_m::asm;
use cortex_m_rt::entry; use cortex_m_rt::entry;
use panic_log as _; // the panicking behavior use panic_log as _; // the panicking behavior
// the custom entry point
// vvvvv
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
// ˆˆˆ
// ! is the 'never' type: this function never returns
// initializes the peripherals // initializes the peripherals
dk::init().unwrap(); dk::init().unwrap();