Ian Hua / Quadcopter-mbedRTOS
Revision:
31:3dde2201e54d
Parent:
30:d9b988f8d84f
Child:
33:f88a6ee18103
--- a/RTOS-Threads/src/Task2_Master.cpp	Mon May 12 04:43:38 2014 +0000
+++ b/RTOS-Threads/src/Task2_Master.cpp	Mon May 12 05:12:19 2014 +0000
@@ -1,7 +1,7 @@
 /* File:        Task2_Master.cpp
  * Author:      Trung Tin Ian HUA
  * Date:        May 2014
- * Purpose:     Thread2: Gyro sample and PID Control loop
+ * Purpose:     Thread2M: Master PID control loop (attitude)
  * Settings:    100Hz
  * Timing:      40us
  */
@@ -15,30 +15,22 @@
 
 //bool counterTask2Master = false;
 
-#ifdef TIME_TASK2M
-Timer _t2m;
-#endif
+//Timer
 void Task2_Master(void const *argument)
 {
-#ifndef TIME_TASK2M
+//Timer
     if (armed) {
-#endif
         switch (mode) {
             case RATE:
                 break;
 
             case ATTITUDE:
             default:
-#ifdef TIME_TASK2M
-                _t2m.reset();
-                _t2m.start();
-#endif
-                Task1(NULL);
+//Timer
+                AHRSSample();
 
-                if (counterTask1) {
-                    pitchPIDstable.setProcessValue((int) (ypr[1] - ypr_offset[1]));
-                    rollPIDstable.setProcessValue((int) (ypr[2] - ypr_offset[2]));
-                }
+                pitchPIDstable.setProcessValue((int) (ypr[1] - ypr_offset[1]));
+                rollPIDstable.setProcessValue((int) (ypr[2] - ypr_offset[2]));
 
                 pitchPIDstable.setSetPoint(inputYPR[1]);
                 rollPIDstable.setSetPoint(inputYPR[2]);
@@ -47,15 +39,10 @@
                 adjust_attitude[2] = rollPIDstable.compute();
                 adjust_attitude[2] *= -1;
 
-                counterTask1 = false;
                 //counterTask2Master = true;
-#ifdef TIME_TASK2M
-                _t2m.stop();
-                BT.printf("%d\n", _t2m.read_us());
-#endif
+//Timer
                 break;
         }
-#ifndef TIME_TASK2M
+//Timer
     }
-#endif
 }