mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-01-10 08:15:36 +00:00
convert all beginner code snippets
This commit is contained in:
parent
6bbd0c1e45
commit
e0ed95dcc4
11 changed files with 73 additions and 56 deletions
|
@ -5,7 +5,8 @@
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet};
|
use dk::ieee802154::{Channel, Packet};
|
||||||
use heapless::{consts, LinearMap};
|
use heapless::{consts, LinearMap};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -36,16 +37,18 @@ fn main() -> ! {
|
||||||
// TODO insert the key-value pair
|
// TODO insert the key-value pair
|
||||||
// dict.insert(/* ? */, /* ? */).expect("dictionary full");
|
// dict.insert(/* ? */, /* ? */).expect("dictionary full");
|
||||||
} else {
|
} else {
|
||||||
log::error!("response packet was not a single byte");
|
defmt::error!("response packet was not a single byte");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("{:?}", dict);
|
defmt::info!("{:?}", defmt::Debug2Format(&dict));
|
||||||
|
// ^^^^^^^^^^^^^^^^^^^ this adapter iscurrently needed to log `heapless`
|
||||||
|
// data structures (like `LinearMap` here) with `defmt`
|
||||||
|
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ use core::str;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use heapless::{consts, Vec};
|
use heapless::{consts, Vec};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
|
@ -21,10 +22,13 @@ fn main() -> ! {
|
||||||
buffer.push(b'i').expect("buffer full");
|
buffer.push(b'i').expect("buffer full");
|
||||||
|
|
||||||
// look into the contents so far
|
// look into the contents so far
|
||||||
log::info!("{:?}", buffer);
|
defmt::info!("{:?}", defmt::Debug2Format(&buffer));
|
||||||
|
// ^^^^^^^^^^^^^^^^^^^ this adapter iscurrently needed to log `heapless`
|
||||||
|
// data structures (like `Vec` here) with `defmt`
|
||||||
|
|
||||||
// or more readable
|
// or more readable
|
||||||
// NOTE as long as you only push bytes in the ASCII range (0..=127) the conversion should work
|
// NOTE utf-8 conversion works as long as you only push bytes in the ASCII range (0..=127)
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"{}",
|
"{}",
|
||||||
str::from_utf8(&buffer).expect("content was not UTF-8")
|
str::from_utf8(&buffer).expect("content was not UTF-8")
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,8 @@ use core::str;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet};
|
use dk::ieee802154::{Channel, Packet};
|
||||||
use heapless::{consts, Vec};
|
use heapless::{consts, Vec};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -27,11 +28,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"ciphertext: {}",
|
"ciphertext: {}",
|
||||||
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
||||||
);
|
);
|
||||||
|
@ -47,7 +48,7 @@ fn main() -> ! {
|
||||||
buf.push(output).expect("buffer full");
|
buf.push(output).expect("buffer full");
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"plaintext: {}",
|
"plaintext: {}",
|
||||||
str::from_utf8(&buf).expect("buffer contains non-UTF-8 data")
|
str::from_utf8(&buf).expect("buffer contains non-UTF-8 data")
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,8 @@ use core::str;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet};
|
use dk::ieee802154::{Channel, Packet};
|
||||||
use heapless::{consts, LinearMap, Vec};
|
use heapless::{consts, LinearMap, Vec};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -37,11 +38,11 @@ fn main() -> ! {
|
||||||
// TODO insert the key-value pair
|
// TODO insert the key-value pair
|
||||||
// dict.insert(/* ? */, /* ? */).expect("dictionary full");
|
// dict.insert(/* ? */, /* ? */).expect("dictionary full");
|
||||||
} else {
|
} else {
|
||||||
log::error!("response packet was not a single byte");
|
defmt::error!("response packet was not a single byte");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,11 +52,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"ciphertext: {}",
|
"ciphertext: {}",
|
||||||
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
||||||
);
|
);
|
||||||
|
@ -71,7 +72,7 @@ fn main() -> ! {
|
||||||
buffer.push(value).expect("buffer full");
|
buffer.push(value).expect("buffer full");
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"plaintext: {}",
|
"plaintext: {}",
|
||||||
str::from_utf8(&buffer).expect("buffer contains non-UTF-8 data")
|
str::from_utf8(&buffer).expect("buffer contains non-UTF-8 data")
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,8 @@ use core::str;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet};
|
use dk::ieee802154::{Channel, Packet};
|
||||||
use heapless::{consts, LinearMap, Vec};
|
use heapless::{consts, LinearMap, Vec};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -37,11 +38,11 @@ fn main() -> ! {
|
||||||
// TODO insert the key-value pair
|
// TODO insert the key-value pair
|
||||||
// dict.insert(/* ? */, /* ? */).expect("dictionary full");
|
// dict.insert(/* ? */, /* ? */).expect("dictionary full");
|
||||||
} else {
|
} else {
|
||||||
log::error!("response packet was not a single byte");
|
defmt::error!("response packet was not a single byte");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,11 +52,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"ciphertext: {}",
|
"ciphertext: {}",
|
||||||
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
||||||
);
|
);
|
||||||
|
@ -71,7 +72,7 @@ fn main() -> ! {
|
||||||
buffer.push(value).expect("buffer full");
|
buffer.push(value).expect("buffer full");
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"plaintext: {}",
|
"plaintext: {}",
|
||||||
str::from_utf8(&buffer).expect("buffer contains non-UTF-8 data")
|
str::from_utf8(&buffer).expect("buffer contains non-UTF-8 data")
|
||||||
);
|
);
|
||||||
|
@ -82,11 +83,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"Dongle response: {}",
|
"Dongle response: {}",
|
||||||
str::from_utf8(&packet).expect("response was not UTF-8")
|
str::from_utf8(&packet).expect("response was not UTF-8")
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,8 @@ use core::str;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet};
|
use dk::ieee802154::{Channel, Packet};
|
||||||
use heapless::{consts, LinearMap};
|
use heapless::{consts, LinearMap};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -38,11 +39,11 @@ fn main() -> ! {
|
||||||
dict.insert(cipherletter, plainletter)
|
dict.insert(cipherletter, plainletter)
|
||||||
.expect("dictionary full");
|
.expect("dictionary full");
|
||||||
} else {
|
} else {
|
||||||
log::error!("response packet was not a single byte");
|
defmt::error!("response packet was not a single byte");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +53,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"ciphertext: {}",
|
"ciphertext: {}",
|
||||||
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
||||||
);
|
);
|
||||||
|
@ -74,7 +75,7 @@ fn main() -> ! {
|
||||||
*spot = plainletter;
|
*spot = plainletter;
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"plaintext: {}",
|
"plaintext: {}",
|
||||||
str::from_utf8(&packet).expect("buffer contains non-UTF-8 data")
|
str::from_utf8(&packet).expect("buffer contains non-UTF-8 data")
|
||||||
);
|
);
|
||||||
|
@ -83,11 +84,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"Dongle response: {}",
|
"Dongle response: {}",
|
||||||
str::from_utf8(&packet).expect("response was not UTF-8")
|
str::from_utf8(&packet).expect("response was not UTF-8")
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,8 @@ use core::str;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet};
|
use dk::ieee802154::{Channel, Packet};
|
||||||
use heapless::{consts, LinearMap, Vec};
|
use heapless::{consts, LinearMap, Vec};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -41,11 +42,11 @@ fn main() -> ! {
|
||||||
dict.insert(cipherletter, plainletter)
|
dict.insert(cipherletter, plainletter)
|
||||||
.expect("dictionary full");
|
.expect("dictionary full");
|
||||||
} else {
|
} else {
|
||||||
log::error!("response packet was not a single byte");
|
defmt::error!("response packet was not a single byte");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,11 +56,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"ciphertext: {}",
|
"ciphertext: {}",
|
||||||
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
str::from_utf8(&packet).expect("packet was not valid UTF-8")
|
||||||
);
|
);
|
||||||
|
@ -76,7 +77,7 @@ fn main() -> ! {
|
||||||
buffer.push(plainletter).expect("buffer full");
|
buffer.push(plainletter).expect("buffer full");
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"plaintext: {}",
|
"plaintext: {}",
|
||||||
str::from_utf8(&buffer).expect("buffer contains non-UTF-8 data")
|
str::from_utf8(&buffer).expect("buffer contains non-UTF-8 data")
|
||||||
);
|
);
|
||||||
|
@ -87,11 +88,11 @@ fn main() -> ! {
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"Dongle response: {}",
|
"Dongle response: {}",
|
||||||
str::from_utf8(&packet).expect("response was not UTF-8")
|
str::from_utf8(&packet).expect("response was not UTF-8")
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,8 @@ use core::str;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet};
|
use dk::ieee802154::{Channel, Packet};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -33,19 +34,19 @@ fn main() -> ! {
|
||||||
// let msg = b"Hello?";
|
// let msg = b"Hello?";
|
||||||
|
|
||||||
packet.copy_from_slice(msg);
|
packet.copy_from_slice(msg);
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"sending: {}",
|
"sending: {}",
|
||||||
str::from_utf8(msg).expect("msg was not valid UTF-8 data")
|
str::from_utf8(msg).expect("msg was not valid UTF-8 data")
|
||||||
);
|
);
|
||||||
|
|
||||||
radio.send(&mut packet);
|
radio.send(&mut packet);
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"received: {}",
|
"received: {}",
|
||||||
str::from_utf8(&packet).expect("response was not valid UTF-8 data")
|
str::from_utf8(&packet).expect("response was not valid UTF-8 data")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
log::error!("no response or response packet was corrupted");
|
defmt::error!("no response or response packet was corrupted");
|
||||||
}
|
}
|
||||||
dk::exit()
|
dk::exit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ use core::str;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Error, Packet};
|
use dk::ieee802154::{Channel, Error, Packet};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
const TEN_MS: u32 = 10_000;
|
const TEN_MS: u32 = 10_000;
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ fn main() -> ! {
|
||||||
let msg = b"olleh";
|
let msg = b"olleh";
|
||||||
packet.copy_from_slice(msg);
|
packet.copy_from_slice(msg);
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"sending: {}",
|
"sending: {}",
|
||||||
str::from_utf8(msg).expect("message is not valid UTF-8")
|
str::from_utf8(msg).expect("message is not valid UTF-8")
|
||||||
);
|
);
|
||||||
|
@ -37,14 +38,15 @@ fn main() -> ! {
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(crc) => {
|
Ok(crc) => {
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"received: {} (CRC={})",
|
"received: {} (CRC = {:X})",
|
||||||
|
// ^^ print as uppercase hexadecimal
|
||||||
str::from_utf8(&*packet).expect("response is not valid UTF-8"),
|
str::from_utf8(&*packet).expect("response is not valid UTF-8"),
|
||||||
crc
|
crc
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(Error::Crc(crc)) => log::error!("invalid CRC: {:06x}", crc),
|
Err(Error::Crc(crc)) => defmt::error!("invalid CRC: {=u16:x}", crc),
|
||||||
Err(Error::Timeout) => log::error!("no response within {} ms", TEN_MS / 1_000),
|
Err(Error::Timeout) => defmt::error!("no response within {} ms", TEN_MS / 1_000),
|
||||||
}
|
}
|
||||||
|
|
||||||
dk::exit()
|
dk::exit()
|
||||||
|
|
|
@ -6,7 +6,8 @@ use core::str;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use dk::ieee802154::{Channel, Packet, TxPower};
|
use dk::ieee802154::{Channel, Packet, TxPower};
|
||||||
use panic_log as _; // the panicking behavior
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
|
@ -25,7 +26,7 @@ fn main() -> ! {
|
||||||
// let msg: &[u8; 5] = &[b'H', b'e', b'l', b'l', b'o'];
|
// let msg: &[u8; 5] = &[b'H', b'e', b'l', b'l', b'o'];
|
||||||
// let msg: &[u8; 5] = b"Hello";
|
// let msg: &[u8; 5] = b"Hello";
|
||||||
|
|
||||||
log::info!(
|
defmt::info!(
|
||||||
"sending: {}",
|
"sending: {}",
|
||||||
str::from_utf8(msg).expect("msg is not valid UTF-8 data")
|
str::from_utf8(msg).expect("msg is not valid UTF-8 data")
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,14 +3,15 @@
|
||||||
|
|
||||||
use cortex_m::asm;
|
use cortex_m::asm;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use panic_log as _; // panic handler
|
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
|
||||||
|
use apps as _;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
// board initialization
|
// board initialization
|
||||||
dk::init().unwrap();
|
dk::init().unwrap();
|
||||||
|
|
||||||
log::info!("fib(100) = {:?}", fib(100));
|
defmt::info!("fib(100) = {:?}", fib(100));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
asm::bkpt();
|
asm::bkpt();
|
||||||
|
|
Loading…
Reference in a new issue