esp-hal icon indicating copy to clipboard operation
esp-hal copied to clipboard

Improve and use timer abstractions

Open bjoernQ opened this issue 1 year ago • 1 comments

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request. To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • [x] I have updated existing examples or added new ones (if applicable).
  • [x] I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • [x] My changes were added to the CHANGELOG.md in the proper section.
  • [x] My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

  • make esp-wifi::initialize take a PeriodicTimer<ErasedTimer>
  • make the embassy time-driver take OneShotTimer<ErasedTimer> references

This enables the user to use any hw-timer for esp-wifi (no matter if from TIMG0, TIMG1 or SYSTIMER) and use any combination of hw-timers for the embassy-time-driver. It also gets rid of the features to select the embassy time-driver implementation.

Testing

Run the (changed) examples ideally at least on ESP32, ESP32-S2 and any other chip

bjoernQ avatar Jul 04 '24 13:07 bjoernQ

Side note: The underlying timers probably should wrap modifications on shared registers in a critical-section (#1739 already addresses that for SYSTIMER). That is out of scope for this PR

Sorry for the huge amount of changed code here but I think it makes sense to have this in one PR - fortunately much of the changes are just adapted examples. BTW the examples use different timers and patterns for initialization - that's to show the flexibility of the API and on purpose

bjoernQ avatar Jul 05 '24 06:07 bjoernQ