Code for an autonomous plane I'm building. Includes process scheduling, process communication, and hardware sensor interfacing (via I2C). NOTE: currently in development, source code will be updated frequently.
Diff: control.cpp
- Revision:
- 0:0c627ff4c5ed
- Child:
- 1:1abb115c2005
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/control.cpp Wed Oct 30 02:31:43 2013 +0000 @@ -0,0 +1,43 @@ +#include "control.h" +#include "sensor.h" +#include "steps.h" +#include "mbed.h" + +#define MAXPROC 15 + +process procs[MAXPROC] = {0}; + +void schedule(); +void init_procs(); + + +int main() +{ + init_procs(); + while (true) + { + get_sensor_data(); + schedule(); + } +} + +void init_procs() +{ + procs[0].status = READY; + procs[0].start = &get_sensor_data; + return; +} + +void schedule() +{ + for (int i=0; i<MAXPROC; i++) + { + process proc = procs[i]; + if(proc.status == READY) + { + proc.start(); + return; + } + } +} + \ No newline at end of file