Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First draft using the gptimer api introduced in ESP-IDF 5.
Pros about the new api:
Cons:
Most of this first draft mimics the implementation of the old api. A noticeable change is that i introduced marker traits for ISR and nonISR safe methods. The advantage of this is that we don't need a runtime check on each driver method. The isr itself will return a special TimerDriverInISR struct that is just a thin wrapper around the underlying handle. This ISRDriver only exposes the isr safe methods. To reduce code duplication i implemented most methods in the defined traits itself. The only one small downside of this is the user of the driver needs to import the traits in his context with
hal::timer::gptimer::{ISRMethods, NonISRsaveMethods}
otherwise he doesn't have any methods on the TimerDriver. I think this tradeoff is worthwhile, but needs proper documentation on the object so people don't forget.To allow this driver to work we need to make sure that in the complete codebase we dont use the old driver in any way. It will lead into a hardfault at runtime (esp-idf checks for this case). The simplest way currently was to just featuregate this driver, but to not make a breaking change with the old driver introduces some amount of
#[cfg(not(feature = "gp_timer_api"))]
TODO: