|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
STM32 Periodic Timer implementation. More...
#include <StmPeriodicTimer.h>
Classes | |
| struct | DispatchEntry |
Public Member Functions | |
| StmPeriodicTimer (TIM_HandleTypeDef *htim, hf_u32_t timer_clock_hz, hf_timer_callback_t callback=nullptr, void *user_data=nullptr) noexcept | |
| Construct from CubeMX timer handle. | |
| StmPeriodicTimer (const hf_stm32_timer_config_t &config, hf_timer_callback_t callback=nullptr, void *user_data=nullptr) noexcept | |
| Construct from config struct. | |
| ~StmPeriodicTimer () noexcept override | |
| StmPeriodicTimer (const StmPeriodicTimer &)=delete | |
| StmPeriodicTimer & | operator= (const StmPeriodicTimer &)=delete |
| hf_timer_err_t | Initialize () noexcept override |
| Initialize the timer hardware/resources. | |
| 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 periodic timer with specified period. | |
| hf_timer_err_t | Stop () noexcept override |
| Stop the periodic timer. | |
| hf_timer_err_t | SetPeriod (hf_u64_t period_us) noexcept override |
| Change the timer period while running. | |
| hf_timer_err_t | GetPeriod (hf_u64_t &period_us) noexcept override |
| Get the 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 | GetMaxPeriod () const noexcept override |
| Get minimum supported timer period. | |
| hf_u64_t | GetMinPeriod () 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. | |
Static Public Member Functions | |
| static void | IsrDispatch (TIM_HandleTypeDef *htim) noexcept |
| Call from HAL_TIM_PeriodElapsedCallback to dispatch to instances. | |
Private Member Functions | |
| bool | ApplyPeriod (hf_u64_t period_us) noexcept |
| Recalculate and apply PSC+ARR for the requested period. | |
| void | RegisterDispatch () noexcept |
| void | UnregisterDispatch () noexcept |
Private Attributes | |
| TIM_HandleTypeDef * | htim_ |
| HAL timer handle. | |
| hf_u32_t | timer_clock_hz_ |
| Input clock to the timer. | |
| hf_u64_t | period_us_ |
| Current period in µs. | |
| hf_timer_stats_t | stats_ |
| Internal stats. | |
Static Private Attributes | |
| static constexpr int | kMaxTimerInstances = 8 |
| static DispatchEntry | s_dispatch_ [kMaxTimerInstances] {} |
| static int | s_dispatch_count_ = 0 |
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. | |
STM32 Periodic Timer implementation.
Design:
|
explicitnoexcept |
Construct from CubeMX timer handle.
| htim | Pointer to HAL timer handle (CubeMX‑initialised). |
| timer_clock_hz | APB timer clock feeding this TIM (e.g. 84 MHz). |
| callback | User callback (may also be set later via SetCallback). |
| user_data | Opaque pointer forwarded to callback. |
|
explicitnoexcept |
Construct from config struct.
|
overridenoexcept |
|
delete |
|
privatenoexcept |
Recalculate and apply PSC+ARR for the requested period.
|
overridevirtualnoexcept |
Deinitialize the timer and free resources.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Get description of this timer implementation.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Get timer diagnostic information.
| diagnostics | Reference to store diagnostics data |
Reimplemented from BasePeriodicTimer.
|
overridevirtualnoexcept |
Get minimum supported timer period.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Get maximum supported timer period.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Get the current timer period.
| period_us | Reference to store the current period |
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get timer operation statistics.
| statistics | Reference to store statistics data |
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 |
Initialize the timer hardware/resources.
Implements BasePeriodicTimer.
|
staticnoexcept |
Call from HAL_TIM_PeriodElapsedCallback to dispatch to instances.
Usage in user code:
|
delete |
|
privatenoexcept |
|
overridevirtualnoexcept |
Reset timer statistics.
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Change the timer period while running.
| period_us | New timer period in microseconds |
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Start the periodic timer with specified period.
| period_us | Timer period in microseconds |
Implements BasePeriodicTimer.
|
overridevirtualnoexcept |
Stop the periodic timer.
Implements BasePeriodicTimer.
|
privatenoexcept |
|
private |
HAL timer handle.
|
staticconstexprprivate |
|
private |
Current period in µs.
|
staticprivate |
|
staticprivate |
|
private |
Internal stats.
|
private |
Input clock to the timer.