SuperTinyKernel™ RTOS 1.06.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk_c_time.cpp File Reference
#include <cstddef>
#include "stk.h"
#include "memory/stk_memory.h"
#include "stk_c.h"
#include "stk_c_time.h"
#include "time/stk_time.h"
Include dependency graph for stk_c_time.cpp:

Go to the source code of this file.

Classes

class  CTimerWrapper
struct  stk_timer_t
struct  TimerSlot
struct  stk_timerhost_t
struct  stk_periodic_trigger_t

Namespaces

namespace  stk
 Namespace of STK package.
namespace  stk::interop_c_helper

Macros

#define STK_C_TIMERS_TOTAL   (STK_C_TIMER_MAX * STK_C_CPU_COUNT)
#define STK_TIMER_COUNT_MAX   (STK_C_TIMER_MAX)
#define STK_TIMER_HANDLER_STACK_SIZE   (STK_C_TIMER_HANDLER_STACK_SIZE)

Functions

static __stk_forceinline stk_timer_tCastCppTimerWrapperToC (CTimerWrapper *const t)
void stk::interop_c_helper::InitializeTimerHost (stk_kernel_t *kernel, stk::time::TimerHost *th, EAccessMode amode)
stk_timerhost_tstk_timerhost_get (uint8_t core_nr)
 Obtain the pre-allocated TimerHost for the given CPU core.
void stk_timerhost_init (stk_timerhost_t *host, stk_kernel_t *kernel, bool privileged)
 Initialize the TimerHost and register its internal tasks with the kernel.
bool stk_timerhost_shutdown (stk_timerhost_t *host)
 Gracefully shut down the TimerHost.
bool stk_timerhost_is_empty (const stk_timerhost_t *host)
 Return true when no timers are currently active on this host.
size_t stk_timerhost_get_size (const stk_timerhost_t *host)
 Return the number of currently active timers on this host.
int64_t stk_timerhost_get_time_now (const stk_timerhost_t *host)
 Return the last tick count snapshot maintained by the host's tick task.
stk_timer_tstk_timer_create (stk_timer_callback_t callback, void *user_data)
 Allocate a timer from the static pool.
void stk_timer_destroy (stk_timer_t *tmr)
 Return a timer handle back to the static pool.
bool stk_timer_start (stk_timerhost_t *host, stk_timer_t *tmr, uint32_t delay, uint32_t period)
 Start a timer.
bool stk_timer_stop (stk_timerhost_t *host, stk_timer_t *tmr)
 Stop a running timer.
bool stk_timer_reset (stk_timerhost_t *host, stk_timer_t *tmr)
 Reset a periodic timer's deadline (re-arm from now).
bool stk_timer_restart (stk_timerhost_t *host, stk_timer_t *tmr, uint32_t delay, uint32_t period)
 Atomically stop and re-start a timer.
bool stk_timer_start_or_reset (stk_timerhost_t *host, stk_timer_t *tmr, uint32_t delay, uint32_t period_ticks)
 Start the timer if inactive, or reset its deadline if already active and periodic.
bool stk_timer_set_period (stk_timerhost_t *host, stk_timer_t *tmr, uint32_t period_ticks)
 Change the period of a running periodic timer without affecting the current deadline.
bool stk_timer_is_active (const stk_timer_t *tmr)
 Check whether a timer is currently active (started and not yet expired/stopped).
uint32_t stk_timer_get_period (const stk_timer_t *tmr)
 Get the timer's reload period.
int64_t stk_timer_get_deadline (const stk_timer_t *tmr)
 Get the absolute expiration tick count of the timer's next deadline.
int64_t stk_timer_get_timestamp (const stk_timer_t *tmr)
 Get the tick count at which the timer last expired.
uint32_t stk_timer_get_remaining_ticks (const stk_timer_t *tmr)
 Get remaining ticks until next expiration.
stk_periodic_trigger_tstk_periodic_trigger_create (stk_periodic_trigger_mem_t *const membuf, uint32_t membuf_size, uint32_t period_ticks, bool started)
 Construct PeriodicTrigger instance in the supplied memory buffer.
void stk_periodic_trigger_destroy (stk_periodic_trigger_t *const trig)
 Destroy instance (calls the C++ destructor in-place).
bool stk_periodic_trigger_poll (stk_periodic_trigger_t *trig)
 Check whether the scheduled trigger time has been reached.
void stk_periodic_trigger_set_period (stk_periodic_trigger_t *trig, uint32_t period_ticks)
 Change the trigger period while preserving phase.
void stk_periodic_trigger_restart (stk_periodic_trigger_t *trig)
 Reset and start the trigger from the current tick count.
uint32_t stk_periodic_trigger_get_period (const stk_periodic_trigger_t *trig)
 Get currently configured trigger period.

Variables

static struct TimerSlot s_Timers [(STK_C_TIMER_MAX *STK_C_CPU_COUNT)]
static stk_timerhost_t s_TimerHosts [STK_C_CPU_COUNT]

Macro Definition Documentation

◆ STK_C_TIMERS_TOTAL

#define STK_C_TIMERS_TOTAL   (STK_C_TIMER_MAX * STK_C_CPU_COUNT)

Definition at line 18 of file stk_c_time.cpp.

Referenced by stk_timer_create(), and stk_timer_destroy().

◆ STK_TIMER_COUNT_MAX

#define STK_TIMER_COUNT_MAX   (STK_C_TIMER_MAX)

Definition at line 22 of file stk_c_time.cpp.

◆ STK_TIMER_HANDLER_STACK_SIZE

#define STK_TIMER_HANDLER_STACK_SIZE   (STK_C_TIMER_HANDLER_STACK_SIZE)

Definition at line 25 of file stk_c_time.cpp.

Function Documentation

◆ CastCppTimerWrapperToC()

__stk_forceinline stk_timer_t * CastCppTimerWrapperToC ( CTimerWrapper *const t)
static

Definition at line 80 of file stk_c_time.cpp.

81{
82 return reinterpret_cast<stk_timer_t *>(reinterpret_cast<void *>(t));
83}

References __stk_forceinline.

Referenced by CTimerWrapper::OnExpired().

Here is the caller graph for this function:

Variable Documentation

◆ s_TimerHosts

stk_timerhost_t s_TimerHosts[STK_C_CPU_COUNT]
static

Definition at line 130 of file stk_c_time.cpp.

Referenced by stk_timerhost_get().

◆ s_Timers

struct TimerSlot s_Timers[ (STK_C_TIMER_MAX * STK_C_CPU_COUNT) ]
static