Skip to content

Commit

Permalink
feat: Update hello world example
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioGasquez committed Nov 15, 2024
1 parent 4486383 commit 4f3bbc3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions book/src/02_4_hello_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd intro/hello-world
✅ Build, flash, and monitor the project:

```console
$ cargo run
$ cargo run --release
(...)
Finished release [optimized] target(s) in 1.78s
(...)
Expand All @@ -33,7 +33,7 @@ Commands:
CTRL+C Exit
(...)
(...)
Hello world!
INFO - Hello world!
```

>🔎 If `cargo run` has been successful, you can exit with `ctrl+C`.
Expand Down
3 changes: 3 additions & 0 deletions intro/hello-world/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ target = "riscv32imc-unknown-none-elf"

[unstable]
build-std = ["core"]

[env]
ESP_LOG="INFO"
1 change: 1 addition & 0 deletions intro/hello-world/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions intro/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
esp-hal = { version = "0.21.0", features = ["esp32c3"] }
esp-backtrace = { version = "0.14.2", features = [
esp-backtrace = { version = "0.14.1", features = [
"esp32c3",
"panic-handler",
"exception-handler",
"panic-handler",
"println",
]}

esp-hal = { version = "0.21.0", features = [
"esp32c3",
] }
esp-println = { version = "0.12.0", features = ["esp32c3"] }
esp-println = { version = "0.12.0", features = ["esp32c3", "log"] }
log = { version = "0.4.21" }
13 changes: 8 additions & 5 deletions intro/hello-world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
#![no_main]

use esp_backtrace as _;
use esp_hal::delay::Delay;
use esp_hal::prelude::*;
use esp_println::println;
use log::info;

#[entry]
fn main() -> ! {
esp_hal::init(esp_hal::Config::default());
esp_println::logger::init_logger_from_env();

println!("Hello world!");

loop {}
let delay = Delay::new();
loop {
info!("Hello world!");
delay.delay(500.millis());
}
}

0 comments on commit 4f3bbc3

Please sign in to comment.