Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework initialization #79

Closed
wants to merge 13 commits into from
Closed

rework initialization #79

wants to merge 13 commits into from

Conversation

kaspar030
Copy link
Collaborator

@kaspar030 kaspar030 commented Feb 17, 2024

This PR reworks (and hopefully simplifies) task initialization.

With SendCell and Delegate I think we got the tools to not use a trait (object) for initialization.
I'm pretty happy so far, it feels like much reduced boilerplate already.

For now the PR:

  • drops the Application trait
  • drops Drivers and InitializationArgs
  • introduces SendCell, a struct that helps passing around non-Send types, runtime-checking that an object stays on the same executor
  • introduces riot_rs::embassy::network_stack(), which is now used to get to the network stack Stack object instead of passing it through the Drivers struct
  • we need a new macro for the tasks
  • review & document SendCell. it's currently more of a PoC, we need to make sure it's sound, and polish the API
  • introduce Delegate, which can be used to provide hooks e.g., for the UsbBuilder
  • use Delegate to provide a hook into the UsbBuilder
  • review & document Delegate

I'm aware that this is a pretty large PR as is. I'll split it up once we agree on the direction.

use riot_rs::embassy::{arch::OptionalPeripherals, Spawner};
#[riot_rs::embassy::distributed_slice(riot_rs::embassy::EMBASSY_TASKS)]
#[linkme(crate = riot_rs::embassy::linkme)]
fn web_server_init(spawner: &Spawner, peripherals: &mut OptionalPeripherals) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here, b/c the Buttons peripherals are optional, I found it easier to just write a custom non-async init function.

src/riot-rs-embassy/src/sendcell.rs Show resolved Hide resolved
src/riot-rs-embassy/src/sendcell.rs Show resolved Hide resolved
src/riot-rs-embassy/src/delegate.rs Show resolved Hide resolved
src/riot-rs-embassy/src/delegate.rs Show resolved Hide resolved
src/riot-rs-embassy/src/delegate.rs Show resolved Hide resolved
examples/embassy-usb-keyboard/src/main.rs Outdated Show resolved Hide resolved
@kaspar030
Copy link
Collaborator Author

Thanks for the review!
I've incorporated everyting and split the PR into #84, #85, #86, #87.

@kaspar030 kaspar030 closed this Feb 19, 2024
@kaspar030 kaspar030 deleted the pr/rework_initialization branch February 19, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants