From 9d3573134462335051e46b990e97e1d32bef4b29 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 31 Mar 2008 13:03:47 +0200 Subject: * digital/io/src: - adapted FSM to AVR program. --- digital/io/src/fsm_templates/template_cb.h | 10 +++++ digital/io/src/fsm_templates/template_cb_decl.h | 6 +++ digital/io/src/fsm_templates/template_cb_impl.c | 9 +++++ digital/io/src/fsm_templates/template_cb_skel.c | 11 ++++++ digital/io/src/fsm_templates/template_fsm.c | 25 ++++++++++++ digital/io/src/fsm_templates/template_fsm.h | 52 +++++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 digital/io/src/fsm_templates/template_cb.h create mode 100644 digital/io/src/fsm_templates/template_cb_decl.h create mode 100644 digital/io/src/fsm_templates/template_cb_impl.c create mode 100644 digital/io/src/fsm_templates/template_cb_skel.c create mode 100644 digital/io/src/fsm_templates/template_fsm.c create mode 100644 digital/io/src/fsm_templates/template_fsm.h (limited to 'digital/io/src/fsm_templates') diff --git a/digital/io/src/fsm_templates/template_cb.h b/digital/io/src/fsm_templates/template_cb.h new file mode 100644 index 00000000..4f4deeec --- /dev/null +++ b/digital/io/src/fsm_templates/template_cb.h @@ -0,0 +1,10 @@ +#ifndef %(prefix)s_cb_h +#define %(prefix)s_cb_h +/* + * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT! + * + * %(name)s callbacks declaration. + * +%(*comments)s */ + +%(states_template,template_cb_decl.h)s#endif /* %(prefix)s_cb_h */ diff --git a/digital/io/src/fsm_templates/template_cb_decl.h b/digital/io/src/fsm_templates/template_cb_decl.h new file mode 100644 index 00000000..fd72d678 --- /dev/null +++ b/digital/io/src/fsm_templates/template_cb_decl.h @@ -0,0 +1,6 @@ +/* + * %(state)s =%(event)s=> +%(*branches_to)s */ +fsm_branch_t +%(prefix)s__%(state)s__%(event)s (void); + diff --git a/digital/io/src/fsm_templates/template_cb_impl.c b/digital/io/src/fsm_templates/template_cb_impl.c new file mode 100644 index 00000000..91ff4fbb --- /dev/null +++ b/digital/io/src/fsm_templates/template_cb_impl.c @@ -0,0 +1,9 @@ +/* + * %(state)s =%(event)s=> +%(*branches_to)s */ +fsm_branch_t +%(prefix)s__%(state)s__%(event)s (void) +{ +%(returns)s +} + diff --git a/digital/io/src/fsm_templates/template_cb_skel.c b/digital/io/src/fsm_templates/template_cb_skel.c new file mode 100644 index 00000000..bf0a0639 --- /dev/null +++ b/digital/io/src/fsm_templates/template_cb_skel.c @@ -0,0 +1,11 @@ +/* + * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT! + * + * Skeleton for %(name)s callbacks implementation. + * +%(*comments)s */ +#include "common.h" +#include "fsm.h" +#include "%(prefix)s_cb.h" + +%(states_template,template_cb_impl.c)s diff --git a/digital/io/src/fsm_templates/template_fsm.c b/digital/io/src/fsm_templates/template_fsm.c new file mode 100644 index 00000000..87e52f33 --- /dev/null +++ b/digital/io/src/fsm_templates/template_fsm.c @@ -0,0 +1,25 @@ +/* + * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT! + * + * %(name)s + * +%(*comments)s */ +#include "common.h" +#include "fsm.h" +#include "%(prefix)s_cb.h" + +#define NULL ((void *)0L) + +/* %(name)s transition table. */ +static const fsm_transition_t +%(prefix)s_transition_table[%(PREFIX)s_STATE_NB][%(PREFIX)s_EVENT_NB] = { +%(transition_table)s}; + +/* %(name)s context. */ +fsm_t %(prefix)s_fsm = { + &%(prefix)s_transition_table[0][0], + %(PREFIX)s_EVENT_NB, + %(PREFIX)s_STATE_%(initial)s, + %(PREFIX)s_STATE_%(initial)s, +}; + diff --git a/digital/io/src/fsm_templates/template_fsm.h b/digital/io/src/fsm_templates/template_fsm.h new file mode 100644 index 00000000..9ac98895 --- /dev/null +++ b/digital/io/src/fsm_templates/template_fsm.h @@ -0,0 +1,52 @@ +#ifndef %(prefix)s_fsm_h +#define %(prefix)s_fsm_h +/* + * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT! + * + * %(name)s + * +%(*comments)s */ + +/* %(name)s states. */ +enum %(prefix)s_state_t +{ +%(states)s %(PREFIX)s_STATE_NB +}; + +/* %(name)s events. */ +enum %(prefix)s_event_t +{ +%(events)s %(PREFIX)s_EVENT_NB +}; + +/* This macro enables checks for branches used in the wrong state/event + * combination. */ +#ifdef HOST +# define _BRANCH(state, event, to) \ + ((%(PREFIX)s_STATE_ ## state) << 16 \ + | (%(PREFIX)s_EVENT_ ## event) << 8 \ + | (%(PREFIX)s_STATE_ ## to)) +#else +# define _BRANCH(state, event, to) \ + ((%(PREFIX)s_STATE_ ## to)) +#endif + +/* %(name)s branches. */ +enum %(prefix)s_branch_t +{ +%(branches)s}; + +#undef _BRANCH + +/* Value to return to follow the only branch. */ +#define %(prefix)s_next(state, event) \ + %(PREFIX)s_BRANCH__ ## state ## __ ## event ## __ + +/* Value to return to follow a given branch. */ +#define %(prefix)s_next_branch(state, event, branch) \ + %(PREFIX)s_BRANCH__ ## state ## __ ## event ## __ ## branch + +/* %(name)s context. */ +extern fsm_t %(prefix)s_fsm; + +#endif /* %(prefix)s_fsm_h */ -- cgit v1.2.3