ajout module_mouvement

Dependencies:   mbed xbee_lib ADXL345_I2C IMUfilter ITG3200 Motor RangeFinder Servo mbos PID

Fork of Labo_TRSE_Drone by HERBERT Nicolas

Files at this revision

API Documentation at this revision

Comitter:
Gaetan
Date:
Wed Mar 20 11:01:06 2013 +0000
Parent:
5:58b31dbee84d
Child:
8:d37c4e566cbf
Commit message:
Ajout des librairies xbee_lib + mbos

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbos.lib Show annotated file Show diff for this revision Revisions of this file
xbee_lib.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jan 30 17:26:04 2013 +0000
+++ b/main.cpp	Wed Mar 20 11:01:06 2013 +0000
@@ -1,4 +1,5 @@
-#include "mbed.h"
+/*#include "mbed.h"
+#include "mbos.h"
 
 DigitalOut myled(LED1);
 
@@ -9,4 +10,57 @@
         myled = 0;
         wait(0.2);
     }
+}*/
+#include "mbed.h"                    
+#include "mbos.h"
+ 
+#define TASK1_ID                1       // Id for task 1 (idle task is 0)
+#define TASK1_PRIO              50      // priority for task 1
+#define TASK1_STACK_SZ          32      // stack size for task 1 in words 
+#define TASK2_ID                2       // Id for task 2 
+#define TASK2_PRIO              60      // priority for task 2
+#define TASK2_STACK_SZ          32      // stack size for task 2 in words 
+#define TIMER0_ID               0       // Id for timer 0
+#define TIMER0_PERIOD           1000    // Time period in milliseconds
+#define TIMER0_EVENT            1       // Event flag (1 << 0)
+#define T1_TO_T2_EVENT          2       // Event flag (1 << 1)
+
+void task1(void);                       // task function prototypes
+void task2(void);
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+mbos os(2, 1);                          // Instantiate mbos with 2 tasks & 1 timer    
+
+int main(void)
+{
+   // Configure tasks and timers
+   os.CreateTask(TASK1_ID, TASK1_PRIO, TASK1_STACK_SZ, task1);
+   os.CreateTask(TASK2_ID, TASK2_PRIO, TASK2_STACK_SZ, task2);
+   os.CreateTimer(TIMER0_ID, TIMER0_EVENT, TASK1_ID);
+    // Start mbos
+   os.Start();
+    // never  return!
 }
+
+void task1(void)
+{
+    os.SetTimer(TIMER0_ID, TIMER0_PERIOD, TIMER0_PERIOD);
+    while(1){
+        os.WaitEvent(TIMER0_EVENT);
+        led1 = !led1;
+        os.SetEvent(T1_TO_T2_EVENT, TASK2_ID);
+    }
+}
+
+void task2(void)
+{
+    while(1){
+        os.WaitEvent(T1_TO_T2_EVENT);
+        led2 = 1;
+        wait_ms(100);
+        led2 = 0;
+   }
+}
+/*@endcode
+ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbos.lib	Wed Mar 20 11:01:06 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AndrewL/code/mbos/#cf660b28b2a4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xbee_lib.lib	Wed Mar 20 11:01:06 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tristanjph/code/xbee_lib/#6455a079bdb3