201903_14ISEで実際に使用した開放用プログラム. 使用マイコンがNUCLES-F303K8なので注意

Dependencies:   mbed Madgwick MPU6050 Kalman BMP180

Revision:
10:1a626929850e
Parent:
9:42b4d337d4cc
Child:
11:c90db1500720
--- a/main.cpp	Sat Mar 09 12:23:07 2019 +0000
+++ b/main.cpp	Sun Mar 10 03:41:56 2019 +0000
@@ -29,6 +29,7 @@
 Serial pc(PA_2, PA_3);
 Serial gps(PA_9, PA_10);
 DigitalOut myled(PA_15);
+DigitalOut ES920_RST(PA_5);
 Timer timer_open;
 Timer timer_data;
 Ticker tic_data;
@@ -61,6 +62,8 @@
 char f[]="Receive";
 
 void main(){
+    ES920_RST = 0;
+    myled =0;
     /*ローカル変数*/
     float acc[3],acc_buff[10],gyro[3],gyro_buff[10],acc_abs;
     float alt_buff[10],alt_md;
@@ -69,7 +72,6 @@
     char gps_data[256];
     /*センサの初期化等*/
     pc.baud(38400);
-    gps.baud(115200);
     mpu.setAcceleroRange(3);
     bmp.Initialize(64,BMP180_OSS_ULTRA_LOW_POWER);
 
@@ -86,21 +88,20 @@
     pc.printf("Hello World!\r\n");
     wait(1.0);
     pc.printf("f:Flight_mode_on\r\n");
-    gps.printf("f:Flight_mode_on\r\n");
     wait(1.0);
     timer_data.start();
     while(1){
         switch(Phase){
             case STANDBY:
-                //gps.printf("Phase_STANDBY\r\n");
-                /*入力待ち*/
-                //tic_data.attach(&_SendData, 1.0/RATE_DATA);
-                servo();
-                //c[i] = pc.getc();
-                //gps.printf("%c",c[i]);
-                //i++;
-                //if(c[i] == '\n') i=0;
-                //wait(1.0);
+                /*サーボ入力待ち*/
+                //servo();
+                c[0]=pc.getc();
+                if(c[0] == 'o') myled = 1;
+                if(c[0] == 'l') myled = 0;
+                if(c[0] == 'f'){
+                //pc.printf("flight_mode\r\n");
+                Phase = LAUNCH;
+                }
                 break;
                 
             case LAUNCH:
@@ -208,7 +209,6 @@
                 }
                 else if((alt_max-alt_md) > ALT_JUDGE_OPEN){
                     cnt_judge++;
-                    //time_judge = timer_open.read();
                 }
 
                 //if((timer_open.read()-time_judge) - TIME_JUDGE_CNT > 0) cnt_judge=0;
@@ -218,43 +218,8 @@
                 }
                 break;
             case RECOVERY:
-                /*while(1){
-                    if(gps.readable()){
-                        gps_data[cnt_gps] = gps.getc();
-                        if(gps_data[cnt_gps] == '$' || cnt_gps ==256){
-                            cnt_gps = 0;
-                            memset(gps_data,'\0',256);
-                        }else if(gps_data[cnt_gps] == '\r'){
-                            float world_time, lon_east, lat_north;
-                            int rlock, sat_num;
-                            char lat,lon;
-                            if(sscanf(gps_data,"GPGGA,%f,%f,%c,%f,%c,%d,%d",&world_time,&lat_north,&lat,&lon_east,&lon,&rlock,&sat_num)>=1){
-                                if(rlock==1){
-                                    lat_north = _DMS2DEG(lat_north);
-                                    lon_east = _DMS2DEG(lon_east);
-                                    //pc.printf("%s\r\n",gps_data);
-                                    //pc.printf("Lat:%f,Lon:%f\r\ntime:%f,sat_num:%d\r\n",lat_north,lon_east,world_time,sat_num);
-                                    int japan_time = int(world_time) - 9;
-                                    pc.printf("Lat:%f,Lon:%f,time:%d,max_alt:%f\r\n",lat_north,lon_east,world_time,alt_max);
-                                    break;
-                                }else{
-                                    //pc.printf("%s\r\n",gps_data);
-                                    pc.printf("NoGPSSignal,max_alt:%f\r\n",alt_max);
-                                    break;
-                                }
-                            }else{
-                                //pc.printf("No_Satellite_signal\r\n");
-                            }
-                        }else{
-                            cnt_gps++;
-                        }
-                }
-    }
- 
-                //Phase = SEA;*/
                 break;
             case SEA:
-                    
                 break;
         }
     }
@@ -398,6 +363,20 @@
                         //pc.printf("Lat:%f,Lon:%f\r\ntime:%f,sat_num:%d\r\n",lat_north,lon_east,world_time,sat_num);
                         int japan_time = int(world_time) - 9;
                         pc.printf("Lat:%f,Lon:%f,MAX_ALT:%f\r\n",lat_north,lon_east,alt_max);
+                        for(i=0;i<2;i++){
+                            c[i]=pc.getc();
+                        }
+                        //pc.printf("%c",c[1]);
+                        if(c[1]!='O'){
+                            ES920_RST = 1;
+                            wait(0.1);
+                            ES920_RST = 0;
+                            wait(1.0);
+                            myled = 1;
+                        }else{
+                            myled = 0;
+                        }
+                        
                         break;
                     }else{
                         //pc.printf("%s\r\n",gps_data);