Embassy executor

The Embassy framework and particularly its executor will help us decouple tasks and resources.

Add the Embassy executor as a dependency

❎ Add the embassy-executor dependency to your Cargo.toml file with the following features:

  • arch-cortex-m in order to select the asynchronous executor adapted to our architecture
  • executor-thread to enable to default executor ("thread mode" is the "normal" processor mode, opposed to "interrupt mode")
  • defmt to enable debugging messages

Since we now use the full executor, the generic-queue-8 feature can be removed from embassy-time. The timers will use the features provided by the Embassy executor.

Embassy main program

❎ Add the embassy_executor::main attribute to your main function (instead of the previous entry attribute) and make it async, as seen in class and in Embassy documentation. Check that you can still execute your code as you did before. The main() function must take a Spawner parameter, which will be used to create tasks.

❎ Modify the Matrix::new() method so that it becomes asynchronous. Replace the use of the blocking delay by a call to one of the Timer asynchronous function.

For example you could use Timer::after() and give it an appropriate Duration, or use Timer::after_millis() directly.

Check that your program works correctly, including after unplugging and replugging your board in order to deinitialize the led matrix.