Playback system PGA test code

Dependencies:   BufferedSerial mbed

Files at this revision

API Documentation at this revision

Comitter:
Arkadi
Date:
Sun Jul 29 08:11:25 2018 +0000
Parent:
0:2542aa3b6c07
Commit message:
PGA test with xbee module

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 31 07:50:41 2017 +0000
+++ b/main.cpp	Sun Jul 29 08:11:25 2018 +0000
@@ -43,6 +43,7 @@
 
 // uart
 BufferedSerial pc(USBTX, USBRX);
+BufferedSerial xbee(D1, D0);
 
 // SPI with PGA112
 SPI spi(PB_5, PB_4, PB_3); // mosi, miso, sclk , SSEL
@@ -65,6 +66,7 @@
 int main()
 {
     pc.baud(57600);
+    xbee.baud(57600);
 #ifdef DEBUG_MOD1
     pc.printf("MIC Test\r\n");
 #endif
@@ -107,6 +109,23 @@
             PGA_CS=1;
 
         }// end serial
+        
+        if (xbee.readable()) {
+            in_byte=xbee.getc();
+#ifdef DEBUG_MOD1
+            xbee.putc(in_byte);
+#endif
+            uint8_t writeMSB = 0x2A;
+            uint8_t writeLSB = in_byte;
+            //uint16_t writeU16 = ((writeMSB<<8) | (writeLSB&0x00FF));
+            uint16_t writeU16 = ((writeMSB<<8) | (writeLSB));
+            PGA_CS=0;
+            // write Register
+            spi.write(writeU16);
+            // Disable PGA112
+            PGA_CS=1;
+
+        }// end serial
 
 //    // Enable PGA112
 //    PGA_CS=0;