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::PlatformArmCortexM Class Referencefinal

Concrete implementation of IPlatform driver for the Arm Cortex-M0, M3, M4, M7 processors. More...

#include <stk_arch_arm-cortex-m.h>

Inheritance diagram for stk::PlatformArmCortexM:
Collaboration diagram for stk::PlatformArmCortexM:

Public Member Functions

 ~PlatformArmCortexM ()=default
 Destructor.
void Initialize (IEventHandler *event_handler, IKernelService *service, uint32_t resolution_us, Stack *exit_trap) override
 Initialize scheduler's context.
void Start () override
 Start scheduling.
void Stop () override
 Stop scheduling.
void InitStack (EStackType stack_type, Stack *stack, IStackMemory *stack_memory, ITask *user_task) override
 Initialize stack memory of the user task.
uint32_t GetTickResolution () const override
 Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds between system tick timer ISRs.
Cycles GetSysTimerCount () const override
 Get system timer count value.
uint32_t GetSysTimerFrequency () const override
 Get system timer frequency.
void SwitchToNext () override
 Switch to a next task.
void Sleep (Timeout ticks) override
 Put calling process into a sleep state.
bool SleepUntil (Ticks timestamp) override
 Put calling process into a sleep state until the specified timestamp.
IWaitObjectWait (ISyncObject *sync_obj, IMutex *mutex, Timeout timeout) override
 Put calling process into a waiting state until synchronization object is signaled or timeout occurs.
void ProcessTick () override
 Process one tick.
void ProcessHardFault () override
 Cause a hard fault of the system.
void SetEventOverrider (IEventOverrider *overrider) override
 Set platform event overrider.
Word GetCallerSP () const override
 Get caller's Stack Pointer (SP).
TId GetTid () const override
 Get thread Id.
Timeout Suspend () override
 Suspend scheduling.
void Resume (Timeout elapsed_ticks) override
 Resume scheduling after a prior Suspend() call.

Detailed Description

Concrete implementation of IPlatform driver for the Arm Cortex-M0, M3, M4, M7 processors.

Definition at line 24 of file stk_arch_arm-cortex-m.h.

Constructor & Destructor Documentation

◆ ~PlatformArmCortexM()

stk::PlatformArmCortexM::~PlatformArmCortexM ( )
default

Destructor.

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

References STK_VIRT_DTOR.

Member Function Documentation

◆ GetCallerSP()

Word stk::PlatformArmCortexM::GetCallerSP ( ) const
overridevirtual

Get caller's Stack Pointer (SP).

Note
Valid for a Thread process only.
Returns
Current value of the Stack Pointer (SP) of the calling process.

Implements stk::IPlatform.

◆ GetSysTimerCount()

Cycles stk::PlatformArmCortexM::GetSysTimerCount ( ) const
overridevirtual

Get system timer count value.

Note
ISR-safe.
Returns
64-bit count value.

Implements stk::IPlatform.

◆ GetSysTimerFrequency()

uint32_t stk::PlatformArmCortexM::GetSysTimerFrequency ( ) const
overridevirtual

Get system timer frequency.

Note
ISR-safe.
Returns
Frequency (Hz).

Implements stk::IPlatform.

◆ GetTickResolution()

uint32_t stk::PlatformArmCortexM::GetTickResolution ( ) const
overridevirtual

Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds between system tick timer ISRs.

Returns
Microseconds.

Implements stk::IPlatform.

◆ GetTid()

TId stk::PlatformArmCortexM::GetTid ( ) const
overridevirtual

Get thread Id.

Returns
Thread Id.
Warning
ISR-safe.
See also
TID_ISR_N, TID_NONE, IsIsrTid

Implements stk::IPlatform.

◆ Initialize()

void stk::PlatformArmCortexM::Initialize ( IEventHandler * event_handler,
IKernelService * service,
uint32_t resolution_us,
Stack * exit_trap )
overridevirtual

Initialize scheduler's context.

Parameters
[in]event_handlerEvent handler.
[in]serviceKernel service.
[in]resolution_usTick resolution in microseconds (for example 1000 equals to 1 millisecond resolution).
[in]exit_trapStack of the Exit trap (optional, provided if kernel is operating in KERNEL_DYNAMIC mode).
Note
Must be called once before Start().

Implements stk::IPlatform.

◆ InitStack()

void stk::PlatformArmCortexM::InitStack ( EStackType stack_type,
Stack * stack,
IStackMemory * stack_memory,
ITask * user_task )
overridevirtual

Initialize stack memory of the user task.

Parameters
[in]stack_typeStack type.
[in]stackStack descriptor.
[in]stack_memoryStack memory.
[in]user_taskUser task to which Stack belongs.

Implements stk::IPlatform.

◆ ProcessHardFault()

void stk::PlatformArmCortexM::ProcessHardFault ( )
overridevirtual

Cause a hard fault of the system.

Note
Normally called by the Kernel when one of the scheduled tasks missed its deadline (see stk::KERNEL_HRT).

Implements stk::IPlatform.

◆ ProcessTick()

void stk::PlatformArmCortexM::ProcessTick ( )
overridevirtual

Process one tick.

Note
Normally system tick is processed by the platform driver implementation. In case system tick handler is used by the application and should not be implemented by the driver then disable driver's handler in stk_config.h like this:
#define STK_SYSTICK_HANDLER _STK_SYSTICK_HANDLER_DISABLE
and then call ProcessTick() from your custom tick handler.

Implements stk::IPlatform.

◆ Resume()

void stk::PlatformArmCortexM::Resume ( Timeout elapsed_ticks)
overridevirtual

Resume scheduling after a prior Suspend() call.

Parameters
[in]elapsed_ticksNumber of ticks that elapsed during the suspended period. The kernel uses this value to advance internal time counters.
Note
ISR-safe.

Implements stk::IPlatform.

◆ SetEventOverrider()

void stk::PlatformArmCortexM::SetEventOverrider ( IEventOverrider * overrider)
overridevirtual

Set platform event overrider.

Note
Must be set prior call to IKernel::Start.
Parameters
[in]overriderPlatform event overrider.

Implements stk::IPlatform.

◆ Sleep()

void stk::PlatformArmCortexM::Sleep ( Timeout ticks)
overridevirtual

Put calling process into a sleep state.

Note
Unlike Delay this function does not waste CPU cycles and allows kernel to put CPU into a low-power state.
Parameters
[in]ticksTime to sleep (ticks).

Implements stk::IPlatform.

◆ SleepUntil()

bool stk::PlatformArmCortexM::SleepUntil ( Ticks timestamp)
overridevirtual

Put calling process into a sleep state until the specified timestamp.

Note
Unlike Delay this function does not waste CPU cycles and allows kernel to put CPU into a low-power state.
Unsupported in HRT mode (see stk::KERNEL_HRT); in HRT mode tasks sleep automatically according to their periodicity and workload.
Parameters
[in]timestampAbsolute timestamp (ticks).
Warning
ISR-unsafe. Calling from an ISR context is not permitted and will trigger an assertion.
Returns
True if sleep succeeded, false otherwise.

Implements stk::IPlatform.

◆ Start()

void stk::PlatformArmCortexM::Start ( )
overridevirtual

Start scheduling.

Note
This function never returns if kernel is initialized as KERNEL_STATIC. Must be called after Initialize().

Implements stk::IPlatform.

◆ Stop()

void stk::PlatformArmCortexM::Stop ( )
overridevirtual

Stop scheduling.

Implements stk::IPlatform.

◆ Suspend()

Timeout stk::PlatformArmCortexM::Suspend ( )
overridevirtual

Suspend scheduling.

Returns
Number of ticks available for the suspension period, as determined by the nearest pending wake-up. The caller may use this value to program a hardware timer for the tickless sleep interval.
Note
ISR-safe. Pair with Resume().

Implements stk::IPlatform.

◆ SwitchToNext()

void stk::PlatformArmCortexM::SwitchToNext ( )
overridevirtual

Switch to a next task.

Implements stk::IPlatform.

◆ Wait()

IWaitObject * stk::PlatformArmCortexM::Wait ( ISyncObject * sobj,
IMutex * mutex,
Timeout timeout )
overridevirtual

Put calling process into a waiting state until synchronization object is signaled or timeout occurs.

Note
This function implements core blocking logic using the Monitor pattern to ensure atomicity between state check and suspension.
The kernel automatically unlocks the provided mutex before the task is suspended and re-locks it before this function returns.
Parameters
[in]sobjSynchronization object to wait on.
[in]mutexMutex protecting the state of the synchronization object.
[in]timeoutMaximum wait time (ticks). Use WAIT_INFINITE to block indefinitely, use NO_WAIT to poll without blocking.
Returns
Pointer to the wait object representing this wait operation (always non-NULL). The caller must check IWaitObject::IsTimeout() after this function returns to determine whether the wake was caused by a signal or by timeout expiry. The returned pointer is valid until the calling task re-enters a wait or the wait object is explicitly released by the kernel. The return value is guaranteed non nullptr and points to a valid IWaitObject.
Warning
ISR-unsafe.

Implements stk::IPlatform.


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