From 50fdc339083a34d91ada1c462c67978e58f87f11 Mon Sep 17 00:00:00 2001 From: Lotte Steenbrink Date: Mon, 19 Apr 2021 11:21:21 +0200 Subject: [PATCH] point out parts of a embedded program in helo.rs, Cargo.toml --- beginner/apps/.cargo/config.toml | 1 + beginner/apps/src/bin/hello.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/beginner/apps/.cargo/config.toml b/beginner/apps/.cargo/config.toml index be9aeec..7a1c918 100644 --- a/beginner/apps/.cargo/config.toml +++ b/beginner/apps/.cargo/config.toml @@ -12,4 +12,5 @@ rustflags = [ ] [build] +# cross-compile to this target target = "thumbv7em-none-eabihf" # = ARM Cortex-M4 \ No newline at end of file diff --git a/beginner/apps/src/bin/hello.rs b/beginner/apps/src/bin/hello.rs index 62a8ad0..9d20aa2 100644 --- a/beginner/apps/src/bin/hello.rs +++ b/beginner/apps/src/bin/hello.rs @@ -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] +// this program uses a custom entry point instead of `fn main()` +#![no_main] use cortex_m::asm; use cortex_m_rt::entry; use panic_log as _; // the panicking behavior + #[entry] +// ˆˆˆˆ the custom entry point fn main() -> ! { + // ˆˆˆ + // ! is the 'never' type: this function never returns + // initializes the peripherals dk::init().unwrap();