MegaWiFi 1.5
MegaWiFi API documentation
tsk

Tasking routines related functions. More...

Macros

#define FPS   60
 Frames per second (60 on NTSC consoles, 50 on PAL machines) More...
 
#define MS_TO_FRAMES(ms)   (((ms)*FPS/500 + 1)/2)
 Converts milliseconds to frames, rounding to the nearest. More...
 
#define TSK_PEND_FOREVER   -1
 Timeout value to use for infinite waits. More...
 

Functions

void vint_cb_set (void(*vint_cb)(void))
 
void tsk_user_set (void(*user_tsk)(void))
 
void tsk_user_yield (void)
 
bool tsk_super_pend (int16_t wait_tout)
 
void tsk_super_post (bool force_ctx_sw)
 

Detailed Description

Tasking routines related functions.

Author
Jesus Alonso (doragasu)
Date
2021
Note
These functions are implemented in boot/sega.s

Macro Definition Documentation

◆ FPS

#define FPS   60

Frames per second (60 on NTSC consoles, 50 on PAL machines)

Definition at line 22 of file tsk.h.

◆ MS_TO_FRAMES

#define MS_TO_FRAMES (   ms)    (((ms)*FPS/500 + 1)/2)

Converts milliseconds to frames, rounding to the nearest.

Definition at line 25 of file tsk.h.

◆ TSK_PEND_FOREVER

#define TSK_PEND_FOREVER   -1

Timeout value to use for infinite waits.

Definition at line 28 of file tsk.h.

Function Documentation

◆ tsk_super_pend()

bool tsk_super_pend ( int16_t  wait_tout)

Block supervisor task and resume user task. Supervisor task will not resume execution until super_tsk_post() is called from user task or a timeout happens..

Parameters
[in]wait_toutMaximum number of frames to wait while blocking. Use TSK_PEND_FOREVER for an infinite wait, or a positive number (greater than 0) for a specific number of frames.
Returns
false if task was awakened from user task, or true if timeout occurred.

◆ tsk_super_post()

void tsk_super_post ( bool  force_ctx_sw)

Resume a blocked supervisor task. Must be called from user task.

Parameters
[in]force_ctx_swIf true, immediately causes a context switch to supervisor task. If false, context switch will not occur until the VBLANK interrupt.

◆ tsk_user_set()

void tsk_user_set ( void(*)(void)  user_tsk)

Configure the task used as user task. Must be invoked once before calling tsk_user_yield().

Parameters
[in]user_tskA function pointer to the user task to configure.

◆ tsk_user_yield()

void tsk_user_yield ( void  )

Yield from supervisor task to user task. The user task will resume and will use all the available CPU time until the next vertical blanking interrupt, that will resume the supervisor task.

◆ vint_cb_set()

void vint_cb_set ( void(*)(void)  vint_cb)

Configure the VBLANK interrupt attention callback. Note that the function is run in exception context.

Parameters
[in]Functionpointer to the VBLANK callback.
Warning
Callback is run in exception context. Use rte (instead of rts) if function is coded in assembly language, or attribute((interrupt)) for C functions.