NIT Fukui / Serial6050Yaw

Dependents:   R1Arobo_Maika_B 2021Arobo_UMAPYOI 2021Arobo_YUMIPYOI

Files at this revision

API Documentation at this revision

Comitter:
Suzutomo
Date:
Wed Sep 18 07:52:24 2019 +0000
Parent:
3:601cfc41e50a
Commit message:
add Device Reset

Changed in this revision

Serial6050.cpp Show annotated file Show diff for this revision Revisions of this file
Serial6050.h Show annotated file Show diff for this revision Revisions of this file
--- a/Serial6050.cpp	Wed Apr 17 07:57:05 2019 +0000
+++ b/Serial6050.cpp	Wed Sep 18 07:52:24 2019 +0000
@@ -3,13 +3,17 @@
 Serial6050::Serial6050(PinName tx, PinName rx, PinName resetPin)
     : serial(tx, rx, 38400), rst(resetPin), Deg(0), Bias(0)
 {
+    if (resetPin == NC) useResetPin = false;
+    else useResetPin = true;
 }
 
 void Serial6050::init()
 {
-    rst = 1;
-    wait(0.5);
-    rst = 0;
+    if (useResetPin) {
+        rst = 1;
+        wait(0.1);
+        rst = 0;
+    }
     while(1) {
         serial.putc(100);
         if(serial.readable()) {
@@ -17,7 +21,7 @@
         }
     }
     serial.attach(this, &Serial6050::intReceive, RawSerial::RxIrq);
-    wait(0.1);
+    wait(1);
     reset();
 }
 
--- a/Serial6050.h	Wed Apr 17 07:57:05 2019 +0000
+++ b/Serial6050.h	Wed Sep 18 07:52:24 2019 +0000
@@ -17,8 +17,9 @@
     int resetValue;
     int Bias;
     void intReceive();
+    bool useResetPin;
 public:
-    Serial6050(PinName tx, PinName rx, PinName reset);
+    Serial6050(PinName tx, PinName rx, PinName resetPin);
     void init();
     void reset();
     volatile uint8_t data;