5#ifndef ELEC_C7222_UTILS_FREE_RTOS_TIMER_HPP
6#define ELEC_C7222_UTILS_FREE_RTOS_TIMER_HPP
73 enum class Type : uint8_t {
95 std::uint32_t period_ticks,
97 std::function<
void(
void*)> callback =
nullptr);
113 std::uint32_t period_ticks,
115 std::function<
void(
void*)> callback);
134 bool Start(std::uint32_t ticks_to_wait = 0,
void* callback_arg =
nullptr);
154 bool Stop(std::uint32_t ticks_to_wait = 0);
174 bool Reset(std::uint32_t ticks_to_wait = 0);
195 bool ChangePeriod(std::uint32_t period_ticks, std::uint32_t ticks_to_wait = 0);
235 void* handle_{
nullptr};
241 std::function<void(
void*)> callback_{
nullptr};
245 void* callback_arg_{
nullptr};
Ownership-based C++ wrapper for FreeRTOS software timers.
Definition freertos_timer.hpp:71
bool IsValid() const
Check if the timer handle is valid.
bool Reset(std::uint32_t ticks_to_wait=0)
Reset the timer to start counting from zero.
bool IsActive() const
Check whether the timer is active.
friend void FreeRtosTimerCallback(void *timer)
Internal use only. This function is invoked as a callback when the FreeRTOS timer expires.
bool Stop(std::uint32_t ticks_to_wait=0)
Stop the timer.
bool ChangePeriod(std::uint32_t period_ticks, std::uint32_t ticks_to_wait=0)
Change the timer period.
FreeRtosTimer(const char *name, std::uint32_t period_ticks, Type type, std::function< void(void *)> callback=nullptr)
Create a FreeRTOS software timer.
bool ResetFromISR()
Reset the timer from ISR context (no immediate yield).
bool Start(std::uint32_t ticks_to_wait=0, void *callback_arg=nullptr)
Start the timer.
bool StartFromISR(void *callback_arg=nullptr)
Start the timer from ISR context (no immediate yield).
bool ChangePeriodFromISR(std::uint32_t period_ticks)
Change the timer period from ISR context (no immediate yield).
bool StopFromISR()
Stop the timer from ISR context (no immediate yield).
Type
Definition freertos_timer.hpp:73
@ kOneShot
One-shot timer: fires once then stops.
@ kPeriodic
Periodic timer: fires repeatedly at the configured period.
bool Initialize(const char *name, std::uint32_t period_ticks, Type type, std::function< void(void *)> callback)
Initialize (or re-initialize) the timer wrapper.
void SetCallback(std::function< void(void *)> callback)
Register or replace the timer callback.
FreeRtosTimer()=default
Create an uninitialized timer wrapper.
~FreeRtosTimer()
Delete the timer if it was created.
Disable both copy and move operations.
Definition non_copyable.hpp:75
C7222 course abstractions namespace.
Definition ble.hpp:20
void FreeRtosTimerCallback(void *timer)
Internal use only. This function is invoked as a callback when the FreeRTOS timer expires.
Base classes to control copy/move semantics.