- Main Page
- Modules
- Data Structures
- Files
- Directories

# e_agenda.h File Reference

Manage the agendas (timer2). More...

## Data Structures
struct | AgendaType
| srtuct Agenda as chained list More...
## Defines
#define | AG_ALREADY_CREATED 1
#define | AG_NOT_FOUND 2
## Typedefs
typedef struct AgendaType | Agenda
## Functions
void | e_start_agendas_processing (void)
| Start the agendas processing.
void | e_end_agendas_processing (void)
| Stop all the agendas.
int | e_activate_agenda (void(*func)(void), int cycle)
| Activate an agenda.
int | e_destroy_agenda (void(*func)(void))
| Destroy an agenda.
int | e_set_agenda_cycle (void(*func)(void), int cycle)
| Change the cycle value of an agenda.
int | e_reset_agenda (void(*func)(void))
| Reset an agenda's counter.
int | e_pause_agenda (void(*func)(void))
| Pause an agenda.
int | e_restart_agenda (void(*func)(void))
| Restart an agenda previously paused.

## Detailed Description

Manage the agendas (timer2).

This module manage the agendas with the timer2.
An agenda is a structure made to work as chained list. It containts: the function you want to launch, the time setup between two launching events, a counter to measure the current time, a pointer to the next element of the list.
Each times the timer2 has an interrupt, all the agenda chained list is scanned to look if an agenda has to be treated according to the cycle value and current counter value.
If one (or more) agenda has to be treated, his callback function is launch.

Author:
  Code: Francesco Mondada, Lucas Meier
  Doc: Jonathan Besuchet

## Define Documentation

#define AG_ALREADY_CREATED 1

#define AG_NOT_FOUND 2

## Typedef Documentation

typedef struct AgendaType Agenda

## Function Documentation

int e_activate_agenda | ( | void(*)(void) | func,
|  | int | cycle |
| ) |  |  |

Activate an agenda.

Activate an agenda and allocate memory for him if there isn't already an agenda with the same callback function (the agenda is active but isn't processed if he has a null cycle value).

Parameters:

  | func | function called if the cycle value is reached by the counter
  | cycle | cycle value in millisec/10

Returns:
  EXIT_OK if the agenda has been created, exit the programme otherwise

int e_destroy_agenda | ( | void(*)(void) | func | ) |

Destroy an agenda.

Destroy the agenda with a given callback function.

Parameters:

  | func | function to test

Returns:
  EXIT_OK if the agenda has been destroyed, AG_NOT_FOUND otherwise

Destroy the agenda with a given callback function

Parameters:

  | func | function to test

Returns:
  int return the success of the destruction (EXIT_OK for successfull, AG_NOT_FOUND for unsuccessfull).

void e_end_agendas_processing | ( | void |  | ) |

Stop all the agendas.

Stop all the agendas by disabling Timer2

Warning:
  the memory allocated for the agenda isn't freed, use e_destroy_agenda(void (*func)(void)) for that.

See also:
  e_destroy_agenda

int e_pause_agenda | ( | void(*)(void) | func | ) |

Pause an agenda.

Pause an agenda but do not reset its information.

Parameters:

  | func | function to pause

Returns:
  EXIT_OK the agenda has been paused, AG_NOT_FOUND otherwise

Pause an agenda but do not reset its information.

Parameters:

  | func | function to pause

int e_reset_agenda | ( | void(*)(void) | func | ) |

Reset an agenda's counter.

Reset an agenda's counter with a given callback function.

Parameters:

  | func | function to reset

Returns:
  EXIT_OK if the cycle of the agenda has been reseted, AG_NOT_FOUND otherwise

Warning:
  This function RESET the agenda, if you just want a pause tell e_pause_agenda(void (*func)(void))

See also:
  e_pause_agenda

Reset an agenda's counter.

Reset an agenda's counter with a given callback function

Parameters:

  | func | function to reset

int e_restart_agenda | ( | void(*)(void) | func | ) |

Restart an agenda previously paused.

Restart an agenda previously paused.

Parameters:

  | func | function to restart

Returns:
  EXIT_OK if he agenda has been restarted, AG_NOT_FOUND otherwise

See also:
  e_pause_agenda

Restart an agenda previously paused

Parameters:

  | func | function to restart

int e_set_agenda_cycle | ( | void(*)(void) | func,
|  | int | cycle |
| ) |  |  |

Change the cycle value of an agenda.

Change the cycle value of an agenda with a given callback function.

Parameters:

  | func | function to test
  | cycle | new cycle value in millisec/10

Returns:
  EXIT_OK if the cycle of the agenda has been modified, AG_NOT_FOUND otherwise

void e_start_agendas_processing | ( | void |  | ) |

Start the agendas processing.

Start the agendas processing by starting the Timer2.

Start the agendas processing.

Start the agendas processing by initialising the accounting structures.
Don't activate any timer which is done by e_start_timer_processing.

See also:
  e_start_timer_processing