embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
4.79k stars 650 forks source link

Add async API to TSC #3111

Open Eekle opened 1 week ago

Eekle commented 1 week ago

First punt at contributing peripheral code, I hope it's close to where it needs to be.

Based off what I read in rng.rs, on the advice of @kkoppul2

Some questions I have:

kkoppul2 commented 1 week ago

I'm thinking we can have two constructors here, one with the interrupt, one without. Then users can choose how they want to use it. Make the irq an option.

Eekle commented 6 days ago

I'm thinking we can have two constructors here, one with the interrupt, one without. Then users can choose how they want to use it. Make the irq an option.

Would this be best achieved as an additional type parameter on the Tsc struct?

kkoppul2 commented 6 days ago

Yeah we can add the interrupt handler as an option and then follow the paradigm of the peripheral mode (Async vs Blocking) and have a constructor for each implementation. The Async takes the interrupts, the blocking doesn't. Then maybe we can combine the non-interrupt start function with the polling function and move that to the Blocking impl and the start_it to the Async impl. Most of the bus implementations already follow the pattern for reference.

Eekle commented 1 day ago

@kkoppul2 Updated with async/blocking split.

I have just removed the _it functions altogether, since the async wait works with the normal start func. I hope that's not problematic?