anton ahmad / Mbed 2 deprecated STM32_AD7606

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
antonmadto
Date:
Fri Apr 09 08:45:28 2021 +0000
Parent:
0:d47d291acdf4
Commit message:
STM32F303 AD7606

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Apr 09 06:27:33 2021 +0000
+++ b/main.cpp	Fri Apr 09 08:45:28 2021 +0000
@@ -1,20 +1,22 @@
 #include "mbed.h"
+#include "USBSerial.h"
 #include "ad7606.h"
  
-#ifdef TARGET_NUCLEO_F303K8
- #define MISO    PB_4
- #define SCLK    PB_3
- #define CS      PA_8
- #define CONVST  PB_1
- #define BUSY    PB_6
- #define RESET   PB_7
-#endif
+
+#define MISO    PB_4
+#define SCLK    PB_3
+#define CS      PA_8
+#define CONVST  PB_1
+#define BUSY    PB_6
+#define RESET   PB_7
+
  
  
-Serial pc(USBTX, USBRX);
+// Create a BufferedSerial object with a default baud rate.
+static BufferedSerial pc(USBTX, USBRX);
 AD7606 ad7606(MISO, SCLK, CS, CONVST, BUSY, RESET, 10500000);
 double aValues[8] = {0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F};
-//int16_t rawValues[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+int16_t rawValues[8] = {0, 0, 0, 0, 0, 0, 0, 0};
 Ticker tick1;
 
 volatile bool timerInterrupt = false;
@@ -26,18 +28,21 @@
  
 int main() {
 
-    pc.baud(115200);
-    pc.printf("Hello, World!\r\n");
+        pc.set_baud(115200);
+    printf("Hello, World!\r\n");
     ad7606.setDR(10.0f);
-    tick1.attach(timInterrupt_ISR, 0.1F);
+    // tick1.attach(timInterrupt_ISR, 0.1F);
     
     while(1) {
-        if (timerInterrupt) { 
-            //ad7606.readRAW(rawValues);
-            //pc.printf("%d, %d, %d, %d, %d, %d, %d, %d\r\n", rawValues[0], rawValues[1], rawValues[2], rawValues[3], rawValues[4], rawValues[5], rawValues[6], rawValues[7]);
-            ad7606.readAnalog(aValues);
-            pc.printf("%.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f\r\n", aValues[0], aValues[1], aValues[2], aValues[3], aValues[4], aValues[5], aValues[6], aValues[7]);
-            timerInterrupt = false;
-        } 
+        // if (timerInterrupt) { 
+            ad7606.readRAW(rawValues);
+            // printf("%d, %d, %d, %d, %d, %d, %d, %d\r\n", rawValues[0], rawValues[1], rawValues[2], rawValues[3], rawValues[4], rawValues[5], rawValues[6], rawValues[7]);
+            printf("%d\r\n", rawValues[0]);
+            // ad7606.readAnalog(aValues);
+            // printf("%d \r\n", rawValues[0], aValues[0]);
+                wait_us(10000);
+            // pc.write(aValues[0], 2);
+        //     timerInterrupt = false;
+        // } 
     }    
 }
\ No newline at end of file