zpp
Zephyr C++20 Framework
zpp::basic_timer< T_ExpireCallback > Class Template Reference

timer class with only an expire callback More...

#include <timer.hpp>

Inheritance diagram for zpp::basic_timer< T_ExpireCallback >:
[legend]
Collaboration diagram for zpp::basic_timer< T_ExpireCallback >:
[legend]

Public Member Functions

 basic_timer ()=delete
 
 basic_timer (T_ExpireCallback ecb) noexcept
 construct timer with an expire 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 zpp::basic_timer< T_ExpireCallback >

timer class with only an expire callback

Parameters
ExpireCallbackType of the expire callback

Definition at line 178 of file timer.hpp.

Constructor & Destructor Documentation

◆ basic_timer() [1/2]

template<class T_ExpireCallback >
zpp::basic_timer< T_ExpireCallback >::basic_timer ( )
delete

◆ basic_timer() [2/2]

template<class T_ExpireCallback >
zpp::basic_timer< T_ExpireCallback >::basic_timer ( T_ExpireCallback  ecb)
inlineexplicitnoexcept

construct timer with an expire callback

Parameters
ecbthe expire callback

Definition at line 188 of file timer.hpp.

189  : timer_base()
190  , m_expire_callback(ecb)
191  {
192  k_timer_expiry_t ecb_func = [](struct k_timer* t) noexcept {
193  auto self = get_user_data(t);
194  if (self != nullptr) {
195  std::invoke(self->m_expire_callback, self);
196  }
197  };
198 
199  k_timer_init( native_handle(), ecb_func, nullptr);
200  k_timer_user_data_set( native_handle(), this);
201  }
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: