SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
EventOverrider Class Referencefinal
Inheritance diagram for EventOverrider:
Collaboration diagram for EventOverrider:

Public Member Functions

 EventOverrider ()
 ~EventOverrider ()=default
 Destructor.
void SetCallback (stk_event_overrider_t *c)
 Bind or unbind a C-level overrider struct.
bool IsActive () const
 Returns true when a C-level struct is currently bound.
bool OnSleep (Timeout sleep_ticks) override
 Called by the Kernel when it is entering a sleep mode.
bool OnHardFault () override
 Called by Kernel when hard fault happens.
virtual bool OnException (EHwException exc_id, TId tid, const struct FaultContext *const ctx)
 Called by the platform driver during initialization to obtain global, application-defined MPU configurations.

Private Attributes

stk_event_overrider_tm_cb

Detailed Description

Definition at line 160 of file stk_c.cpp.

Constructor & Destructor Documentation

◆ EventOverrider()

EventOverrider::EventOverrider ( )
inline

Definition at line 163 of file stk_c.cpp.

163 : m_cb(nullptr)
164 {}
stk_event_overrider_t * m_cb
Definition stk_c.cpp:206

References m_cb.

◆ ~EventOverrider()

EventOverrider::~EventOverrider ( )
default

Destructor.

Note
MISRA deviation: [STK-DEV-005] Rule 10-3-2.

References STK_VIRT_DTOR.

Member Function Documentation

◆ IsActive()

bool EventOverrider::IsActive ( ) const
inline

Returns true when a C-level struct is currently bound.

Definition at line 179 of file stk_c.cpp.

179{ return (m_cb != nullptr); }

References m_cb.

◆ OnException()

virtual bool stk::IPlatform::IEventOverrider::OnException ( EHwException exc_id,
TId tid,
const struct FaultContext *const ctx )
inlinevirtualinherited

Called by the platform driver during initialization to obtain global, application-defined MPU configurations.

Allows user-space code to configure custom MPU regions (e.g., shared data/code sections or peripheral blocks) and enable state at system startup. Unlike per-task MPU regions set via ITask::GetMpuRegions(), configurations returned by this callback apply globally across the platform driver.

Returns
Pointer to a constant MpuConfig structure encapsulating global region descriptors and enable state, or nullptr if no custom global MPU configuration is supplied.
Note
Optional. The default implementation returns nullptr.
The underlying MpuConfig instance referenced by the returned pointer must remain valid for the duration of platform initialization (e.g., point to a static instance).
See also
MpuConfig, ITask::GetMpuRegions

Called by platform driver when hardware exception occurred.

Parameters
[in]exc_idHardware exception id, see EHwException.
[in]tidTId of the currently active task.
[in]ctxFaultContext which includes hardware exception frame captured at fault entry (see hw::ExceptionFrame). PC is the true faulting instruction address; may be nullptr if unavailable.
Returns
True if event is handled otherwise False to let driver handle it.
See also
EHwException

Definition at line 1124 of file stk_common.h.

1125 {
1126 STK_UNUSED(exc_id);
1127 STK_UNUSED(tid);
1128 STK_UNUSED(ctx);
1129 return false;
1130 }
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:715

References STK_UNUSED.

◆ OnHardFault()

bool EventOverrider::OnHardFault ( )
inlineoverridevirtual

Called by Kernel when hard fault happens.

Note
Normally called by Kernel when one of the scheduled tasks missed its deadline (see stk::KERNEL_HRT, IPlatform::HardFault).
Returns
True if event is handled otherwise False to let driver handle it.

Reimplemented from stk::IPlatform::IEventOverrider.

Definition at line 193 of file stk_c.cpp.

194 {
195 bool is_handled = false;
196
197 if ((m_cb != nullptr) && (m_cb->on_hard_fault != nullptr))
198 {
199 is_handled = m_cb->on_hard_fault(m_cb->user_data);
200 }
201
202 return is_handled;
203 }

References m_cb.

◆ OnSleep()

bool EventOverrider::OnSleep ( Timeout sleep_ticks)
inlineoverridevirtual

Called by the Kernel when it is entering a sleep mode.

Returns
True if event is handled otherwise False to let driver handle it.

Reimplemented from stk::IPlatform::IEventOverrider.

Definition at line 182 of file stk_c.cpp.

183 {
184 bool is_handled = false;
185
186 if ((m_cb != nullptr) && (m_cb->on_sleep != nullptr))
187 {
188 is_handled = m_cb->on_sleep(static_cast<stk_timeout_t>(sleep_ticks), m_cb->user_data);
189 }
190
191 return is_handled;
192 }
int32_t stk_timeout_t
Timeout value.
Definition stk_c.h:113

References m_cb.

◆ SetCallback()

void EventOverrider::SetCallback ( stk_event_overrider_t * c)
inline

Bind or unbind a C-level overrider struct.

Parameters
[in]cPointer to a caller-owned stk_event_overrider_t, or nullptr to deactivate this wrapper.

Definition at line 175 of file stk_c.cpp.

175{ m_cb = c; }

References m_cb.

Member Data Documentation

◆ m_cb

stk_event_overrider_t* EventOverrider::m_cb
private

Definition at line 206 of file stk_c.cpp.

Referenced by EventOverrider(), IsActive(), OnHardFault(), OnSleep(), and SetCallback().


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