mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-01-10 08:15:36 +00:00
9f7bfe3384
these are for the case where USB functionality fails and compromises the radio functionality
35 lines
765 B
Rust
35 lines
765 B
Rust
#![deny(unused_must_use)]
|
|
#![no_main]
|
|
#![no_std]
|
|
|
|
use hal::{radio::{self, Channel}, led};
|
|
use panic_abort as _;
|
|
|
|
#[no_mangle]
|
|
fn main() -> ! {
|
|
let (mut rtx, mut rrx) = radio::claim(Channel::_21); // <- change this
|
|
let led = led::Green;
|
|
|
|
let task = async {
|
|
let mut packet = radio::Packet::new().await;
|
|
let mut on = true;
|
|
|
|
loop {
|
|
let crcres = rrx.read(&mut packet).await;
|
|
// togle LED on each new packet
|
|
if on {
|
|
led.on();
|
|
} else {
|
|
led.off();
|
|
}
|
|
on = !on;
|
|
|
|
if crcres.is_ok() {
|
|
packet.reverse();
|
|
rtx.write(&packet).await.ok();
|
|
}
|
|
}
|
|
};
|
|
|
|
executor::run!(task)
|
|
}
|