Raharja Agie / Mbed 2 deprecated Mini-X
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "define.h"
00003 #include "setup.h"
00004 #include "struct.h"
00005 
00006 int loop_cnt = 0, init_cnt = 0;
00007 
00008 #include "pid.h"
00009 #include "i2c.h"
00010 #include "rc.h"
00011 
00012 #include "2gcs.h"
00013 #include "gps.h"
00014 #include "2fcs.h"
00015 
00016 #include "ahrs.h"
00017 
00018 void init(){
00019     Yaw_ref = fcc.yaw;
00020     init_cnt++;
00021 }    
00022     
00023 int main() {
00024     setup();
00025     securinit();     
00026     rc.rise(&PPM_rise);    // attach the address of the PPM_rise function to the rising edge   
00027     wait(0.5);
00028     
00029     while(1) {           // wait around, interrupts will interrupt this!        
00030         if(ahrs.readable())ahrs_rec();
00031         
00032         if(radio.readable())radio.putc(radio.getc());//getGCS();
00033         if(loop_cnt>10000){
00034             getrc();
00035             pid();
00036             moteq();
00037             updatei2c();        
00038             loop_cnt = 0;   
00039             //rcprint();               
00040             if(bat > 0.8) myled = 1;
00041             else myled = !myled;
00042         }   
00043         loop_cnt++;                  
00044        
00045     }
00046 }
00047 
00048