]> Pileus Git - ~andy/csm213a-hw/blobdiff - yue/main.cpp
Move timer to main
[~andy/csm213a-hw] / yue / main.cpp
index e580188dcce225a1caf375fed709594a5b036c5b..ce909d4eeff3eb9d95e69f8d6825b7c1f76209ea 100644 (file)
@@ -146,7 +146,7 @@ void printBin(uint8_t *frame, int len);
 int main(void) {\r
     // Initialization\r
     // Interruption Declarations\r
-    clock1.attach(&clock1_interrupt, TIME_ACCURACY);    // maximun accuracy be 0.1s\r
+    //clock1.attach(&clock1_interrupt, TIME_ACCURACY);    // maximun accuracy be 0.1s\r
     serial.attach(&serialRx_interrupt, Serial::RxIrq);  // receive interrupt for serialS\r
     serial.baud(115200);\r
     magSensor.begin();\r
@@ -155,8 +155,13 @@ int main(void) {
 \r
     printStr("\r\n============= Start of the program ============\r\n");\r
 \r
+    int ticks = 0, tocks = 0;\r
     while(1){\r
-        wait(3);\r
+       ticks = us_ticker_read() * TIME_ACCURACY;\r
+       if (tocks < ticks) {\r
+               clock1_interrupt();\r
+               tocks++;\r
+       }\r
     }\r
 }\r
 \r