A(rduino) OS
Simple Task Scheduler for Arduino Development Board
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
aos_common.c File Reference
#include "aos_common.h"
#include "aos_task.h"
#include "aos_sched.h"
#include "timer_common.h"
#include <avr/interrupt.h>
#include <string.h>
#include <avr/sleep.h>

Go to the source code of this file.

Functions

static void _aos_idle_task (void *a_data UNUSED)
 idle task definition More...
 
 if (!_aos_common_isr_interrupted_get())
 tick interrupt definition More...
 
 AOS_CTX_RESTORE ()
 
 reti ()
 
void aos_init (uint32_t a_freq)
 initialize the system More...
 
void aos_common_hook_install (aos_hook_t a_hook, aos_hook_cb_t a_hook_cb)
 install a specific system hook callback. More...
 
__inline__ void _aos_common_hook_exec (aos_hook_t a_hook)
 execute a specified hook type More...
 
void aos_run ()
 launch the scheduler and all tasks More...
 
__inline__ aos_systime_t aos_common_systime_get ()
 return number of ticks since the system start More...
 
__inline__ aos_sys_status_t aos_common_sys_state_get ()
 get the system state More...
 
__inline__ void _aos_common_sys_state_set (aos_sys_status_t a_state)
 set the system state More...
 
__inline__ uint8_t _aos_common_isr_interrupted_get ()
 get the ISR interrupted flag More...
 
__inline__ struct task_cbaos_common_current_get ()
 get the currently scheduled and running tasks control block More...
 
__inline__ void _aos_common_isr_interrupted_set (uint8_t a_isr_int_flag)
 set the ISR interrupted flag More...
 
void aos_init_watchdog ()
 
void aos_clear_watchdog ()
 

Variables

volatile struct aos_sys _g_sys
 AOS system status holder, global variable. More...
 

Function Documentation

__inline__ void _aos_common_hook_exec ( aos_hook_t  a_hook)

execute a specified hook type

This is a private API and should not be called from outside.

Parameters
a_hookhook type

Definition at line 171 of file aos_common.c.

__inline__ uint8_t _aos_common_isr_interrupted_get ( )

get the ISR interrupted flag

This is a private API and should not be called from outside. Check if tick interrupt interrupted an ISR.

Returns
true if tick interrupt interrupted an ISR

Definition at line 223 of file aos_common.c.

__inline__ void _aos_common_isr_interrupted_set ( uint8_t  a_isr_int_flag)

set the ISR interrupted flag

This is a private API and should not be called from outside.

Parameters
a_isr_int_flagset if tick interrupt interrupted an ISR

Definition at line 235 of file aos_common.c.

__inline__ void _aos_common_sys_state_set ( aos_sys_status_t  a_state)

set the system state

This is a private API and should not be called from outside.

Parameters
a_stateappropriate system state value

Definition at line 216 of file aos_common.c.

static void _aos_idle_task ( void *a_data  UNUSED)
static

idle task definition

Parameters
a_dataprivate data for the task

Definition at line 49 of file aos_common.c.

void aos_clear_watchdog ( )

Definition at line 249 of file aos_common.c.

__inline__ struct task_cb* aos_common_current_get ( )

get the currently scheduled and running tasks control block

Returns
control block

Definition at line 229 of file aos_common.c.

void aos_common_hook_install ( aos_hook_t  a_hook,
aos_hook_cb_t  a_hook_cb 
)

install a specific system hook callback.

The hook callbacks should not block and should be as short as possible. There is one exception to that rule, which is the stack corruption detection hook callback - obviously you don't want to return from that hook, since the system is probably in unknown condition.

Parameters
a_hookhook type
a_hook_cbhook callback - pointer to a function performing the hook action.
Examples:
hooks_01.c.

Definition at line 165 of file aos_common.c.

__inline__ aos_sys_status_t aos_common_sys_state_get ( )

get the system state

Returns current system state (have a look at aos_sys_status_t enumeration for possible values)

Returns
system state enumeration

Definition at line 210 of file aos_common.c.

__inline__ aos_systime_t aos_common_systime_get ( )

return number of ticks since the system start

Returns
number of ticks from system boot

Definition at line 204 of file aos_common.c.

AOS_CTX_RESTORE ( )
void aos_init ( uint32_t  a_freq)

initialize the system

Initializes the internal system data structures to known conditions. Zeros _g_sys static variable, creates an idle task and sets everything up, so the system is ready to accept new tasks being created and to be started

Parameters
a_freqtick frequency
Examples:
generic_01.c, hooks_01.c, list_01.c, list_02.c, sched_01.c, sched_02.c, semaphores_01.c, and timer_01.c.

Definition at line 114 of file aos_common.c.

void aos_init_watchdog ( )

Definition at line 243 of file aos_common.c.

void aos_run ( )

launch the scheduler and all tasks

From now on, the system will start execution. This call is blocking and should never return.

Examples:
generic_01.c, hooks_01.c, list_01.c, list_02.c, sched_01.c, sched_02.c, semaphores_01.c, and timer_01.c.

Definition at line 177 of file aos_common.c.

if ( _aos_common_isr_interrupted_get())

tick interrupt definition

Definition at line 85 of file aos_common.c.

reti ( )

Variable Documentation

volatile struct aos_sys _g_sys

AOS system status holder, global variable.

global system context, declared in aos_common

global system context defined in aos_common

Definition at line 40 of file aos_common.c.