Table 1 SSX Function Calls

-----------------------------------------------------------------------
int ssx_alert(wait_q       ssx_alert sends a message to a task waiting
*wqptr)                    on the specified wait_q. If there is already
                           a message waiting on the specified wait_q,
                           then a MW_ERR (see ssx.h) is returned. If
                           there are any tasks waiting on the wait_q,
                           the first task is scheduled if it has a high
                           enoughpriority. If no task is waiting then a
                           message is left on the wait_q.

int ssx_init(void)         ssx_init is called before creating tasks or
                           running the SSX executive. This initializes
                           SSX executivedata.

int ssx_task_create        ssx_task_create is called to create a task to
(unsigned char task_pri,   run with the SSX executive. Following is list
unsigned char task_id,     of parameters passed to ssx_task_create:
fptr task_ptr, unsigned    name — an eight-character name for the
int stack_size, char       task. This is useful in debugging SSX
*name)                     applications. The size of name is setup in
                           ssx_conf.h. stack_size — the size of the
                           stack for this task in bytes. In our demo
                           application we are using 0x200. This will
                           depend on your application. Start high if you
                           think you will be deeply nested or you are
                           using a lot of automatic variables.
                           task_id — the ID for the task being created.
                           IDs range from 1 to 0xfe. ID 0xff is reserved
                           for a background task that SSX creates. ID 0
                           is used in some SSX calls when a task wants
                           to refer to itself.
                           task_pri — the task priority. Tasks with the
                           highest priority are scheduled to run first.
                           Priorities range from 0 (highest priority) to
                           0xff (lowest priority).
                           task_ptr — a pointer to a function. (Its
                           typedef is in ssx.h.) Pass a pointer to the C
                           function that is to be used as a task. A
                           function used as a task must have no
                           parameters passed and return no value. A task
                           function is generally a loop without exit.

int ssx_task_delete        ssx_task_delete deletes the task with the
(unsigned char task_id)    task_id passed. If you pass in ID 0, the
                           calling task is deleted.

int ssx_wait_with_alarm    ssx_wait_with_alarm causes a task to wait for
(wait_q *wqptr, long       a message for the number of ticks passed. If
timeout)                   no message is received within the timeout
                           number of ticks, a TO_ERR is returned (see
                           ssx.h). ssx_wait_with_alarm returns SUCCESS
                           (see ssx.h) if the task gets a message on the
                           wait_q.

long ssx_get_time(void)    ssx_get_time gets the current clock ticks in
                           SSX.

unsigned char              ssx_change_priority changes the priority of
ssx_change_priority        the calling task, but does not immediately
(unsigned char)            reschedule tasks.
new_priority

void ssx_clock_tick(void)  ssx_clock_tick is called to inject a clock
                           tick into SSX. This is usually called by a
                           timer interrupt handler.

void ssx_lock(void)        ssx_lock disables task switching. Called
                           either at the entry to an interrupt handler
                           to prevent the interrupt handler from getting
                           switched out or from task code to reserve
                           control of the CPU for a while. Note: a task
                           cannot wait, delay, or otherwise cause itself
                           to become unrunnable while it has task
                           switching locked.

void ssx_run(void)         ssx_run is called after you have created at
                           least one task and started the executive
                           running.

void ssx_set_time(long     ssx_set_time sets the number of clock ticks
ticks)                     in SSX to the number passed in.

void ssx_stop(void)        ssx_stop is called to shutdown the SSX
                           executive. It returns where ssx_run was
                           called.

void ssx_switch(void)      ssx_switch forces rescheduling of tasks by
                           SSX. ssx_switch is usually called from within
                           the executive. It schedules the highest
                           priority task in the front of the ready
                           queue.

void ssx_task_delay(long   ssx_task_delay delays the calling task for
ticks)                     the number of ticks passed. It will be
                           scheduled back in after the number of ticks
                           have passed and when it is highest priority
                           on the ready queue.

void ssx_unlock(void)      ssx_unlock re-enables task switching. A
                           matching call to ssx_lock must already have
                           been made. Called at the exit of an interrupt
                           handler, or from task level code to release
                           the CPU to other tasks.

void ssx_wait(wait_q       ssx_wait causes a task to wait for a message
*wqptr)                    on the passed wait_q. The typedef for a
                           wait_q data structure is in the file ssx.h.
                           If there is a message waiting, ssx_wait
                           returns immediately. Ifthere is no message
                           waiting, ssx_wait schedules a new task while
                           the calling task waits for a message.