RAII wrapper around an oveRTOS software timer.
More...
#include <timer.hpp>
|
template<typename F >
requires TimerCallback<F> |
| | Timer (F callback, void *user_data, uint32_t period_ms, bool one_shot=false) |
| | Constructs and initialises the timer.
|
| |
|
| ~Timer () |
| | Destroys the timer, stopping it if running and releasing the kernel resource.
|
| |
|
| Timer (const Timer &)=delete |
| |
|
Timer & | operator= (const Timer &)=delete |
| |
| | Timer (Timer &&other) noexcept |
| | Move constructor — transfers ownership of the kernel handle.
|
| |
| Timer & | operator= (Timer &&other) noexcept |
| | Move-assignment operator — transfers ownership of the kernel handle.
|
| |
| int | start () |
| | Starts the timer.
|
| |
| int | stop () |
| | Stops the timer without resetting its period.
|
| |
| int | reset () |
| | Restarts the timer, resetting the period countdown.
|
| |
| bool | valid () const |
| | Returns true if the underlying kernel handle is non-null.
|
| |
| ove_timer_t | handle () const |
| | Returns the raw oveRTOS timer handle.
|
| |
RAII wrapper around an oveRTOS software timer.
A software timer calls a user-provided callback either once (one_shot) or periodically at the specified interval. The timer is created in the stopped state; call start() to activate it.
- Note
- Not copyable. Move-only when heap allocation is enabled.
-
start(), stop(), and reset() are marked [[nodiscard]] because their return value indicates whether the RTOS accepted the request.
◆ Timer() [1/2]
template<typename F >
requires TimerCallback<F>
| ove::Timer::Timer |
( |
F |
callback, |
|
|
void * |
user_data, |
|
|
uint32_t |
period_ms, |
|
|
bool |
one_shot = false |
|
) |
| |
|
inline |
Constructs and initialises the timer.
The timer is created in the stopped state.
- Template Parameters
-
| F | Callable type satisfying TimerCallback. |
- Parameters
-
| [in] | callback | Function pointer called when the timer fires. |
| [in] | user_data | Opaque pointer forwarded to the callback. |
| [in] | period_ms | Timer period in milliseconds. |
| [in] | one_shot | If true, the timer fires once and stops; if false, it repeats indefinitely. |
Asserts at startup if initialisation fails.
◆ Timer() [2/2]
| ove::Timer::Timer |
( |
Timer && |
other | ) |
|
|
inlinenoexcept |
Move constructor — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
◆ operator=()
Move-assignment operator — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
- Returns
- Reference to this object.
◆ start()
| int ove::Timer::start |
( |
| ) |
|
|
inline |
Starts the timer.
- Returns
OVE_OK on success, or a negative error code.
◆ stop()
Stops the timer without resetting its period.
- Returns
OVE_OK on success, or a negative error code.
◆ reset()
| int ove::Timer::reset |
( |
| ) |
|
|
inline |
Restarts the timer, resetting the period countdown.
- Returns
OVE_OK on success, or a negative error code.
◆ valid()
| bool ove::Timer::valid |
( |
| ) |
const |
|
inline |
Returns true if the underlying kernel handle is non-null.
- Returns
true when the timer was successfully initialised.
◆ handle()
| ove_timer_t ove::Timer::handle |
( |
| ) |
const |
|
inline |
Returns the raw oveRTOS timer handle.
- Returns
- The opaque
ove_timer_t handle.
The documentation for this class was generated from the following file: