Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once you achieved a successful build, you are actually ready to start testing your port. As the title of this section suggest, this step will verify the proper operation of OSTaskStkInit() and OSStartHighRdy().

Testing with a source level debugger

If you have a source level debugger, you should be able to verify this step fairly quickly. I assume you already know how to use your debugger.

...

You can now step into OSTimeDly(). The function OSTimeDly() will call OS_Sched() and OS_Sched() will in turn calls the assembly language function OSCtxSw(). In most cases, this is accomplished through a TRAP or software interrupt mechanism. In other words, if you setup the software interrupt or TRAP correctly, this instruction should cause the CPU to start executing OSCtxSw(). You can step through the code for OSCtxSw() and see the registers of TestTask() be saved onto its stack and the value of the registers for OS_TaskIdle() be loaded into the CPU. When the return from interrupt is executed (for the software interrupt or TRAP), you should be in OS_TaskIdle()!

...

At this point, your port should work and you can now start adding application tasks. Have fun!

OSCtxSw()

void OSCtxSw(void)

FileCalled from 
OS_CPU_A.ASMOS_TASK_SW()Always needed

...

Some compilers will allow you to create software interrupts (or traps) directly in C and thus, you could place this function in OS_CPU_C.C. In some cases, the compiler also requires that you declare the prototype for this function differently. In this case, you can define the #define constant OS_ISR_PROTO_EXT in your INCLUDES.H. This allows you to delare OSCtxSw() differently. In other words, you are not forced to use the void OSCtxSw(void) prototype.

Example

NONE

OSInitHookBegin()

void OSInitHookBegin(void)

...

Notes/Warnings

NONE

Example

NONE

OSInitHookEnd()

void OSInitHookEnd(void)

FileCalled fromCode enabled in OS_CPU_C.C if
OS_CPU_C.COSInit()OS_CPU_HOOKS_EN == 1

...

Notes/Warnings

NONE

Example

NONE

OSIntCtxSw()

void OSIntCtxSw(void)

FileCalled from 
OS_CPU_A.ASMOSIntExit()Always needed

...

Interrupts are disabled when this function is called.

Example

NONE

OSStartHighRdy()

void OSStartHighRdy(void)

...

Interrupts are disabled when this function is called.

Example

NONE

OSTaskCreateHook()

void OSTaskCreateHook(OS_TCB *ptcb)

...

This example assumes that you created a task using OSTaskCreateExt() because it expects to have the .OSTCBExtPtr field in the tasks OS_TCB contain a pointer to storage for floating-point registers.

OSTaskDelHook()

void OSTaskDelHook(OS_TCB *ptcb)

...

Interrupts are disabled when this function is called. Because of this, you should keep the code in this function to a minimum because it directly affects interrupt latency.

Example

OSTaskIdleHook()

void OSTaskIdleHook(void)

...

OSTaskIdleHook() is called with interrupts enabled.

Example

OSTaskStatHook()

void OSTaskStatHook(void)

...

Interrupts are enabled when this function is called.

Example

NONE

OSTaskSwHook()

void OSTaskSwHook(void)

FileCalled fromCode enabled in OS_CPU_C.C if
OS_CPU_C.COSCtxSw() and OSIntCtxSw()OS_CPU_HOOKS_EN == 1

...

Interrupts are disabled when this function is called. Because of this, you should keep the code in this function to a minimum because it directly affects interrupt latency.

Example

OSTCBInitHook()

void OSTCBInitHook(OS_TCB *ptcb)

...

This example assumes that you created a task using OSTaskCreateExt() because it expects to have the .OSTCBExtPtr field in the tasks OS_TCB contain a pointer to storage for floating-point registers.

OSTickISR()

void OSTickISR(void)

FileCalled from 
OS_CPU_A.ASMTick InterruptAlways needed

...

  1. The interrupting device that causes OSTickISR() to be called should generally be setup to generate an interrupt every 10 to 100 mS.
  2. Some compilers will allow you to create ISRs directly in C and thus, you could place this function in OS_CPU_C.C. In some cases, the compiler also requires that you declare the prototype for this function differently. In this case, you can define the #define constant OS_ISR_PROTO_EXT in your INCLUDES.H. This allows you to delare OSTickISR() differently. In other words, you are not forced to use the void OSTickISR(void) prototype.

Example

NONE

OSTimeTickHook()

void OSTimeTickHook(void)

...