航空研究会 / Mbed 2 deprecated sahaquiel_1

Dependencies:   mbed MPU6050_2 HMC5883L_4 SDFileSystem3

Committer:
imanomadao
Date:
Sat Feb 08 08:08:47 2020 +0000
Revision:
42:dd36373a1b46
Parent:
41:d142afd3c2f7
a;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HARUKIDELTA 0:84ddd6d354e1 1 #include "mbed.h"
Skykon 3:c18342e4fddd 2 #include "MPU6050_DMP6.h"
taknokolat 6:166746820555 3 #include "HMC5883L.h"
taknokolat 12:083662bca47d 4 #include "SDFileSystem.h"
taknokolat 12:083662bca47d 5 #include "SkipperSv2.h"
taknokolat 12:083662bca47d 6 #include "falfalla.h"
Skykon 3:c18342e4fddd 7
taknokolat 7:8989a4b84695 8 void MoveCansat(char g_landingcommand);
Skykon 3:c18342e4fddd 9
Skykon 3:c18342e4fddd 10 Timer t;
Skykon 3:c18342e4fddd 11
imanomadao 42:dd36373a1b46 12 RawSerial raspi(PC_6,PC_7,115200); //uart6 raspi
Skykon 3:c18342e4fddd 13
HARUKIDELTA 5:8bfe95431ec0 14 /*通信用のpinは
HARUKIDELTA 5:8bfe95431ec0 15 PA_3(UART2_Rx) skipperウラ
HARUKIDELTA 5:8bfe95431ec0 16 PA_12(UART6_Rx) skipperオモテ USB端子より
HARUKIDELTA 5:8bfe95431ec0 17 PB_7 (UART1_Rx) skipperオモテ 6番目 TIM4_CH2
HARUKIDELTA 5:8bfe95431ec0 18 */
HARUKIDELTA 5:8bfe95431ec0 19
Skykon 3:c18342e4fddd 20
HARUKIDELTA 0:84ddd6d354e1 21 int main() {
imanomadao 42:dd36373a1b46 22 t.start();
imanomadao 42:dd36373a1b46 23 if(t>7){
imanomadao 42:dd36373a1b46 24 while(1){
imanomadao 42:dd36373a1b46 25 MoveCansat('F');
imanomadao 42:dd36373a1b46 26 wait(5);
imanomadao 42:dd36373a1b46 27 MoveCansat('S');
imanomadao 42:dd36373a1b46 28 wait(3);
imanomadao 42:dd36373a1b46 29 MoveCansat('R');
imanomadao 42:dd36373a1b46 30 wait(5);
imanomadao 42:dd36373a1b46 31 MoveCansat('S');
imanomadao 42:dd36373a1b46 32 wait(3);
imanomadao 42:dd36373a1b46 33 MoveCansat('L');
imanomadao 42:dd36373a1b46 34 wait(5);
imanomadao 42:dd36373a1b46 35 MoveCansat('S');
imanomadao 42:dd36373a1b46 36 wait(3);
imanomadao 42:dd36373a1b46 37 MoveCansat('B');
imanomadao 42:dd36373a1b46 38 wait(5);
imanomadao 42:dd36373a1b46 39 MoveCansat('S');
imanomadao 42:dd36373a1b46 40 wait(3);
taknokolat 29:5d239812ace6 41 }
imanomadao 42:dd36373a1b46 42 }
imanomadao 42:dd36373a1b46 43 return 0;
HARUKIDELTA 0:84ddd6d354e1 44 }
HARUKIDELTA 0:84ddd6d354e1 45
Skykon 3:c18342e4fddd 46
taknokolat 22:a19be3b505b7 47 void MoveCansat(char a)
HARUKIDELTA 0:84ddd6d354e1 48 {
taknokolat 22:a19be3b505b7 49 switch(a){
imanomadao 42:dd36373a1b46 50 case 'F': //MOVE_FORWARD
imanomadao 42:dd36373a1b46 51 raspi.printf("F\r\n");
HARUKIDELTA 27:f67efcee6509 52 break;
taknokolat 1:290e621741fd 53
imanomadao 42:dd36373a1b46 54 case 'R': //MOVE_RIGHT
imanomadao 42:dd36373a1b46 55 raspi.printf("R\r\n");
HARUKIDELTA 0:84ddd6d354e1 56 break;
taknokolat 1:290e621741fd 57
imanomadao 42:dd36373a1b46 58 case 'L': //MOVE_LEFT
imanomadao 42:dd36373a1b46 59 raspi.printf("L\r\n");
taknokolat 7:8989a4b84695 60 break;
taknokolat 37:8e273677500d 61
imanomadao 42:dd36373a1b46 62 case 'S': //STOP
imanomadao 42:dd36373a1b46 63 raspi.printf("S\r\n");
taknokolat 37:8e273677500d 64 break;
taknokolat 12:083662bca47d 65
imanomadao 42:dd36373a1b46 66 case 'B': //MOVE_BACK
imanomadao 42:dd36373a1b46 67 raspi.printf("B\r\n");
taknokolat 12:083662bca47d 68 break;
HARUKIDELTA 0:84ddd6d354e1 69 }
HARUKIDELTA 0:84ddd6d354e1 70 return;
taknokolat 1:290e621741fd 71 }
taknokolat 1:290e621741fd 72
imanomadao 42:dd36373a1b46 73
taknokolat 7:8989a4b84695 74
taknokolat 7:8989a4b84695 75
imanomadao 42:dd36373a1b46 76 /*void getSF_Serial_jevois(){
taknokolat 22:a19be3b505b7 77
taknokolat 22:a19be3b505b7 78 //pc.printf("jevois\r\n");
taknokolat 1:290e621741fd 79
taknokolat 1:290e621741fd 80
taknokolat 1:290e621741fd 81 static char SFbuf[16]={'Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q'};
taknokolat 1:290e621741fd 82
taknokolat 1:290e621741fd 83 static int bufcounter=0;
taknokolat 1:290e621741fd 84
taknokolat 1:290e621741fd 85
taknokolat 1:290e621741fd 86
taknokolat 1:290e621741fd 87 if(pc.readable()) { // 受信確認
taknokolat 1:290e621741fd 88
taknokolat 1:290e621741fd 89 SFbuf[bufcounter] = pc.getc(); // 1文字取り出し
taknokolat 1:290e621741fd 90 if(SFbuf[0]!='S'){
taknokolat 1:290e621741fd 91 //pc.printf("x");
taknokolat 1:290e621741fd 92 return;
taknokolat 1:290e621741fd 93 }
taknokolat 1:290e621741fd 94
taknokolat 1:290e621741fd 95
taknokolat 1:290e621741fd 96
taknokolat 41:d142afd3c2f7 97 //pc.printf("%c",SFbuf[bufcounter]);
taknokolat 1:290e621741fd 98
Skykon 3:c18342e4fddd 99 if(SFbuf[0]=='S' && bufcounter<5)bufcounter++;
taknokolat 1:290e621741fd 100
taknokolat 1:290e621741fd 101 if(bufcounter==5 && SFbuf[4]=='F'){
taknokolat 1:290e621741fd 102
taknokolat 1:290e621741fd 103 g_landingcommand = SFbuf[1];
taknokolat 2:f30666d7838b 104 wait_ms(31);//信号が速すぎることによる割り込み防止
taknokolat 1:290e621741fd 105 //pc.printf("%c",g_landingcommand);
taknokolat 1:290e621741fd 106 //wait_ms(20);
taknokolat 1:290e621741fd 107 //if(g_landingcommand=='Y')g_SerialTargetYAW = ConvertByteintoFloat(SFbuf[2], SFbuf[3]);
taknokolat 1:290e621741fd 108 bufcounter = 0;
taknokolat 1:290e621741fd 109 memset(SFbuf, 0, sizeof(SFbuf));
taknokolat 1:290e621741fd 110 NVIC_ClearPendingIRQ(USART2_IRQn);
taknokolat 1:290e621741fd 111 //pc.printf("command = %c, commandYAW = %f\r\n", g_landingcommand, g_SerialTargetYAW);
taknokolat 1:290e621741fd 112 }
taknokolat 1:290e621741fd 113
taknokolat 1:290e621741fd 114 else if(bufcounter>=5){
taknokolat 1:290e621741fd 115 //pc.printf("Communication Falsed.\r\n");
taknokolat 1:290e621741fd 116 memset(SFbuf, 0, sizeof(SFbuf));
taknokolat 1:290e621741fd 117 bufcounter = 0;
taknokolat 1:290e621741fd 118 NVIC_ClearPendingIRQ(USART2_IRQn);
taknokolat 1:290e621741fd 119 }
taknokolat 1:290e621741fd 120 }
taknokolat 1:290e621741fd 121
taknokolat 1:290e621741fd 122
taknokolat 1:290e621741fd 123 }
taknokolat 1:290e621741fd 124
taknokolat 1:290e621741fd 125
taknokolat 12:083662bca47d 126 void getSF_Serial_pi(){
taknokolat 2:f30666d7838b 127
taknokolat 7:8989a4b84695 128 //NVIC_DisableIRQ(USART2_IRQn);
taknokolat 1:290e621741fd 129
taknokolat 1:290e621741fd 130 static char SFbuf[16]={'Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q'};
taknokolat 1:290e621741fd 131
taknokolat 1:290e621741fd 132 static int bufcounter=0;
taknokolat 1:290e621741fd 133
taknokolat 1:290e621741fd 134
taknokolat 1:290e621741fd 135
taknokolat 1:290e621741fd 136 if(pc2.readable()) { // 受信確認
taknokolat 1:290e621741fd 137
taknokolat 1:290e621741fd 138 SFbuf[bufcounter] = pc2.getc(); // 1文字取り出し
taknokolat 1:290e621741fd 139 if(SFbuf[0]!='S'){
taknokolat 1:290e621741fd 140 //pc.printf("x");
taknokolat 1:290e621741fd 141 return;
taknokolat 1:290e621741fd 142 }
taknokolat 1:290e621741fd 143
taknokolat 1:290e621741fd 144
taknokolat 1:290e621741fd 145
taknokolat 41:d142afd3c2f7 146 //pc.printf("%c",SFbuf[bufcounter]);
taknokolat 1:290e621741fd 147
taknokolat 1:290e621741fd 148 if(SFbuf[0]=='S'&&bufcounter<5)bufcounter++;
taknokolat 1:290e621741fd 149
taknokolat 1:290e621741fd 150 if(bufcounter==5 && SFbuf[4]=='F'){
taknokolat 1:290e621741fd 151
taknokolat 1:290e621741fd 152 g_landingcommand = SFbuf[1];
taknokolat 2:f30666d7838b 153 wait_ms(31);//信号が速すぎることによる割り込み防止
taknokolat 1:290e621741fd 154 //pc.printf("%c",g_landingcommand);
taknokolat 1:290e621741fd 155 //wait_ms(20);
taknokolat 1:290e621741fd 156 //if(g_landingcommand=='Y')g_SerialTargetYAW = ConvertByteintoFloat(SFbuf[2], SFbuf[3]);
taknokolat 1:290e621741fd 157 bufcounter = 0;
taknokolat 1:290e621741fd 158 memset(SFbuf, 0, sizeof(SFbuf));
taknokolat 1:290e621741fd 159 NVIC_ClearPendingIRQ(USART2_IRQn);
taknokolat 1:290e621741fd 160 //pc.printf("command = %c, commandYAW = %f\r\n", g_landingcommand, g_SerialTargetYAW);
taknokolat 1:290e621741fd 161 }
taknokolat 1:290e621741fd 162
taknokolat 1:290e621741fd 163 else if(bufcounter>=5){
taknokolat 1:290e621741fd 164 //pc.printf("Communication Falsed.\r\n");
taknokolat 1:290e621741fd 165 memset(SFbuf, 0, sizeof(SFbuf));
taknokolat 1:290e621741fd 166 bufcounter = 0;
taknokolat 1:290e621741fd 167 NVIC_ClearPendingIRQ(USART2_IRQn);
taknokolat 1:290e621741fd 168 }
taknokolat 1:290e621741fd 169 }
taknokolat 2:f30666d7838b 170
taknokolat 7:8989a4b84695 171 //NVIC_EnableIRQ(USART2_IRQn);
taknokolat 1:290e621741fd 172
taknokolat 24:0ad1725c7849 173 }*/
taknokolat 12:083662bca47d 174