diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-04-17 05:58:54 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-17 05:58:54 +0000 |
| commit | 688ba1cf5b777995b777f6ec9555b69cced5a218 (patch) | |
| tree | 8a0fb9c1a179baf228e0e6d943ba6ae7f63d77ad /examples | |
| parent | 55083fb3ccee36c623c91b48ecc7d1f563ed80f8 (diff) | |
| parent | 76d2d27def1a911e23950dd1fceef9509c1ac56b (diff) | |
Merge #737
737: Fix example r=korken89 a=datdenkikniet
Co-authored-by: datdenkikniet <jcdra1@gmail.com>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp2040_local_i2c_init/src/main.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/examples/rp2040_local_i2c_init/src/main.rs b/examples/rp2040_local_i2c_init/src/main.rs index 6776892..a7ec08d 100644 --- a/examples/rp2040_local_i2c_init/src/main.rs +++ b/examples/rp2040_local_i2c_init/src/main.rs @@ -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; + } } } |
