zpp
Zephyr C++20 Framework
zpp::timer_base Class Reference

base class for the timer class More...

#include <timer.hpp>

Inheritance diagram for zpp::timer_base:
[legend]

Public Member Functions

 ~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
 

Protected Member Functions

 timer_base () noexcept
 

Detailed Description

base class for the timer class

Definition at line 24 of file timer.hpp.

Constructor & Destructor Documentation

◆ timer_base() [1/3]

zpp::timer_base::timer_base ( )
inlineprotectednoexcept

Definition at line 26 of file timer.hpp.

27  {
28  }

◆ ~timer_base()

zpp::timer_base::~timer_base ( )
inline

Destructor that stops the timer.

Definition at line 33 of file timer.hpp.

34  {
35  stop();
36  }
void stop() noexcept
Stop the timer.
Definition: timer.hpp:69

References stop().

◆ timer_base() [2/3]

zpp::timer_base::timer_base ( const timer_base )
delete

◆ timer_base() [3/3]

zpp::timer_base::timer_base ( timer_base &&  )
delete

Member Function Documentation

◆ native_handle()

auto zpp::timer_base::native_handle ( )
inlinenoexcept

Zephyr native handle.

Returns
pointer to the k_timer

Definition at line 108 of file timer.hpp.

109  {
110  return &m_timer;
111  }

Referenced by zpp::basic_timer< T_ExpireCallback >::basic_timer(), zpp::sync_timer::sync_timer(), and zpp::timer< T_ExpireCallback, T_StopCallback >::timer().

◆ operator=() [1/2]

timer_base& zpp::timer_base::operator= ( const timer_base )
delete

◆ operator=() [2/2]

timer_base& zpp::timer_base::operator= ( timer_base &&  )
delete

◆ remaining_time()

std::chrono::nanoseconds zpp::timer_base::remaining_time ( )
inlinenoexcept

Get remaining time.

Returns
the remaining time

Definition at line 97 of file timer.hpp.

98  {
99  auto t = k_timer_remaining_ticks(&m_timer);
100  return std::chrono::nanoseconds(k_ticks_to_ns_floor64(t));
101  }

◆ start() [1/2]

template<class T_Rep , class T_Period >
void zpp::timer_base::start ( const std::chrono::duration< T_Rep, T_Period > &  duration)
inlinenoexcept

Start a single shot timer with duration.

Parameters
durationThe timeout

Definition at line 59 of file timer.hpp.

60  {
61  using namespace std::chrono;
62 
63  k_timer_start(&m_timer, to_timeout(duration), K_NO_WAIT);
64  }
constexpr k_timeout_t to_timeout(const std::chrono::duration< T_Rep, T_Period > &d) noexcept
convert a duration to tick
Definition: clock.hpp:88

References zpp::to_timeout().

◆ start() [2/2]

template<class T_Rep1 , class T_Period1 , class T_Rep2 , class T_Period2 >
void zpp::timer_base::start ( const std::chrono::duration< T_Rep1, T_Period1 > &  duration,
const std::chrono::duration< T_Rep2, T_Period2 > &  period 
)
inlinenoexcept

Start a timer with duration and period.

Parameters
durationThe first time out
periodthe time of the repeat period

Definition at line 45 of file timer.hpp.

47  {
48  using namespace std::chrono;
49 
50  k_timer_start(&m_timer, to_timeout(duration), to_timeout(period));
51  }

References zpp::to_timeout().

◆ status()

auto zpp::timer_base::status ( )
inlinenoexcept

get the timer status

Returns
the timer status

Definition at line 79 of file timer.hpp.

80  {
81  return k_timer_status_get(&m_timer);
82  }

◆ stop()

void zpp::timer_base::stop ( )
inlinenoexcept

Stop the timer.

Definition at line 69 of file timer.hpp.

70  {
71  k_timer_stop(&m_timer);
72  }

Referenced by ~timer_base().

◆ sync()

auto zpp::timer_base::sync ( )
inlinenoexcept

sync with the timer

Definition at line 87 of file timer.hpp.

88  {
89  return k_timer_status_sync(&m_timer);
90  }

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