PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions
esos.h File Reference
#include "all_generic.h"
#include "esos_task.h"
#include "esos_comm.h"
#include "esos_irq.h"

Go to the source code of this file.

Macros

#define ESOS_USER_FLAG_0
 
#define ESOS_USER_FLAG_1
 
#define ESOS_USER_FLAG_2
 
#define ESOS_USER_FLAG_3
 
#define ESOS_USER_FLAG_4
 
#define ESOS_USER_FLAG_5
 
#define ESOS_USER_FLAG_6
 
#define ESOS_USER_FLAG_7
 
#define ESOS_USER_FLAG_8
 
#define ESOS_USER_FLAG_9
 
#define ESOS_USER_FLAG_A
 
#define ESOS_USER_FLAG_B
 
#define ESOS_USER_FLAG_C
 
#define ESOS_USER_FLAG_D
 
#define ESOS_USER_FLAG_E
 
#define ESOS_USER_FLAG_F
 
#define ESOS_USER_TIMER(timername)
 
#define esos_GetSystemTick()
 
#define esos_GetNumberRegisteredTasks()
 
#define esos_GetFutureSystemTick(deltaT)
 
#define esos_SetUserFlag(mask)
 
#define esos_ClearUserFlag(mask)
 
#define esos_IsUserFlagSet(mask)
 
#define esos_IsUserFlagClear(mask)
 
#define esos_GetNumberRunningTimers()
 
#define esos_IsTimerRunning(hndl)
 

Typedefs

typedef int main_t
 
typedef uint8 ESOS_TMR_HANDLE
 

Functions

void user_init (void)
 
ESOS_TASK_HANDLE esos_GetFreeChildTaskStruct ()
 
uint32 esos_GetRandomUint32 ()
 
ESOS_TMR_HANDLE esos_RegisterTimer (void(*pfnTmrFcn)(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

Embedded Systems Operating System (ESOS)

Definition in file esos.h.

Macro Definition Documentation

#define esos_ClearUserFlag (   mask)

Clears bits in the global user flags provided by ESOS

Parameters
maskAn uint16 value composed of the OR-ed user mask flag masks, where each flag in the OR will be cleared
Note
User should use the provided bits masks like ESOS_USER_FLAG_0 and ESOS_USER_FLAG_1 and ... ESOS_USER_FLAG_F to create their own readable constants
#define HEADLIGHTS_ARE_ON ESOS_USER_FLAG_3
#define MY_USER_FRIENDLY_FLAG ESOS_USER_FLAG_7
esos_ClearUserFlag( HEADLIGHTS_ARE_ON | MY_USER_FRIENDLY_FLAG);
See Also
esos_SetUserFlag
esos_IsUserFlagSet
esos_IsUserFlagClear

Definition at line 328 of file esos.h.

#define esos_GetFutureSystemTick (   deltaT)

Returns the system tick value of a future time

Parameters
deltaTthe number of ticks in the future you'd like the system tick value for
Returns
The uint32 number corresponding to the system tick value of that future time
See Also
esos_GetSystemTick

Definition at line 290 of file esos.h.

#define esos_GetNumberRegisteredTasks ( )

Get the current number of user task registered with the ESOS scheduler.

Returns
The uint8 number of currently registered user tasks
Note
This value does not include the number of child tasks (tasks of the type ESOS_CHILD_TASK ), just the tasks of the type ESOS_USER_TASK

Definition at line 279 of file esos.h.

#define esos_GetNumberRunningTimers ( )

Get the current number of user software timers registers (running) in the ESOS timer services

Returns
The uint8 number of currently registered user tasks

Definition at line 391 of file esos.h.

Referenced by esos_GetTimerHandle(), and esos_RegisterTimer().

#define esos_GetSystemTick ( )

Get the current value of the ESOS system tick counter In the current implementation of ESOS, a tick equal 1.0ms. Therefore, the value returned by this function is approximately equal to the number of milliseconds since the since was last reset.

Returns
The uint32 value of current value of the ESOS system tick counter
Note
This counter value will roll-over every 49.7 days.

Definition at line 256 of file esos.h.

#define esos_IsTimerRunning (   hndl)

Determines if the software timer represented by the handle is currently running

Parameters
hndlThe ESOS_TMR_HANDLE of a software timer
Return values
TRUEif the timer is currently running
FALSEif the timer is not currently running
See Also
ESOS_USER_TIMER
esos_UnregisterTimer
esos_GetTimerHandle
esos_ChangeTimerPeriod

Definition at line 404 of file esos.h.

Referenced by esos_ChangeTimerPeriod(), esos_GetTimerHandle(), esos_RegisterTimer(), and esos_UnregisterTimer().

#define esos_IsUserFlagClear (   mask)

Queries whether the global user flags provided by ESOS are clear

Parameters
maskAn uint16 value composed of the OR-ed user mask flag masks, where each flag in the OR will be checked for being clear
Return values
TRUEif at least one of the flags is clear
FALSEif none of the flags are clear
Note
User should use the provided bits masks like ESOS_USER_FLAG_0 and ESOS_USER_FLAG_1 and ... ESOS_USER_FLAG_F to create their own readable constants
#define HEADLIGHTS_ARE_ON ESOS_USER_FLAG_3
#define MY_USER_FRIENDLY_FLAG ESOS_USER_FLAG_7
esos_ClearUserFlag( HEADLIGHTS_ARE_ON | MY_USER_FRIENDLY_FLAG);
while(esos_IsUserFlagClear( HEADLIGHTS_ARE_ON)); // infinite loop
See Also
esos_SetUserFlag
esos_ClearUserFlag
esos_IsUserFlagSet

Definition at line 372 of file esos.h.

#define esos_IsUserFlagSet (   mask)

Queries whether the global user flags provided by ESOS are set

Parameters
maskAn uint16 value composed of the OR-ed user mask flag masks, where each flag in the OR will be checked for being set
Return values
TRUEif at least one of the flags is set
FALSEif none of the flags are set
Note
User should use the provided bits masks like ESOS_USER_FLAG_0 and ESOS_USER_FLAG_1 and ... ESOS_USER_FLAG_F to create their own readable constants
#define HEADLIGHTS_ARE_ON ESOS_USER_FLAG_3
#define MY_USER_FRIENDLY_FLAG ESOS_USER_FLAG_7
esos_ClearUserFlag( HEADLIGHTS_ARE_ON | MY_USER_FRIENDLY_FLAG);
while(esos_IsUserFlagSet( HEADLIGHTS_ARE_ON)); // falls through
See Also
esos_SetUserFlag
esos_ClearUserFlag
esos_IsUserFlagClear

Definition at line 350 of file esos.h.

#define esos_SetUserFlag (   mask)

Sets bits in the global user flags provided by ESOS

Parameters
maskAn uint16 value composed of the OR-ed user mask flag masks, where each flag in the OR will be set
Note
User should use the provided bits masks like ESOS_USER_FLAG_0 to create their own readable constants
#define HEADLIGHTS_ARE_ON ESOS_USER_FLAG_3
#define MY_USER_FRIENDLY_FLAG ESOS_USER_FLAG_7
esos_SetUserFlag( HEADLIGHTS_ARE_ON | MY_USER_FRIENDLY_FLAG);
See Also
esos_ClearUserFlag
esos_IsUserFlagSet
esos_IsUserFlagClear

Definition at line 308 of file esos.h.

Referenced by user_init().

#define ESOS_USER_FLAG_0

Mask for a global user flag provided by ESOS

Definition at line 105 of file esos.h.

#define ESOS_USER_FLAG_1

Mask for a global user flag provided by ESOS

Definition at line 109 of file esos.h.

#define ESOS_USER_FLAG_2

Mask for a global user flag provided by ESOS

Definition at line 113 of file esos.h.

#define ESOS_USER_FLAG_3

Mask for a global user flag provided by ESOS

Definition at line 117 of file esos.h.

#define ESOS_USER_FLAG_4

Mask for a global user flag provided by ESOS

Definition at line 121 of file esos.h.

#define ESOS_USER_FLAG_5

Mask for a global user flag provided by ESOS

Definition at line 125 of file esos.h.

#define ESOS_USER_FLAG_6

Mask for a global user flag provided by ESOS

Definition at line 129 of file esos.h.

#define ESOS_USER_FLAG_7

Mask for a global user flag provided by ESOS

Definition at line 133 of file esos.h.

#define ESOS_USER_FLAG_8

Mask for a global user flag provided by ESOS

Definition at line 137 of file esos.h.

#define ESOS_USER_FLAG_9

Mask for a global user flag provided by ESOS

Definition at line 141 of file esos.h.

#define ESOS_USER_FLAG_A

Mask for a global user flag provided by ESOS

Definition at line 145 of file esos.h.

#define ESOS_USER_FLAG_B

Mask for a global user flag provided by ESOS

Definition at line 149 of file esos.h.

#define ESOS_USER_FLAG_C

Mask for a global user flag provided by ESOS

Definition at line 153 of file esos.h.

#define ESOS_USER_FLAG_D

Mask for a global user flag provided by ESOS

Definition at line 157 of file esos.h.

#define ESOS_USER_FLAG_E

Mask for a global user flag provided by ESOS

Definition at line 161 of file esos.h.

#define ESOS_USER_FLAG_F

Mask for a global user flag provided by ESOS

Definition at line 165 of file esos.h.

#define ESOS_USER_TIMER (   timername)

Declaration of an user-defined timer callback (for ESOS timer services)

This macro is used to declare a user-timer. All timers using ESOS timer services must be declared with this macro.

Parameters
timernameThe name of the software timer to create.
Note
You are really creating a C function implementing the user timer callback. Since ESOS timer serivces calls this callback function at the appropriate time, this function cannot be passed arguments and cannot return values

Definition at line 180 of file esos.h.

Typedef Documentation

Handle to a software timer in the ESOS timer service.

See Also
ESOS_USER_TIMER
esos_RegisterTimer
esos_UnregisterTimer
esos_GetTimerHandle
esos_ChangeTimerPeriod

Definition at line 193 of file esos.h.

typedef int main_t

Define the constants and structures required for our little embedded systems operating system

Definition at line 87 of file esos.h.

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.

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_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().

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.

void user_init ( void  )

User-provided function to initialize user's hardware configuration register user tasks.

Note
All ESOS applications MUST provide this function.
This function MUST register at least one ESOS task.
user_init() is a centralized initialization routine where the user can setup their application. It is called automagically by ES_OS during the operating system initialization.
User should set up any state machines and init all application variables. They can also turn on any needed peripherals here.
User shall not mess with the interrupt hardware directly!!! The ESOS must be aware of the interrupts and provides esos_XXXXXXX functions for the user to use. Using these ESOS-provided functions, the user may (and probably should) initialize, register, and enable interrupts in this routine.
Furthermore, the user should register AT LEAST one user application task here via esos_RegisterTask or the ES_OS scheduler will have nothing to schedule to run when this function returns.

Definition at line 191 of file app_childtask.c.