Hi David,
the modules mechanism should (almost) provide the features you
require. You will have to write:
- a module description, a file in conf/modules/ : In your case, it
will contain only a call to your init function, a call to your
periodic task and the declaration of .c and .h files:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="cld">
<header>
<file name="cld.h"/>
</header>
<init fun="cld_init()"/>
<periodic fun="cld_check()" period="1./60" autorun="TRUE"/>
<makefile>
<file name="cld.c"/>
<flag name="ADC_CLD" "ADC_7"/>
</makefile>
</module>
- your .c and .h files in the sw/airborne/modules/cld/ folder:
---8<--- .h ---------
...
#include "std.h"
bool cld_launch_detected;
...
---8<--- .c ---------
#include "cld.h"
void cld_init(void) {
... initialisation code for your adc ...
cld_launch_detected = false;
}
void cld_check(void) {
if (... check condition...) {
cld_launch_detected = false;
cld_cld_status = MODULES_STOP; // stop calling me
}
- your flight plan, for example using an exception in the Holding
Point block (in basic.xml):
<block name="Holding point">
<exception cond="cld_launch_detected" deroute="Takeoff"/>
...
</block>
- and finally in your airframe file:
<modules>
<load name="cld.xml"/>
</modules>
...
# in the makefile section:
ap.CFLAGS += -DUSE_MODULES
In the current implementation, 60Hz is the maximum frequency for a
periodic task in a module. If you really need more ... let us know :-)
Hope this is enough
And feel free to update the wiki :-)
--Pascal