|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
MCU-integrated periodic timer implementation. More...
#include <EspPeriodicTimer.h>
Public Member Functions | |
| EspPeriodicTimer (hf_timer_callback_t callback=nullptr, void *user_data=nullptr) noexcept | |
| Constructor with callback specification. | |
| ~EspPeriodicTimer () noexcept override | |
| Destructor - ensures timer is stopped and resources are freed. | |
| EspPeriodicTimer (const EspPeriodicTimer &)=delete | |
| EspPeriodicTimer & | operator= (const EspPeriodicTimer &)=delete |
| EspPeriodicTimer (EspPeriodicTimer &&)=delete | |
| EspPeriodicTimer & | operator= (EspPeriodicTimer &&)=delete |
| hf_timer_err_t | Initialize () noexcept override |
| Initialize the timer. | |
| hf_timer_err_t | Deinitialize () noexcept override |
| Deinitialize the timer and free resources. | |
| hf_timer_err_t | Start (hf_u64_t period_us) noexcept override |
| Start the timer with specified period. | |
| hf_timer_err_t | Stop () noexcept override |
| Stop the timer. | |
| hf_timer_err_t | SetPeriod (hf_u64_t new_period_us) noexcept override |
| Change timer period (timer can be running or stopped). | |
| hf_timer_err_t | GetPeriod (hf_u64_t &period_us) noexcept override |
| Get current timer period. | |
| hf_timer_err_t | GetStats (hf_u64_t &callback_count, hf_u64_t &missed_callbacks, hf_timer_err_t &last_error) noexcept override |
| Get timer statistics and status information. | |
| hf_timer_err_t | ResetStats () noexcept override |
| Reset timer statistics. | |
| const char * | GetDescription () const noexcept override |
| Get description of this timer implementation. | |
| hf_u64_t | GetMinPeriod () const noexcept override |
| Get minimum supported timer period. | |
| hf_u64_t | GetMaxPeriod () const noexcept override |
| Get maximum supported timer period. | |
| hf_u64_t | GetResolution () const noexcept override |
| Get timer resolution. | |
| hf_timer_err_t | GetStatistics (hf_timer_statistics_t &statistics) const noexcept override |
| Get timer operation statistics. | |
| hf_timer_err_t | GetDiagnostics (hf_timer_diagnostics_t &diagnostics) const noexcept override |
| Get timer diagnostic information. | |
Public Member Functions inherited from BasePeriodicTimer | |
| virtual | ~BasePeriodicTimer () noexcept=default |
| Virtual destructor to ensure proper cleanup. | |
| BasePeriodicTimer (const BasePeriodicTimer &)=delete | |
| BasePeriodicTimer & | operator= (const BasePeriodicTimer &)=delete |
| bool | IsInitialized () const noexcept |
| Check if timer is initialized. | |
| bool | IsRunning () const noexcept |
| Check if timer is currently running. | |
| hf_timer_err_t | SetCallback (hf_timer_callback_t callback, void *user_data=nullptr) noexcept |
| Set new callback function. | |
| void * | GetUserData () const noexcept |
| Get current user data pointer. | |
| virtual hf_timer_err_t | ResetStatistics () noexcept |
| Reset timer operation statistics. | |
| virtual hf_timer_err_t | ResetDiagnostics () noexcept |
| Reset timer diagnostic information. | |
Private Member Functions | |
| hf_timer_err_t | ConvertError (int platform_error) const noexcept |
| Convert platform-specific error to hf_timer_err_t. | |
| bool | ValidatePeriod (hf_u64_t period_us) const noexcept |
| Validate timer period. | |
| bool | CreateTimerHandle () noexcept |
| Create platform-specific timer handle. | |
| void | DestroyTimerHandle () noexcept |
| Destroy platform-specific timer handle. | |
Static Private Member Functions | |
| static void | InternalTimerCallback (void *arg) |
| Internal timer callback dispatcher (ISR-safe C bridge). | |
Private Attributes | |
| hf_timer_handle_t | timer_handle_ |
| Platform-specific timer handle. | |
| hf_u64_t | period_us_ |
| Current timer period in microseconds. | |
| hf_timer_stats_t | stats_ |
| Timer statistics. | |
Additional Inherited Members | |
Protected Member Functions inherited from BasePeriodicTimer | |
| BasePeriodicTimer (hf_timer_callback_t callback, void *user_data=nullptr) noexcept | |
| Protected constructor with callback specification. | |
| void | SetInitialized (bool initialized) noexcept |
| Set the initialized state. | |
| void | SetRunning (bool running) noexcept |
| Set the running state. | |
| void | ExecuteCallback () noexcept |
| Execute the timer callback (called by implementations). | |
| bool | HasValidCallback () const noexcept |
| Check if callback is valid. | |
Protected Attributes inherited from BasePeriodicTimer | |
| hf_timer_callback_t | callback_ |
| Timer callback function. | |
| void * | user_data_ |
| User data passed to callback. | |
| bool | initialized_ |
| Initialization state flag. | |
| bool | running_ |
| Running state flag. | |
| hf_timer_statistics_t | statistics_ |
| Timer operation statistics. | |
| hf_timer_diagnostics_t | diagnostics_ |
| Timer diagnostic information. | |
MCU-integrated periodic timer implementation.
This class provides periodic timer functionality using the microcontroller's built-in timer peripherals. On ESP32, it uses the ESP timer API. The implementation handles platform-specific details while providing the unified BasePeriodicTimer API.
Features:
|
noexcept |
Constructor with callback specification.
| callback | Callback function to be called on timer expiry |
| user_data | User data passed to callback function |
|
overridenoexcept |
Destructor - ensures timer is stopped and resources are freed.
|
delete |
|
delete |
|
privatenoexcept |
Convert platform-specific error to hf_timer_err_t.
| platform_error | Platform-specific error code |
|
privatenoexcept |
Create platform-specific timer handle.
|
overridevirtualnoexcept |
Deinitialize the timer and free resources.
Implements BasePeriodicTimer.
|
privatenoexcept |
Destroy platform-specific timer handle.
|
overridevirtualnoexcept |
Get description of this timer implementation.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Get timer diagnostic information.
| diagnostics | Reference to diagnostics structure to fill |
Reimplemented from BasePeriodicTimer.
|
overridevirtualnoexcept |
Get maximum supported timer period.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Get minimum supported timer period.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Get current timer period.
| period_us | Reference to store current period |
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get timer operation statistics.
| statistics | Reference to statistics structure to fill |
Reimplemented from BasePeriodicTimer.
|
overridevirtualnoexcept |
Get timer statistics and status information.
| callback_count | Number of callbacks executed |
| missed_callbacks | Number of missed callbacks (if supported) |
| last_error | Last error that occurred |
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
|
staticprivate |
Internal timer callback dispatcher (ISR-safe C bridge).
| arg | User data (pointer to EspPeriodicTimer instance) |
|
delete |
|
delete |
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Change timer period (timer can be running or stopped).
| new_period_us | New period in microseconds |
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Start the timer with specified period.
| period_us | Timer period in microseconds |
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
|
privatenoexcept |
Validate timer period.
| period_us | Period to validate in microseconds |
|
private |
Current timer period in microseconds.
|
private |
Timer statistics.
|
private |
Platform-specific timer handle.