#include <aversive.h>
#include <scheduler_config.h>
Go to the source code of this file.
Defines | |
#define | TIMER_UNIT_FLOAT ( 65536000000.0 / (double)(CONFIG_QUARTZ) ) |
#define | SCHEDULER_UNIT_FLOAT ( TIMER_UNIT_FLOAT * (double)SCHEDULER_CLOCK_PRESCALER ) |
#define | SCHEDULER_UNIT ( (unsigned long) SCHEDULER_UNIT_FLOAT ) |
#define | SCHEDULER_PERIODICAL 0 |
#define | SCHEDULER_SINGLE 1 |
#define | SCHEDULER_DEFAULT_PRIORITY 128 |
Functions | |
void | scheduler_init (void) |
int8_t | scheduler_add_event (uint8_t unicity, void(*f)(void *), void *data, uint16_t period, uint8_t priority) |
int8_t | scheduler_del_event (int8_t num) |
void | scheduler_interrupt (void) |
uint8_t | scheduler_disable_save (void) |
void | scheduler_enable_restore (uint8_t old_prio) |
Functions with a high priority value will be call before others (default is 128).
This module uses Timer 0
Definition in file scheduler.h.
#define SCHEDULER_DEFAULT_PRIORITY 128 |
Definition at line 124 of file scheduler.h.
#define SCHEDULER_PERIODICAL 0 |
Definition at line 121 of file scheduler.h.
#define SCHEDULER_SINGLE 1 |
Definition at line 122 of file scheduler.h.
#define SCHEDULER_UNIT ( (unsigned long) SCHEDULER_UNIT_FLOAT ) |
Definition at line 115 of file scheduler.h.
Referenced by main(), mf2_client_send(), SIGNAL(), and time_increment().
#define SCHEDULER_UNIT_FLOAT ( TIMER_UNIT_FLOAT * (double)SCHEDULER_CLOCK_PRESCALER ) |
SCHEDULER_UNIT is the number of microseconds between each scheduler interruption. We can use it like this : scheduler_add_periodical_event(f, 1000L/SCHEDULER_UNIT); The function f will be called every ms.
Definition at line 114 of file scheduler.h.
#define TIMER_UNIT_FLOAT ( 65536000000.0 / (double)(CONFIG_QUARTZ) ) |
TIME_UNIT is the number of microseconds between each interruption if the prescaler equals 1
Definition at line 106 of file scheduler.h.
int8_t scheduler_add_event | ( | uint8_t | unicity, | |
void(*)(void *) | f, | |||
void * | data, | |||
uint16_t | period, | |||
uint8_t | priority | |||
) |
Add an event to the event table. Return the id of the event on succes and -1 on error You can use static inline funcs below for simpler use.
Alloc an event, and fill its field, then mark it as active. return its index in the table, or -1 if no evt is available
Definition at line 50 of file scheduler_add.c.
References event_t::current_time, event_t::data, parse_symbols::f, event_t::f, g_tab_event, IRQ_LOCK, IRQ_UNLOCK, event_t::period, event_t::priority, SCHEDULER_EVENT_ACTIVE, and event_t::state.
int8_t scheduler_del_event | ( | int8_t | num | ) |
Dels an event from the table by its ID. If there is no event, nothing is done.
Definition at line 26 of file scheduler_del.c.
References g_tab_event, IRQ_LOCK, IRQ_UNLOCK, SCHEDULER_EVENT_ACTIVE, SCHEDULER_EVENT_DELETING, SCHEDULER_EVENT_FREE, SCHEDULER_EVENT_SCHEDULED, and event_t::state.
Referenced by SIGNAL().
uint8_t scheduler_disable_save | ( | void | ) |
Temporarily disable scheduler events. You may loose precision in events schedule. It returns the current priority of the scheduler.
Definition at line 34 of file scheduler_interrupt.c.
Referenced by AX12_send().
void scheduler_enable_restore | ( | uint8_t | old_prio | ) |
Re-enable scheduler after a call to scheduler_disable_save().
Definition at line 42 of file scheduler_interrupt.c.
Referenced by AX12_send().
void scheduler_init | ( | void | ) |
Initialisation of the module
init all global data
Definition at line 38 of file scheduler.c.
References CS00_REG, DUMP_EVENTS, g_tab_event, and TOIE0_REG.
Referenced by main().
void scheduler_interrupt | ( | void | ) |
Function called by the interruption. It is public in case of host version, because you have to call it by hand. In AVR version, you don't have to do anything with this function, it is called automatilcally by the timer interruption.
this function is called from a timer interruption. If an event has to be scheduled, it will execute the fonction (IRQ are allowed during the execution of the function). This interruption can be interrupted by itself too, in this case only events with a higher priority can be scheduled.
We assume that this function is called from a SIGNAL(), with global interrupt flag disabled --> that's why we can use cli() and sei() instead of IRQ_LOCK(flags).
Definition at line 59 of file scheduler_interrupt.c.
References cli, event_t::current_time, event_t::data, DUMP_EVENTS, event_t::f, g_tab_event, i, event_t::period, event_t::priority, SCHEDULER_EVENT_ACTIVE, SCHEDULER_EVENT_DELETING, SCHEDULER_EVENT_FREE, SCHEDULER_EVENT_SCHEDULED, sei, SLIST_FIRST, SLIST_FOREACH, SLIST_HEAD, SLIST_INIT, SLIST_INSERT_AFTER, SLIST_INSERT_HEAD, SLIST_NEXT, and event_t::state.