mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-01-10 16:25:37 +00:00
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:
commit
e9e2f15d65
2 changed files with 12 additions and 1 deletions
|
@ -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
|
|
@ -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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue