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
NonSecureLedTask< _AccessMode > Class Template Reference
Inheritance diagram for NonSecureLedTask< _AccessMode >:
Collaboration diagram for NonSecureLedTask< _AccessMode >:

Public Types

enum  

Public Member Functions

 NonSecureLedTask (uint8_t task_id, stk::Word *stack, size_t stack_size)
stk::EAccessMode GetAccessMode () const override
 Get pointer to the stack memory.
const stk::Word * GetStack () const override
 Get pointer to the stack memory.
size_t GetStackSize () const override
 Get number of elements of the stack memory array.
 NonSecureLedTask (uint8_t task_id)
 NonSecureLedTask (uint8_t task_id, stk::Word *stack, size_t stack_size, stk::EAccessMode mode)
stk::EAccessMode GetAccessMode () const override
 Get pointer to the stack memory.
const stk::Word * GetStack () const override
 Get pointer to the stack memory.
size_t GetStackSize () const override
 Get number of elements of the stack memory array.
virtual void OnDeadlineMissed (uint32_t duration)
 Called by the scheduler if deadline of the task is missed when Kernel is operating in Hard Real-Time mode (see stk::KERNEL_HRT).
virtual void OnExit ()
 Called by the kernel before removal from the scheduling (see stk::KERNEL_DYNAMIC).
virtual Weight GetWeight () const
 Get static base weight of the task.
virtual Timeout GetTimeSlice () const
 Get time-slice quantum of the task (ticks). KERNEL_TIMESLICE only.
virtual const char * GetTraceName () const
 Get task trace name set by application.
virtual size_t GetStackSpace () const
 Get available stack space.
TId GetTid () const

Private Member Functions

void Run () override
 Entry point of the user task.
void Run () override
 Entry point of the user task.
const stk::MpuRegionList * GetMpuRegions () const override
void Run () override
 Entry point of the user task.

Private Attributes

uint8_t m_task_id
uint32_t m_my_flag
uint32_t m_next_flag
stk::Word * m_stack
 pointer to stack buffer
size_t m_stack_size
 stack size in words
stk::EAccessMode m_mode
 kernel access mode

Detailed Description

template<stk::EAccessMode _AccessMode>
class NonSecureLedTask< _AccessMode >
Examples
blinky_mpu-hard/example.cpp, blinky_mpu/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 211 of file blinky_mpu-hard/example.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Definition at line 100 of file stk_helper.h.

Partial implementation of the user task.
Definition stk_helper.h:98

Constructor & Destructor Documentation

◆ NonSecureLedTask() [1/3]

template<stk::EAccessMode _AccessMode>
NonSecureLedTask< _AccessMode >::NonSecureLedTask ( uint8_t task_id,
stk::Word * stack,
size_t stack_size )
inlineexplicit

◆ NonSecureLedTask() [2/3]

template<stk::EAccessMode _AccessMode>
NonSecureLedTask< _AccessMode >::NonSecureLedTask ( uint8_t task_id)
inlineexplicit

Definition at line 233 of file blinky_mpu/example.cpp.

References FLAGS_ALL, LED_MAX, m_my_flag, m_next_flag, and m_task_id.

◆ NonSecureLedTask() [3/3]

template<stk::EAccessMode _AccessMode>
NonSecureLedTask< _AccessMode >::NonSecureLedTask ( uint8_t task_id,
stk::Word * stack,
size_t stack_size,
stk::EAccessMode mode )
inlineexplicit

Definition at line 160 of file blinky_mpu_armv8/example.cpp.

164 m_stack(stack),
166 m_mode(mode)
167 {}
stk::EAccessMode m_mode
kernel access mode

References FLAGS_ALL, LED_MAX, m_mode, m_my_flag, m_next_flag, m_stack, m_stack_size, and m_task_id.

Member Function Documentation

◆ GetAccessMode() [1/2]

template<stk::EAccessMode _AccessMode>
stk::EAccessMode NonSecureLedTask< _AccessMode >::GetAccessMode ( ) const
inlineoverridevirtual

Get pointer to the stack memory.

Note
Optional. ARM TrustZone only.
Returns
Pointer to the Secure stack memory.

Get up to (STK_MPU_TASK_REGIONS - 1) application-defined MPU regions for this task.

When STK_MPU_STACK_GUARD is enabled, each task owns STK_MPU_TASK_REGIONS (2, 4, 6, 8, 12 or 16, see STK_MPU_TASK_REGIONS) hardware MPU region slots. Slot 0 is always the automatic stack guard, computed by the driver from the task's own stack memory (see IStackMemory::GetStack/GetStackSize). This hook supplies the remaining STK_MPU_TASK_REGIONS-1 slots, letting an application additionally sandbox a task to e.g. a private data buffer, a specific peripheral block, or a shared IPC region - on top of its stack guard.

Returns
Pointer to a constant MpuRegionList containing up to (STK_MPU_TASK_REGIONS - 1) region descriptors, or nullptr if no extra task regions are configured. Array element i is applied at task-relative region index i +1 (i.e. the slots following the stack guard).
Note
Optional. Only consulted when STK_MPU_STACK_GUARD is enabled; a no-op on platforms/builds without MPU stack-guard support.
Read once, when the task is bound via Kernel::AddTask() (through IPlatform::InitStack()), not re-evaluated on every context switch. The underlying MpuRegionList instance referenced by the returned pointer must remain valid (e.g. a static const instance); a stack-local temporary is invalid once this function returns.
Warning
An element count greater than (STK_MPU_TASK_REGIONS - 1) is clamped by the driver (STK_ASSERT fires in debug builds); only the first STK_MPU_TASK_REGIONS-1 entries are ever applied.
class MyTask : public stk::Task<256, stk::ACCESS_USER>
{
static constexpr stk::MpuRegionConfig s_extra_regions[] =
{
{ .addr = MY_BUFFER_ADDR, .size = MY_BUFFER_SIZE,
.access_perm = stk::hw::mpu::ACCESS_FULL,
.mem_type = stk::hw::mpu::TYPE_NORMAL_CACHEABLE,
.exec = stk::hw::mpu::EXEC_NEVER },
};
const stk::MpuRegionList *GetMpuRegions() const override
{
static const stk::MpuRegionList mpu_regions(s_extra_regions, 1U);
return &mpu_regions;
}
void Run() override { ... }
};
See also
TaskMpu::Configure, IPlatform::InitStack, MpuRegionList

Get hardware access mode of the user task.

Implements stk::ITask.

Examples
blinky_mpu-hard/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 230 of file blinky_mpu-hard/example.cpp.

230{ return stk::ACCESS_USER; }

References stk::ACCESS_USER.

◆ GetAccessMode() [2/2]

template<stk::EAccessMode _AccessMode>
stk::EAccessMode NonSecureLedTask< _AccessMode >::GetAccessMode ( ) const
inlineoverridevirtual

Get pointer to the stack memory.

Note
Optional. ARM TrustZone only.
Returns
Pointer to the Secure stack memory.

Get up to (STK_MPU_TASK_REGIONS - 1) application-defined MPU regions for this task.

When STK_MPU_STACK_GUARD is enabled, each task owns STK_MPU_TASK_REGIONS (2, 4, 6, 8, 12 or 16, see STK_MPU_TASK_REGIONS) hardware MPU region slots. Slot 0 is always the automatic stack guard, computed by the driver from the task's own stack memory (see IStackMemory::GetStack/GetStackSize). This hook supplies the remaining STK_MPU_TASK_REGIONS-1 slots, letting an application additionally sandbox a task to e.g. a private data buffer, a specific peripheral block, or a shared IPC region - on top of its stack guard.

Returns
Pointer to a constant MpuRegionList containing up to (STK_MPU_TASK_REGIONS - 1) region descriptors, or nullptr if no extra task regions are configured. Array element i is applied at task-relative region index i +1 (i.e. the slots following the stack guard).
Note
Optional. Only consulted when STK_MPU_STACK_GUARD is enabled; a no-op on platforms/builds without MPU stack-guard support.
Read once, when the task is bound via Kernel::AddTask() (through IPlatform::InitStack()), not re-evaluated on every context switch. The underlying MpuRegionList instance referenced by the returned pointer must remain valid (e.g. a static const instance); a stack-local temporary is invalid once this function returns.
Warning
An element count greater than (STK_MPU_TASK_REGIONS - 1) is clamped by the driver (STK_ASSERT fires in debug builds); only the first STK_MPU_TASK_REGIONS-1 entries are ever applied.
class MyTask : public stk::Task<256, stk::ACCESS_USER>
{
static constexpr stk::MpuRegionConfig s_extra_regions[] =
{
{ .addr = MY_BUFFER_ADDR, .size = MY_BUFFER_SIZE,
.access_perm = stk::hw::mpu::ACCESS_FULL,
.mem_type = stk::hw::mpu::TYPE_NORMAL_CACHEABLE,
.exec = stk::hw::mpu::EXEC_NEVER },
};
const stk::MpuRegionList *GetMpuRegions() const override
{
static const stk::MpuRegionList mpu_regions(s_extra_regions, 1U);
return &mpu_regions;
}
void Run() override { ... }
};
See also
TaskMpu::Configure, IPlatform::InitStack, MpuRegionList

Get hardware access mode of the user task.

Implements stk::ITask.

Definition at line 170 of file blinky_mpu_armv8/example.cpp.

170{ return m_mode; }

References m_mode.

◆ GetMpuRegions()

template<stk::EAccessMode _AccessMode>
const stk::MpuRegionList * NonSecureLedTask< _AccessMode >::GetMpuRegions ( ) const
inlineoverrideprivate
Examples
blinky_mpu-hard/example.cpp, blinky_mpu/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 282 of file blinky_mpu/example.cpp.

283 {
284 using namespace stk;
285 using namespace stk::hw::mpu;
286
287 // leave last slot for a stack protector
289
290 // on every context switch global regions will be re-programmed which is
291 // a defensive measure if compromised task escalated to Privileged and
292 // attempted to modify MPU regions
293 if (STK_MPU_TASK_REGIONS == 8)
294 {
296 for (size_t i = 0; i < global_mpu.GetSize(); ++i)
297 {
299 }
300 }
301
302 // allow access to self
303 const MpuRegionConfig self =
304 {
305 .addr = hw::PtrToWord(this), // 'this'
306 .size = TASK_MEMORY_SIZE, // cover whole allocated region of the task instance
307 .access_perm = hw::mpu::ACCESS_FULL,
309 .share = hw::mpu::SHARE_NON,
310 .exec = hw::mpu::EXEC_NEVER
311 };
313
314 static const stk::MpuRegionList mpu_regions(
316
317 return &mpu_regions;
318 }
#define STK_STATIC_ARRAY_SIZE(ARRAY)
Get size of the static array.
Definition stk_defs.h:742
static stk::MpuRegionList GetGlobalMpuRegions()

References GetGlobalMpuRegions(), stk::hw::PtrToWord(), STK_MPU_TASK_REGIONS, STK_STATIC_ARRAY_SIZE, and TASK_MEMORY_SIZE.

Here is the call graph for this function:

◆ GetStack() [1/2]

template<stk::EAccessMode _AccessMode>
const stk::Word * NonSecureLedTask< _AccessMode >::GetStack ( ) const
inlineoverridevirtual

Get pointer to the stack memory.

Implements stk::IStackMemory.

Examples
blinky_mpu-hard/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 233 of file blinky_mpu-hard/example.cpp.

233{ return m_stack; }

References m_stack.

◆ GetStack() [2/2]

template<stk::EAccessMode _AccessMode>
const stk::Word * NonSecureLedTask< _AccessMode >::GetStack ( ) const
inlineoverridevirtual

Get pointer to the stack memory.

Implements stk::IStackMemory.

Definition at line 173 of file blinky_mpu_armv8/example.cpp.

173{ return m_stack; }

References m_stack.

◆ GetStackSize() [1/2]

template<stk::EAccessMode _AccessMode>
size_t NonSecureLedTask< _AccessMode >::GetStackSize ( ) const
inlineoverridevirtual

Get number of elements of the stack memory array.

Implements stk::IStackMemory.

Examples
blinky_mpu-hard/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 234 of file blinky_mpu-hard/example.cpp.

234{ return m_stack_size; }

References m_stack_size.

◆ GetStackSize() [2/2]

template<stk::EAccessMode _AccessMode>
size_t NonSecureLedTask< _AccessMode >::GetStackSize ( ) const
inlineoverridevirtual

Get number of elements of the stack memory array.

Implements stk::IStackMemory.

Definition at line 174 of file blinky_mpu_armv8/example.cpp.

174{ return m_stack_size; }

References m_stack_size.

◆ GetStackSpace()

virtual size_t stk::IStackMemory::GetStackSpace ( ) const
inlinevirtualinherited

Get available stack space.

Returns
Number of elements of the stack memory array remaining on the stack (computed via the watermark pattern). Returns 0 if the stack has been fully used or the watermark STK_STACK_MEMORY_FILLER was overwritten.
Warning
Stack type: Bottom to Top (index[0]).

Definition at line 511 of file stk_common.h.

512 {
513 const ArrayView<const Word> stack(GetStack(), GetStackSize());
514 const size_t total_size = stack.GetSize();
515 size_t space = 0U;
516
517 for (size_t i = 0U; i < total_size; ++i)
518 {
519 if (stack[i] == STK_STACK_MEMORY_FILLER)
520 {
521 space = i + 1U;
522 }
523 else
524 {
525 break; // terminate loop as soon as watermark ends
526 }
527 }
528
529 return space;
530 }
#define STK_STACK_MEMORY_FILLER
Sentinel value written to the entire stack region at initialization (stack watermark pattern).
Definition stk_defs.h:570
virtual size_t GetStackSize() const =0
Get number of elements of the stack memory array.
virtual const Word * GetStack() const =0
Get pointer to the stack memory.

References stk::ArrayView< T >::GetSize(), GetStack(), GetStackSize(), and STK_STACK_MEMORY_FILLER.

Here is the call graph for this function:

◆ GetTid()

TId stk::Task< _StackSize, _AccessMode >::GetTid ( ) const
inlineinherited

Definition at line 106 of file stk_helper.h.

106{ return GetTidFromUserTask(this); }
TId GetTidFromUserTask(const ITask *task) noexcept
Get task identifier from ITask instance.
Definition stk_arch.h:775

◆ GetTimeSlice()

virtual Timeout stk::ITask::GetTimeSlice ( ) const
inlinevirtualinherited

Get time-slice quantum of the task (ticks). KERNEL_TIMESLICE only.

Returns
Number of ticks the task may run before being rotated behind its same-priority peers, or NO_TIME_SLICE (default) to run until it blocks, yields or is preempted.
Note
Read once when the task is bound by Kernel::AddTask(). Use IKernelService::SetTimeSlice() to change it at run-time.
See also
stk::KERNEL_TIMESLICE, IKernelService::SetTimeSlice

Reimplemented in LedTaskT< _AccessMode >, and LedTaskT< stk::ACCESS_PRIVILEGED >.

Definition at line 1006 of file stk_common.h.

1006{ return NO_TIME_SLICE; }
static constexpr Timeout NO_TIME_SLICE
Time-slice quantum value: no time-slicing for the task (it runs until it blocks, yields or is preempt...
Definition stk_common.h:296

References stk::NO_TIME_SLICE.

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::Bind().

Here is the caller graph for this function:

◆ GetTraceName()

virtual const char * stk::ITask::GetTraceName ( ) const
inlinevirtualinherited

Get task trace name set by application.

Returns
Null-terminated name string, or NULL if unused.
Note
Used for debugging and tracing only (e.g. SEGGER SystemView). Kernel does not interpret this value.

Reimplemented in AudioIsrTask, BlinkyTask, cy_stk_thread, LedTask< _Priority, _AccessMode >, LogTask< _AccessMode >, stk::pthread::PthreadTask, stk::pthread::ReaperTask, stk::time::TimerHost::TimerWorkerTask, and UsbDeviceTask.

Definition at line 1013 of file stk_common.h.

1013{ return nullptr; }

◆ GetWeight()

virtual Weight stk::ITask::GetWeight ( ) const
inlinevirtualinherited

Get static base weight of the task.

Returns
Static weight value of the task (must be positive, the valid range is defined by the strategy).
See also
sched::SwitchStrategyFixedPriority, sched::SwitchStrategySmoothWeightedRoundRobin, IKernelTask::GetWeight, IKernelService::InheritWeight, IKernelService::RestoreWeight

Reimplemented in AudioIsrTask, BlinkyTask, cy_stk_thread, LedTaskT< _AccessMode >, LedTaskT< stk::ACCESS_PRIVILEGED >, stk::pthread::PthreadTask, stk::pthread::ReaperTask, stk::TaskW< _Weight, _StackSize, _AccessMode >, stk::TaskW< _Priority, TASK_STACK_SIZE, _AccessMode >, stk::TaskW< _Weight, TASK_STACK_SIZE, _AccessMode >, stk::time::TimerHost::TimerWorkerTask, and UsbDeviceTask.

Definition at line 997 of file stk_common.h.

997{ return DEFAULT_WEIGHT; }
static constexpr Weight DEFAULT_WEIGHT
Weight value: default weight of value (1) (see SwitchStrategySmoothWeightedRoundRobin).
Definition stk_common.h:290

References stk::DEFAULT_WEIGHT.

Referenced by stk::ISyncObject::FindWeightHigherThan().

Here is the caller graph for this function:

◆ OnDeadlineMissed()

virtual void stk::ITask::OnDeadlineMissed ( uint32_t duration)
inlinevirtualinherited

Called by the scheduler if deadline of the task is missed when Kernel is operating in Hard Real-Time mode (see stk::KERNEL_HRT).

Parameters
[in]durationElapsed active time in ticks at the point the deadline was detected. Always greater than the task's configured deadline (ticks).
Note
Optional handler. Use it for fault logging.
After this call returns, IPlatform::ProcessHardFault() is invoked and the system enters a safe state. This function should not attempt to recover scheduling.

Reimplemented in CtrlTask< _AccessMode >, HwLedTask< _AccessMode >, and stk::time::TimerHost::TimerWorkerTask.

Definition at line 973 of file stk_common.h.

973{ STK_UNUSED(duration); }
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:715

References STK_UNUSED.

◆ OnExit()

virtual void stk::ITask::OnExit ( )
inlinevirtualinherited

Called by the kernel before removal from the scheduling (see stk::KERNEL_DYNAMIC).

Note
The task's stack is no longer in use but the ITask object itself is still valid.
The default no-op implementation is sufficient for detached tasks. Override to implement join semantics (signal a waiting joiner).
Called in kernel/tick context - keep it short. ISR-safe primitives only (e.g. stk::sync::Semaphore::Signal(), stk::sync::EventFlags::Set()).
KERNEL_DYNAMIC only. Never called in KERNEL_STATIC mode.
This is the completion notification of a task removal (returning from Run(), IKernelService::ExitTask() or IKernel::ScheduleTaskRemoval()): after it has been observed by another task the kernel no longer references the ITask object, its stack and its slot, so they can be released or reused, and the same ITask can be added again with IKernel::AddTask() (a restart, e.g. tx_thread_reset()). The removal is an atomic step of the kernel tick: the slot is freed right after this call, before any other task can run (single-core kernel). Until then IKernel::AddTask() of the same task fails with ADD_FAIL_DUPLICATE.

Reimplemented in cy_stk_thread, stk::pthread::PthreadTask, and stk::time::TimerHost::TimerWorkerTask.

Definition at line 990 of file stk_common.h.

990{}

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::RemoveTask().

Here is the caller graph for this function:

◆ Run() [1/3]

template<stk::EAccessMode _AccessMode>
void NonSecureLedTask< _AccessMode >::Run ( )
inlineoverrideprivatevirtual

Entry point of the user task.

Note
Called by the Kernel when the task is scheduled for execution. Implement this method with the task's main logic.
Warning
If Kernel is configured as KERNEL_STATIC, the body must contain an infinite loop.
void Run() override
{
while (true)
{
// task logic here
}
}
void Run() override
Entry point of the user task.

Implements stk::ITask.

Examples
blinky_mpu-hard/example.cpp, blinky_mpu/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 237 of file blinky_mpu-hard/example.cpp.

238 {
239 // we switch LEDs with 250ms period
241
242 // get a start of the timeline
244
245 while (true)
246 {
247 // block until this task's flag is set; auto-cleared on return
250 continue;
251
252 // change active LED
253 s_HwCmdQueue.Write({
255 .param_0 = m_task_id}
256 );
257
258 // sleep 1s drift-free and then delegate work to the next task
259 // we could use simple stk::Sleep() but due to other work around Sleep call we
260 // will get a time drift, STK allows to sleep until exact timestamp making it
261 // possible precise sleeping with 1 tick precision, you could also use
262 // time::TimerHost for timer-related tasks (see related 'timer' example)
264
265 // hand off to the next task
267
268 // uncommenting this will cause MemManage exception due to access of Secure
269 // memory region by Non-Secure task, under debugger you will see such call stack:
270 //
271 // * PlatformEventHandler::OnException() at example.cpp:459
272 // * StkExceptionHandlerMain() at stk_arch_arm-cortex-m.cpp:2 683
273 // * <signal handler called>() at 0xfffffffd
274 // * NonSecureLedTask<(stk::EAccessMode)0>::Run at example.cpp:211 <--- points to offending ++g_SecureCounter
275 // * OnTaskRun() at stk_arch_arm-cortex-m.cpp:2 751
276 //
277 //++g_SecureCounter;
278 }
279 }
static bool SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
Definition stk_helper.h:523
static Ticks GetTicksFromMs(Time ms, uint32_t resolution)
Convert milliseconds to ticks.
Definition stk_helper.h:406
static Ticks GetTicks()
Get number of ticks elapsed since kernel start.
Definition stk_helper.h:448

References HwCommand::CMD_LED_ON, g_TaskFlags(), g_Timeline, stk::GetTicks(), stk::GetTicksFromMs(), stk::sync::EventFlagsT< uint32_t >::IsError(), m_my_flag, m_next_flag, m_task_id, stk::sync::EventFlagsT< uint32_t >::OPT_WAIT_ANY, s_HwCmdQueue, and stk::SleepUntil().

Here is the call graph for this function:

◆ Run() [2/3]

template<stk::EAccessMode _AccessMode>
void NonSecureLedTask< _AccessMode >::Run ( )
inlineoverrideprivatevirtual

Entry point of the user task.

Note
Called by the Kernel when the task is scheduled for execution. Implement this method with the task's main logic.
Warning
If Kernel is configured as KERNEL_STATIC, the body must contain an infinite loop.
void Run() override
{
while (true)
{
// task logic here
}
}

Implements stk::ITask.

Definition at line 238 of file blinky_mpu/example.cpp.

239 {
240 // we switch LEDs with 250ms period
242
243 // get a start of the timeline
245
246 while (true)
247 {
248 // block until this task's flag is set; auto-cleared on return
251 continue;
252
253 // change active LED
254 s_HwCmdQueue.Write({
256 .param_0 = m_task_id}
257 );
258
259 // sleep 1s drift-free and then delegate work to the next task
260 // we could use simple stk::Sleep() but due to other work around Sleep call we
261 // will get a time drift, STK allows to sleep until exact timestamp making it
262 // possible precise sleeping with 1 tick precision, you could also use
263 // time::TimerHost for timer-related tasks (see related 'timer' example)
265
266 // hand off to the next task
268
269 // uncommenting this will cause MemManage exception due to access of Secure
270 // memory region by Non-Secure task, under debugger you will see such call stack:
271 //
272 // * PlatformEventHandler::OnException() at example.cpp:383
273 // * StkExceptionHandlerMain() at stk_arch_arm-cortex-m.cpp:2 683
274 // * <signal handler called>() at 0xfffffffd
275 // * NonSecureLedTask<(stk::EAccessMode)0>::Run at example.cpp:140 <--- points to offending ++g_SecureCounter
276 // * OnTaskRun() at stk_arch_arm-cortex-m.cpp:2 751
277 //
278 //++g_SecureCounter;
279 }
280 }

References HwCommand::CMD_LED_ON, g_TaskFlags(), g_Timeline, stk::GetTicks(), stk::GetTicksFromMs(), stk::sync::EventFlagsT< uint32_t >::IsError(), m_my_flag, m_next_flag, m_task_id, stk::sync::EventFlagsT< uint32_t >::OPT_WAIT_ANY, s_HwCmdQueue, and stk::SleepUntil().

Here is the call graph for this function:

◆ Run() [3/3]

template<stk::EAccessMode _AccessMode>
void NonSecureLedTask< _AccessMode >::Run ( )
inlineoverrideprivatevirtual

Entry point of the user task.

Note
Called by the Kernel when the task is scheduled for execution. Implement this method with the task's main logic.
Warning
If Kernel is configured as KERNEL_STATIC, the body must contain an infinite loop.
void Run() override
{
while (true)
{
// task logic here
}
}

Implements stk::ITask.

Definition at line 177 of file blinky_mpu_armv8/example.cpp.

178 {
179 // we switch LEDs with 250ms period
181
182 // get a start of the timeline
184
185 while (true)
186 {
187 // block until this task's flag is set; auto-cleared on return
190 continue;
191
192 // change active LED
193 s_HwCmdQueue.Write({
195 .param_0 = m_task_id}
196 );
197
198 // sleep 1s drift-free and then delegate work to the next task
199 // we could use simple stk::Sleep() but due to other work around Sleep call we
200 // will get a time drift, STK allows to sleep until exact timestamp making it
201 // possible precise sleeping with 1 tick precision, you could also use
202 // time::TimerHost for timer-related tasks (see related 'timer' example)
204
205 // hand off to the next task
207
208 // uncommenting this will cause MemManage exception due to access of Secure
209 // memory region by Non-Secure task, under debugger you will see such call stack:
210 //
211 // * PlatformEventHandler::OnException() at example.cpp:459
212 // * StkExceptionHandlerMain() at stk_arch_arm-cortex-m.cpp:2 683
213 // * <signal handler called>() at 0xfffffffd
214 // * NonSecureLedTask<(stk::EAccessMode)0>::Run at example.cpp:211 <--- points to offending ++g_SecureCounter
215 // * OnTaskRun() at stk_arch_arm-cortex-m.cpp:2 751
216 //
217 //++g_SecureCounter;
218 }
219 }

References HwCommand::CMD_LED_ON, g_TaskFlags(), g_Timeline, stk::GetTicks(), stk::GetTicksFromMs(), stk::sync::EventFlagsT< uint32_t >::IsError(), m_my_flag, m_next_flag, m_task_id, stk::sync::EventFlagsT< uint32_t >::OPT_WAIT_ANY, s_HwCmdQueue, and stk::SleepUntil().

Here is the call graph for this function:

Member Data Documentation

◆ m_mode

template<stk::EAccessMode _AccessMode>
stk::EAccessMode NonSecureLedTask< _AccessMode >::m_mode
private

kernel access mode

Examples
blinky_mpu_armv8/example.cpp.

Definition at line 157 of file blinky_mpu_armv8/example.cpp.

Referenced by GetAccessMode(), and NonSecureLedTask().

◆ m_my_flag

template<stk::EAccessMode _AccessMode>
uint32_t NonSecureLedTask< _AccessMode >::m_my_flag
private

◆ m_next_flag

template<stk::EAccessMode _AccessMode>
uint32_t NonSecureLedTask< _AccessMode >::m_next_flag
private

◆ m_stack

template<stk::EAccessMode _AccessMode>
stk::Word * NonSecureLedTask< _AccessMode >::m_stack
private

pointer to stack buffer

Examples
blinky_mpu-hard/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 217 of file blinky_mpu-hard/example.cpp.

Referenced by GetStack(), NonSecureLedTask(), and NonSecureLedTask().

◆ m_stack_size

template<stk::EAccessMode _AccessMode>
size_t NonSecureLedTask< _AccessMode >::m_stack_size
private

stack size in words

Examples
blinky_mpu-hard/example.cpp, and blinky_mpu_armv8/example.cpp.

Definition at line 218 of file blinky_mpu-hard/example.cpp.

Referenced by GetStackSize(), NonSecureLedTask(), and NonSecureLedTask().

◆ m_task_id

template<stk::EAccessMode _AccessMode>
uint8_t NonSecureLedTask< _AccessMode >::m_task_id
private

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