zpp
Zephyr C++20 Framework
zpp::timer< T_ExpireCallback, T_StopCallback > Class Template Reference

timer class with expire and stop callbacks More...

#include <timer.hpp>

Inheritance diagram for zpp::timer< T_ExpireCallback, T_StopCallback >:
[legend]
Collaboration diagram for zpp::timer< T_ExpireCallback, T_StopCallback >:
[legend]

Public Member Functions

 timer ()=delete
 
 timer (T_ExpireCallback ecb, T_StopCallback scb) noexcept
 construct timer with expire and stop callback More...
 
- Public Member Functions inherited from zpp::timer_base
 ~timer_base ()
 Destructor that stops the timer. More...
 
template<class T_Rep1 , class T_Period1 , class T_Rep2 , class T_Period2 >
void start (const std::chrono::duration< T_Rep1, T_Period1 > &duration, const std::chrono::duration< T_Rep2, T_Period2 > &period) noexcept
 Start a timer with duration and period. More...
 
template<class T_Rep , class T_Period >
void start (const std::chrono::duration< T_Rep, T_Period > &duration) noexcept
 Start a single shot timer with duration. More...
 
void stop () noexcept
 Stop the timer. More...
 
auto status () noexcept
 get the timer status More...
 
auto sync () noexcept
 sync with the timer More...
 
std::chrono::nanoseconds remaining_time () noexcept
 Get remaining time. More...
 
auto native_handle () noexcept
 Zephyr native handle. More...
 
 timer_base (const timer_base &)=delete
 
 timer_base (timer_base &&)=delete
 
timer_baseoperator= (const timer_base &)=delete
 
timer_baseoperator= (timer_base &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from zpp::timer_base
 timer_base () noexcept
 

Detailed Description

template<class T_ExpireCallback, class T_StopCallback>
class zpp::timer< T_ExpireCallback, T_StopCallback >

timer class with expire and stop callbacks

Parameters
ExpireCallbackType of the expire callback
StopCallbackType of the stop callback

Definition at line 128 of file timer.hpp.

Constructor & Destructor Documentation

◆ timer() [1/2]

template<class T_ExpireCallback , class T_StopCallback >
zpp::timer< T_ExpireCallback, T_StopCallback >::timer ( )
delete

◆ timer() [2/2]

template<class T_ExpireCallback , class T_StopCallback >
zpp::timer< T_ExpireCallback, T_StopCallback >::timer ( T_ExpireCallback  ecb,
T_StopCallback  scb 
)
inlineexplicitnoexcept

construct timer with expire and stop callback

Parameters
ecbthe expire callback
scbthe stop callbacl

Definition at line 139 of file timer.hpp.

140  : timer_base()
141  , m_expire_callback(ecb)
142  , m_stop_callback(scb)
143  {
144  k_timer_expiry_t ecb_func = [](struct k_timer* t) noexcept {
145  auto self = get_user_data(t);
146  if (self != nullptr) {
147  std::invoke(self->m_expire_callback, self);
148  }
149  };
150 
151  k_timer_stop_t scb_func = [](struct k_timer* t) noexcept {
152  auto self = get_user_data(t);
153  if (self != nullptr) {
154  std::invoke(self->m_stop_callback, self);
155  }
156  };
157 
158  k_timer_init( native_handle(), ecb_func, scb_func);
159  k_timer_user_data_set( native_handle(), this);
160  }
timer_base() noexcept
Definition: timer.hpp:26
auto native_handle() noexcept
Zephyr native handle.
Definition: timer.hpp:108

References zpp::timer_base::native_handle().


The documentation for this class was generated from the following file: