Hi,
I'm exploring the use of rust in embedded applications and am in the process of going through the suggested on-line book at Introduction - The Embedded Rust Book. In section 2.3 Memory-mapped Registers, Using Peripheral Access Crate (PAC) there is example code which produces a compile error on the #[entry] attribute. The code is:
#[entry]
pub fn init() -> (Delay, Leds) {
let cp = cortex_m::Peripherals::take().unwrap();
let p = tm4c123x::Peripherals::take().unwrap();
...
the error message complains that the function should be marked unsafe and worse its signature should look like "[unsafe] fn() -> ! "to satisfy the rust compiler.
My question is, am I totally missing something in my understanding or was this example created at a time the the function definitions used was correct but is now incorrect? If it is the latter how many other example code inserts are out-of-date in this book?
I'm using version 1.40 of rustc, am using Visual Studio Code as my IDE, and am on a current version of Arch Linux.
I’m not either, but I’m just learning. And, that is straight from the book example which I expected to be correct. Not only does it have parameters passed in it has no “!” as the compiler complained about, and according to what I’m learning
[entries] do not return.
It seems that it is pretty out-of-date a couple of other examples I tried have compile errors.
But that particular example was pretty badly constructed and I don’t think it would ever have worked. I’ll create an issue for that one, but I’ll find another tutorial source for embedded rust.