mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-24 02:49:34 +01:00
Fix example
This commit is contained in:
parent
55083fb3cc
commit
76d2d27def
1 changed files with 16 additions and 6 deletions
|
@ -103,13 +103,23 @@ mod app {
|
|||
|
||||
#[task(local = [i2c, led])]
|
||||
async fn heartbeat(ctx: heartbeat::Context) {
|
||||
// Flicker the built-in LED
|
||||
_ = ctx.local.led.toggle();
|
||||
// Loop forever.
|
||||
//
|
||||
// It is important to remember that tasks that loop
|
||||
// forever should have an `await` somewhere in that loop.
|
||||
//
|
||||
// Without the await, the task will never yield back to
|
||||
// the async executor, which means that no other lower or
|
||||
// equal priority task will be able to run.
|
||||
loop {
|
||||
// Flicker the built-in LED
|
||||
_ = ctx.local.led.toggle();
|
||||
|
||||
// Congrats, you can use your i2c and have access to it here,
|
||||
// now to do something with it!
|
||||
// Congrats, you can use your i2c and have access to it here,
|
||||
// now to do something with it!
|
||||
|
||||
// Re-spawn this task after 1 second
|
||||
Timer::delay(1000.millis()).await;
|
||||
// Delay for 1 second
|
||||
Timer::delay(1000.millis()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue