resist

Files at this revision

API Documentation at this revision

Comitter:
david8251
Date:
Thu Jul 20 09:01:18 2017 +0000
Commit message:
resist

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 9d598f2be2fd main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 20 09:01:18 2017 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+//---------------------------------
+
+Serial Mod(p9, p10);
+
+void task_resist();
+
+int main()
+{    
+     while(1){
+         task_resist();
+        }
+}
+//----------------------------------------------------------
+void task_resist(){ 
+
+int command[8]={0x08, 0x03, 0x00, 0x01, 0x00, 0x02,0x95,0x52};
+char receice[8]={0};
+int j=0;
+
+        for (int i=0; i<8; i++) {
+            while(1)
+            {
+            if (Mod.writeable())
+            {
+            Mod.putc(command[i]);
+            break;
+                }
+            }
+        }
+
+        for (int i=0; i<8; i++) {
+                            while (j<7) {
+                                if (Mod.readable()) {
+                                    receice[i]= Mod.getc();
+                                    if(j>5)
+                                    {
+                                        printf("Resistance:%.1fΩ\r\n", ((receice[3] << 8) + receice[4])/100.0);
+                                        j++;
+                                    }
+                                    j++;
+                                    break;
+                                }
+                    }
+    
+        }                        
+}
\ No newline at end of file
diff -r 000000000000 -r 9d598f2be2fd mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Jul 20 09:01:18 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#a1c0840b3d69060e5eb708edb18358e424a40f51