cocoOS  5.0.3
os_kernel.c File Reference
#include "cocoos.h"

Functions

void os_init (void)
 
void os_start (void)
 
void os_tick (void)
 
void os_sub_tick (uint8_t id)
 
void os_sub_nTick (uint8_t id, uint32_t nTicks)
 
uint8_t os_running (void)
 
uint8_t os_get_running_tid (void)
 

Variables

uint8_t running_tid
 
uint8_t last_running_task
 
uint8_t running
 

Function Documentation

uint8_t os_get_running_tid ( void  )
void os_init ( void  )

Initializes the scheduler.

Returns
None.
Remarks
Usage:
Should be called early in system setup, before starting the task execution
1 int main(void) {
2 system_init();
3 os_init();
4 ...
5 }
uint8_t os_running ( void  )
void os_start ( void  )

Starts the task scheduling

Returns
None.
Remarks
Usage:
Should be the last line of main.
1 int main(void) {
2  system_init();
3  os_init();
4  task_create( myTaskProc, 1, NULL, 0, 0 );
5  ...
6  os_start();
7  return 0;
8 }
void os_sub_nTick ( uint8_t  id,
uint32_t  nTicks 
)

Tick function driving the sub clocks. Increments the tick count with nTicks.

Parameters
idsub clock id, allowed range 1-255.
nTicksincrement size, 16 bit value.
Returns
None.
Remarks
Usage:
Could be called at any desired rate to trigger timeouts. Called from a task or from an interrupt ISR.
1 ISR(SIG_OVERFLOW0) {
2  ...
3  os_sub_nTick( 2, 10 );
4 }
void os_sub_tick ( uint8_t  id)

Tick function driving the sub clocks

Parameters
idsub clock id, allowed range 1-255
Returns
None.
Remarks
Usage:
Could be called at any desired rate to trigger timeouts. Called from a task or from an interrupt ISR.
1 ISR(SIG_OVERFLOW0) {
2  ...
3  os_sub_tick(2);
4 }
void os_tick ( void  )

Tick function driving the kernel

Returns
None.
Remarks
Usage:
Should be called periodically. Preferably from the clock tick ISR.
1 ISR(SIG_OVERFLOW0) {
2  ...
3  os_tick();
4 }

Variable Documentation

uint8_t last_running_task
uint8_t running
uint8_t running_tid