esos/src/esos.c File Reference

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

#include "esos.h"

Go to the source code of this file.

Defines

#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.


Define 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.


Function Documentation

uint8 esos_ChangeTimerPeriod ( ESOS_TMR_HANDLE  hnd_timer,
uint32  u32_period 
)

Change a timer period.

Parameters:
hnd_timer handle to timer whose period is to be changed
u32_period new period for timer selected by mask
Return values:
FALSE if timer is not currently running
TRUE if 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:
TaskHandle if a child task structure is available
ESOS_BAD_CHILD_TASK_HANDLE if 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:
N the 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:
pfnTmrFcn pointer to timer function (will execute each time timer expires)
Return values:
ESOS_TMR_FAILURE could not find the function in the active timer list
timerHandle handle 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:
taskname name of task (argument to ESOS_USER_TASK declaration
Return values:
NULLPTR if no more tasks can execute at this time (scheduler is full)
TaskHandle the handle of the just registered and scheduled task
See also:
ESOS_USER_TASK

esos_UnregisterTask

Definition at line 94 of file esos.c.

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:
timername name under which timer was declared in ESOS_USER_TIMER. and contains the code to run when software timer expires
u32_period period of timer in system ticks (currently, milliseconds)
Return values:
ESOS_TMR_FAILURE if no more timers can added at this time
timerhandle if 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.

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:
taskname name of task (argument to ESOS_USER_TASK declaration
Return values:
TRUE if task was found in scheduler and removed
FALSE otherwise
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_timer handle to timer to remove
Return values:
FALSE if timer wasn't active in the first place
TRUE if timer was stopped and removed
See also:
esos_RegisterTimer

esos_GetTimerHandle

esos_ChangeTimerPeriod

Definition at line 331 of file esos.c.


Generated on Sun Mar 15 11:14:22 2009 for PIC24 Support Libraries by  doxygen 1.5.8