PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
esos.c File Reference

Central code for Embedded Systems Operating System (ESOS) More...

#include "esos.h"

Go to the source code of this file.

Macros

#define MAX_NUM_USER_TASKS   16
 

Functions

ESOS_TASK_HANDLE esos_RegisterTask (uint8(*taskname)(ESOS_TASK_HANDLE pstTask))
 
uint8 esos_UnregisterTask (uint8(*taskname)(ESOS_TASK_HANDLE pstTask))
 
ESOS_TASK_HANDLE esos_GetFreeChildTaskStruct ()
 
void esos_SetRandomUint32Seed (uint32 u32_in)
 
uint32 esos_GetRandomUint32 (void)
 
uint8 esos_GetMaxNumberTasks (void)
 
ESOS_TMR_HANDLE esos_RegisterTimer (void(*timername)(void), uint32 u32_period)
 
uint8 esos_UnregisterTimer (ESOS_TMR_HANDLE hnd_timer)
 
ESOS_TMR_HANDLE esos_GetTimerHandle (void(*pfnTmrFcn)(void))
 
uint8 esos_ChangeTimerPeriod (ESOS_TMR_HANDLE hnd_timer, uint32 u32_period)
 

Detailed Description

Central code for Embedded Systems Operating System (ESOS)

Definition in file esos.c.

Macro Definition Documentation

#define MAX_NUM_USER_TASKS   16

Define the maximum number of user tasks in the system

Note
Technically, this is actually the maximum number of tasks that will be running "concurrently". Usually, this number is the maximum number of tasks that the user has defined, UNLESS they are absolutely sure that two (or more) tasks are mutually exclusive in execution.
BOTH "parent" and "child" tasks use this NUMBER to allocate their pool of tasks. So this number should be equal to or greater than the MAXIMUM number of concurrently running child –OR– parent tasks.

Definition at line 57 of file esos.c.

Referenced by esos_GetMaxNumberTasks(), and esos_RegisterTask().

Function Documentation

uint8 esos_ChangeTimerPeriod ( ESOS_TMR_HANDLE  hnd_timer,
uint32  u32_period 
)

Change a timer period.

Parameters
hnd_timerhandle to timer whose period is to be changed
u32_periodnew period for timer selected by mask
Return values
FALSEif timer is not currently running
TRUEif timer period was changed
See Also
esos_RegisterTimer
esos_UnregisterTimer
esos_GetTimerHandle
esos_IsTimerRunning

Definition at line 379 of file esos.c.

ESOS_TASK_HANDLE esos_GetFreeChildTaskStruct ( )

Searches child task pool to find a free child task structure and returns a handle (pst) back to the caller

Return values
TaskHandleif a child task structure is available
ESOS_BAD_CHILD_TASK_HANDLEif no structures are available at this time

Definition at line 186 of file esos.c.

uint8 esos_GetMaxNumberTasks ( void  )

Returns the number of tasks we can execute

Return values
Nthe number of tasks this version of ESOS can execute

Definition at line 235 of file esos.c.

uint32 esos_GetRandomUint32 ( void  )

Returns a 31-bit pseudo-random number generated by the Park-Miller algorithm.

See Also
esos_SetRandomUint32Seed
Note
Visit http://www.firstpr.com.au/dsp/rand31/ for more information

Definition at line 220 of file esos.c.

ESOS_TMR_HANDLE esos_GetTimerHandle ( void(*)(void)  pfnTmrFcn)

Finds the timer handle to the provided and ACTIVE timer function

Parameters
pfnTmrFcnpointer to timer function (will execute each time timer expires)
Return values
ESOS_TMR_FAILUREcould not find the function in the active timer list
timerHandlehandle to timer
See Also
esos_RegisterTimer
esos_UnregisterTimer
esos_ChangeTimerPeriod
esos_IsTimerRunning

Definition at line 352 of file esos.c.

ESOS_TASK_HANDLE esos_RegisterTask ( uint8(*)(ESOS_TASK_HANDLE pstTask)  taskname)

Adds a task to the scheduler. Task will start executing at the next opportunity. (almost immediately)

Parameters
tasknamename of task (argument to ESOS_USER_TASK declaration
Return values
NULLPTRif no more tasks can execute at this time (scheduler is full)
TaskHandlethe handle of the just registered and scheduled task
See Also
ESOS_USER_TASK
esos_UnregisterTask

Definition at line 94 of file esos.c.

Referenced by user_init().

ESOS_TMR_HANDLE esos_RegisterTimer ( void(*)(void)  timername,
uint32  u32_period 
)

Adds a timer to the ESOS timer service. Timer function will execute at its next opportunity. Timer functions must have void arguments and void returns.

Parameters
timernamename under which timer was declared in ESOS_USER_TIMER. and contains the code to run when software timer expires
u32_periodperiod of timer in system ticks (currently, milliseconds)
Return values
ESOS_TMR_FAILUREif no more timers can added at this time
timerhandleif timer service was registered
See Also
ESOS_USER_TIMER
esos_UnregisterTimer
esos_GetTimerHandle
esos_ChangeTimerPeriod
esos_IsTimerRunning

Definition at line 302 of file esos.c.

Referenced by user_init().

void esos_SetRandomUint32Seed ( uint32  u32_in)

Sets the seed value in the ESOS pseudo-random number generator (PRNG).

Note
ESOS init code sets a seed value for the PRNG. If the application desires a sequence that is not predictable at each execution run, then the seed should be set ONCE with some value that is different with each execution. An idea is to have the user press a key during startup. The value of the ESOS tick when the user presses the key will be different each time. This number would make an ideal PRNG seed.
See Also
esos_GetRandomUint32 See http://www.firstpr.com.au/dsp/rand31/ for more information

Definition at line 210 of file esos.c.

uint8 esos_UnregisterTask ( uint8(*)(ESOS_TASK_HANDLE pstTask)  taskname)

Removes the task from the scheduler

Parameters
tasknamename of task (argument to ESOS_USER_TASK declaration
Return values
TRUEif task was found in scheduler and removed
FALSEotherwise
See Also
ESOS_USER_TASK
esos_RegisterTask

Definition at line 147 of file esos.c.

uint8 esos_UnregisterTimer ( ESOS_TMR_HANDLE  hnd_timer)

Removes a timer from the ESOS timer service.

Parameters
hnd_timerhandle to timer to remove
Return values
FALSEif timer wasn't active in the first place
TRUEif timer was stopped and removed
See Also
esos_RegisterTimer
esos_GetTimerHandle
esos_ChangeTimerPeriod

Definition at line 331 of file esos.c.