操舵ソースコードの第一稿です。 メイン基盤用のソースコードです。

Dependencies:   ADXL345_I2C INA226 mbed SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
YusukeWakuta
Date:
Wed Jan 20 13:33:43 2016 +0000
Parent:
0:77917230ce6d
Commit message:
1?20?????

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 77917230ce6d -r 247ccea89495 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Wed Jan 20 13:33:43 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
diff -r 77917230ce6d -r 247ccea89495 main.cpp
--- a/main.cpp	Fri Jan 15 15:32:09 2016 +0000
+++ b/main.cpp	Wed Jan 20 13:33:43 2016 +0000
@@ -18,10 +18,8 @@
     signed char rec_data_L[BUFFER];
     //signed char rec_data_R;
     rs485R.putc('P');
-    rs485L.putc('P');
     wait_ms(1);
     Driver_R = 0;
-    Driver_L = 0;
     wait_ms(120);
     if(rs485R.readable()) {
         for(int i = 0; i < BUFFER; i++) {
@@ -46,91 +44,96 @@
                     case 'C':
                         pc.printf("  C : %5i",rec_data_R[i + 1]);
                         break;
-                        }
+                }
+            }
+        }
+    }
+    pc.printf("\t");
+
+    rs485L.putc('P');
+    Driver_L = 0;
+    wait_ms(120);
+    if(rs485L.readable()) {
+        for(int i = 0; i < BUFFER; i++) {
+            rec_data_L[i] = rs485L.getc();
+        }
+        for(int i = 0; i < BUFFER; i++) {
+            if(rec_data_L[i + 1] != -1) {
+                pc.printf("LEFT : ");
+                switch(rec_data_L[i]) {
+                    case 'X':
+                        pc.printf("  X : %5i",rec_data_L[i + 1]);
+                        break;
+                    case 'Y':
+                        pc.printf("  Y : %5i",rec_data_L[i + 1]);
+                        break;
+                    case 'Z':
+                        pc.printf("  Z : %5i",rec_data_L[i + 1]);
+                        break; 
+                    case 'V':
+                        pc.printf("  V : %5i",rec_data_L[i + 1]);
+                        break;
+                    case 'C':
+                        pc.printf("  C : %5i",rec_data_L[i + 1]);
+                        break;
                 }
             }
         }
-        pc.printf("\t");
-
-        if(rs485L.readable()) {
-            for(int i = 0; i < BUFFER; i++) {
-                rec_data_L[i] = rs485L.getc();
-            }
-            for(int i = 0; i < BUFFER; i++) {
-                if(rec_data_L[i + 1] != -1) {
-                    pc.printf("LEFT : ");
-                    switch(rec_data_L[i]) {
-                        case 'X':
-                            pc.printf("  X : %5i",rec_data_L[i + 1]);
-                            break;
-                        case 'Y':
-                            pc.printf("  Y : %5i",rec_data_L[i + 1]);
-                            break;
-                        case 'Z':
-                            pc.printf("  Z : %5i",rec_data_L[i + 1]);
-                            break;
-                        case 'V':
-                            pc.printf("  V : %5i",rec_data_L[i + 1]);
-                            break;
-                        case 'C':
-                            pc.printf("  C : %5i",rec_data_L[i + 1]);
-                            break;
-                    }
-                }
-            }
-            pc.printf("\n\r");
-            Driver_R = 1;
-            Driver_L = 1;
-            wait_ms(1);
-        }
-    }
-
-    void counter_checker(int *counter_A,int *counter_B,int *counter_C,int *counter_D) {
-        
-        (*counter_A)++;
-        if(*counter_A > 180)
-            *counter_A = 0;
-            
-        *counter_B = *counter_B + 2;
-        if(*counter_B > 180)
-            *counter_B = 0;
-            
-        *counter_C = *counter_C + 3;
-        if(*counter_C > 180)
-            *counter_C = 0;
-            
-        *counter_D = *counter_D + 4;
-        if(*counter_D > 180)
-            *counter_D = 0;
-    }
-
-    int main() {
-        /*右エルロン:A
-         右翼端板 :B
-         左エルロン:C
-         左翼端板 :D
-        */
-        rs485R.baud(38400);
+        pc.printf("\n\r");
         Driver_R = 1;
         Driver_L = 1;
-        int counter_A = 0;
-        int counter_B = 0;
-        int counter_C = 0;
-        int counter_D = 0;
-        pc.printf("Driver\n\r");
-        CheckData.attach(&ch_data,0.25);
-        while(1) {
-            rs485R.putc('A');
-            rs485R.putc(counter_A);
-            rs485R.putc('B');
-            rs485R.putc(counter_B);
-            rs485L.putc('C');
-            rs485L.putc(counter_C);
-            rs485L.putc('D');
-            rs485L.putc(counter_D);
-            counter_checker(&counter_A,&counter_B,&counter_C,&counter_D);
-            wait(0.25);
-        }
+        wait_ms(1);
     }
+}
+
+void counter_checker(int *counter_A,int *counter_B,int *counter_C,int *counter_D)
+{
+
+    (*counter_A)++;
+    if(*counter_A > 180)
+        *counter_A = 0;
+
+    *counter_B = *counter_B + 2;
+    if(*counter_B > 180)
+        *counter_B = 0;
+
+    *counter_C = *counter_C + 3;
+    if(*counter_C > 180)
+        *counter_C = 0;
+
+    *counter_D = *counter_D + 4;
+    if(*counter_D > 180)
+        *counter_D = 0;
+}
+
+int main()
+{
+    /*右エルロン:A
+     右翼端板 :B
+     左エルロン:C
+     左翼端板 :D
+    */
+    rs485R.baud(38400);
+    rs485L.baud(38400);
+    Driver_R = 1;
+    Driver_L = 1;
+    int counter_A = 0;
+    int counter_B = 0;
+    int counter_C = 0;
+    int counter_D = 0;
+    pc.printf("Driver\n\r");
+    CheckData.attach(&ch_data,0.40);
+    while(1) { 
+        rs485R.putc(counter_A);
+        rs485R.putc('B');
+        rs485R.putc(counter_B);
+        rs485L.putc('C');
+        rs485L.putc(counter_C);
+        rs485L.putc('D');
+        rs485L.putc(counter_D);
+        counter_checker(&counter_A,&counter_B,&counter_C,&counter_D);
+        wait(0.25);
+    }
+}