PIC24 Support Libraries
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.

Functions

ESOS_TASK_HANDLE esos_RegisterTask (uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
 
uint8_t esos_UnregisterTask (uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
 
ESOS_TASK_HANDLE esos_GetTaskHandle (uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
 
ESOS_TASK_HANDLE esos_GetTaskHandleFromID (uint16_t u16_TaskID)
 
ESOS_TASK_HANDLE esos_GetFreeChildTaskStruct ()
 
void esos_SetRandomUint32Seed (uint32_t u32_in)
 
uint32_t esos_GetRandomUint32 (void)
 
uint32_t esos_buffer_hash_u32 (void *buf, uint16_t len)
 
uint32_t esos_string_hash_u32 (char *psz_str)
 
uint8_t esos_GetMaxNumberTasks (void)
 
ESOS_TMR_HANDLE esos_RegisterTimer (void(*timername)(void), uint32_t u32_period)
 
uint8_t esos_UnregisterTimer (ESOS_TMR_HANDLE hnd_timer)
 
ESOS_TMR_HANDLE esos_GetTimerHandle (void(*pfnTmrFcn)(void))
 
uint8_t esos_ChangeTimerPeriod (ESOS_TMR_HANDLE hnd_timer, uint32_t u32_period)
 

Detailed Description

Central code for Embedded Systems Operating System (ESOS)

Definition in file esos.c.

Function Documentation

◆ esos_buffer_hash_u32()

uint32_t esos_buffer_hash_u32 ( void *  buf,
uint16_t  len 
)

Create a 32-bit (uint32_t) hash value for a buffer of voids Routine maintains "state" in the form of variable __esos_u32FNVHash This "state" is used in all of the ESOS FNV hash functions. Based on the Fowler/Noll/Vo (FNV1a) hash algorithm and code provided at http://www.isthe.com/chongo/tech/comp/fnv/

Parameters
bufpointer to a buffer of voids
lenlength of the buffer of voids
Return values
uint32_tvalue of the resulting hash
See also
esos_string_hash_u32
esos_hash_u32_to_u16

Definition at line 379 of file esos.c.

◆ esos_ChangeTimerPeriod()

uint8_t esos_ChangeTimerPeriod ( ESOS_TMR_HANDLE  hnd_timer,
uint32_t  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 591 of file esos.c.

◆ esos_GetFreeChildTaskStruct()

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 298 of file esos.c.

◆ esos_GetMaxNumberTasks()

uint8_t 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 447 of file esos.c.

◆ esos_GetRandomUint32()

uint32_t 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 332 of file esos.c.

◆ esos_GetTaskHandle()

ESOS_TASK_HANDLE esos_GetTaskHandle ( uint8_t(*)(ESOS_TASK_HANDLE pstTask)  taskname)

Find the (active) task handle for a given task function

Parameters
tasknamename of task (argument to ESOS_USER_TASK declaration
Return values
NULLPTRif task is not found among the active tasks
TaskHandlethe handle to the task function requested
See also
ESOS_USER_TASK
esos_RegisterTask
esos_UnregisterTask

Definition at line 219 of file esos.c.

◆ esos_GetTaskHandleFromID()

ESOS_TASK_HANDLE esos_GetTaskHandleFromID ( uint16_t  u16_TaskID)

Find the (active) task handle for a given task function

Parameters
u16_TaskIDname of task (argument to ESOS_USER_TASK declaration)
Return values
NULLPTRif task is not found among the active tasks
TaskHandlethe handle to the task function requested
See also
ESOS_USER_TASK
esos_RegisterTask
esos_UnregisterTask

Definition at line 255 of file esos.c.

◆ esos_GetTimerHandle()

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 564 of file esos.c.

◆ esos_RegisterTask()

ESOS_TASK_HANDLE esos_RegisterTask ( uint8_t(*)(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 86 of file esos.c.

◆ esos_RegisterTimer()

ESOS_TMR_HANDLE esos_RegisterTimer ( void(*)(void)  timername,
uint32_t  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 514 of file esos.c.

◆ esos_SetRandomUint32Seed()

void esos_SetRandomUint32Seed ( uint32_t  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 322 of file esos.c.

◆ esos_string_hash_u32()

uint32_t esos_string_hash_u32 ( char *  psz_str)

Create a 32-bit (uint32_t) hash value for a provided string Routine maintains "state" in the form of variable __esos_u32FNVHash This "state" is used in all of the ESOS FNV hash functions. Based on the Fowler/Noll/Vo (FNV1a) hash algorithm and code provided at http://www.isthe.com/chongo/tech/comp/fnv/

Parameters
psz_strpointer to zero-terminated string
Return values
uint32_tvalue of the resulting hash
See also
esos_string_hash_u32
esos_hash_u32_to_u16

Definition at line 415 of file esos.c.

◆ esos_UnregisterTask()

uint8_t esos_UnregisterTask ( uint8_t(*)(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 178 of file esos.c.

◆ esos_UnregisterTimer()

uint8_t 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 543 of file esos.c.