MAX32625PICO LP0 mode

Dependencies:   SX1276GenericLib USBDevice

Fork of PICO_LP0 by Walter Luu

Revision:
6:51f492ca61a2
Parent:
5:9e751733a6f3
Child:
7:c92ed2d6e344
--- a/main.cpp	Tue Oct 13 00:45:46 2020 +0000
+++ b/main.cpp	Wed Oct 14 00:19:02 2020 +0000
@@ -22,6 +22,9 @@
 // AO32 related
 #include "AO32_lib.h" 
 
+// AO19 related
+#include "AO19_lib.h"
+
 //#if defined(TARGET_MAX32630FTHR) // using the RFM95 board
 //    #include "max32630fthr.h"
 //    MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
@@ -58,17 +61,21 @@
 I2C i2cBus0(P1_6, P1_7);            // I2C of MAX32625PICO
 
 
-bool get_data_flag = false;         // used for data tramission frequency
-
+bool get_data_flag = false;         // used for data tramission frequency on the SENSOR side
+bool print_data_flag = false;       // used for data display on the GATEWAY side
 
 //Timer setup
-Ticker timer_1;                     // timer for data tramission frequency
-
+Ticker timer_1;                     // timer for data tramission frequency on the SENSOR side
+Ticker timer_M;                     // timer for data print out on the GATEWAY side
 
 void onTimerInterrupt(){
     get_data_flag = true;
 }
 
+void onGatewayInterrupt(){
+    print_data_flag = true;
+}
+
 int main() {
 
 /***************************************************************************
@@ -77,17 +84,17 @@
  
     /* Setup begins here: */
     #if   MASTER == 1 // Master Device
-        pc.printf("MAX32625PICO: MASTER DEVICE\r\n");
-        wait(1);
+//        pc.printf("MAX32625PICO: MASTER DEVICE\r\n");
+//        wait(1);
     #elif SLAVE == 1 // Slave Device
-        pc.printf("MAX32625PICO: SLAVE DEVICE\r\n");
-        wait(1);
+//        pc.printf("MAX32625PICO: SLAVE DEVICE\r\n");
+//        wait(1);
     #endif
     
     /* Introduction text: */
-    pc.printf("Welcome to the SX1276GenericLib\r\n");
+//    pc.printf("Welcome to the SX1276GenericLib\r\n");
 //    wait(5);
-    pc.printf("Starting a simple LoRa PingPong\r\n");
+//    pc.printf("Starting a simple LoRa PingPong\r\n");
 //    wait(5);
     
      /***************************************************************************
@@ -109,10 +116,10 @@
      * Dummy Data Buffers
      **************************************************************************/
     #if MASTER == 1  // Master Device
-        uint8_t curr_dum_to_slave[size_of_dum];
+//        uint8_t curr_dum_to_slave[size_of_dum];
     #elif SLAVE == 1 // Slave Device
-        uint8_t curr_dum_from_master[size_of_dum];
-        uint8_t prev_dum_from_master[size_of_dum];
+//        uint8_t curr_dum_from_master[size_of_dum];
+//        uint8_t prev_dum_from_master[size_of_dum];
     #endif
     
     /***************************************************************************
@@ -123,7 +130,7 @@
 //        uint8_t curr_raw_temp_from_slave[size_of_MAX30208];
         char curr_raw_temp_from_slave[size_of_MAX30208];   // to match data type
 //        uint8_t prev_MAX77650_from_slave[size_of_MAX77650];
-//        uint8_t prev_raw_temp_from_slave[size_of_MAX30208];  
+        char prev_raw_temp_from_slave[size_of_MAX30208];  
     #elif SLAVE == 1 // Slave Device
 //        uint8_t curr_MAX77650_to_master[size_of_MAX77650];
 //        bool chrg_status = false; //True = ON False = OFF
@@ -137,7 +144,7 @@
     #if   MASTER == 1 // Master Device
 //        uint8_t curr_raw_light_from_slave[size_of_MAX44009];
         char curr_raw_light_from_slave[size_of_MAX44009];    // to match data type
-//        uint8_t prev_raw_light_from_slave[size_of_MAX44009];
+        char prev_raw_light_from_slave[size_of_MAX44009];
     //    static int16_t conv_frame_data_from_slave[64];
     #elif SLAVE == 1 // Slave Device
         uint8_t curr_raw_light_to_master[size_of_MAX44009];
@@ -151,7 +158,7 @@
     #if   MASTER == 1 // Master Device
 //        uint8_t curr_raw_AO32_from_slave[size_of_MAX20361];
         char curr_raw_AO32_from_slave[size_of_MAX20361];            // to match data type
-//        uint8_t prev_raw_AO32_from_slave[size_of_MAX20361];
+        char prev_raw_AO32_from_slave[size_of_MAX20361];
     //    static int16_t conv_frame_data_from_slave[64];
     #elif SLAVE == 1 // Slave Device
         uint8_t curr_raw_AO32_to_master[size_of_MAX20361];
@@ -187,39 +194,22 @@
 //    http://www.cplusplus.com/doc/tutorial/arrays/
     #if MASTER == 1
 //    curr_dum_to_slave[0] = {33, 34};
-    curr_dum_to_slave[0] = 33;
-    curr_dum_to_slave[1] = 34;
+//    curr_dum_to_slave[0] = 33;
+//    curr_dum_to_slave[1] = 34;
     #endif
     
     #if SLAVE == 1
-//    curr_raw_temp_to_master[size_of_MAX30208] = {10, 13, 15, 17, 19};
+
     curr_raw_temp_to_master[0] = 99;
     curr_raw_temp_to_master[1] = 99;
-//    curr_raw_temp_to_master[2] = 15;
-//    curr_raw_temp_to_master[3] = 17;
-//    curr_raw_temp_to_master[4] = 19;
-//    curr_raw_light_to_master[size_of_MAX44009] = {25, 26, 27, 28, 29};
+
     curr_raw_light_to_master[0] = 25;
     curr_raw_light_to_master[1] = 26;
-//    curr_raw_light_to_master[2] = 27;
-//    curr_raw_light_to_master[3] = 28;
-//    curr_raw_light_to_master[4] = 29;
-//    curr_raw_AO32_to_master[size_of_MAX20361] = {99, 100, 101, 102, 103};
+
     curr_raw_AO32_to_master[0] = 99;
     curr_raw_AO32_to_master[1] = 100;
     curr_raw_AO32_to_master[2] = 101;
-    curr_raw_AO32_to_master[3] = 102;
-//    curr_raw_AO32_to_master[4] = 103;
-//    curr_raw_other_to_master[size_of_other] = {20, 30, 40, 50, 60, 70, 80};
-//    curr_raw_other_to_master[0] = 20;
-//    curr_raw_other_to_master[1] = 30;
-//    curr_raw_other_to_master[2] = 40;
-//    curr_raw_other_to_master[3] = 50;
-//    curr_raw_other_to_master[4] = 60;
-//    curr_raw_other_to_master[5] = 70;
-//    curr_raw_other_to_master[6] = 80;
-    
-    
+    curr_raw_AO32_to_master[3] = 102;    
      #endif
     
     /***************************************************************************
@@ -227,15 +217,19 @@
      **************************************************************************/
     int loopCnt = 0;
     
+    #if MASTER == 1
+     //************* init ticker timer callbacks  ****************
+    timer_M.attach(&onGatewayInterrupt, 3);        //Gateway data print out frequency
+    
+    #endif
+    
     #if SLAVE == 1
     //************* init ticker timer callbacks  ****************
-    timer_1.attach(&onTimerInterrupt, 3);        //LED3 toggles every 3 seconds
+    timer_1.attach(&onTimerInterrupt, 3);        //Sensor data transmission frequency
     
-    //************* OT07 Variables  ****************
-//    char data[5];   
+    //************* OT07 Variables  **************** 
     char rawtempdata[2];          
     char OT07_i2c_add = 0xA0;
-//    TempResponse T;
     
     //************* MAX44009 Variables  ****************
     char rawluxdata[2];          
@@ -246,22 +240,39 @@
     char rawCntdata[2];
     char AO32_i2c_add = 0x2A;      // 0b0010 101x
     
+     //************* AO19 Settings  ****************
+    // Enable AO19
+    char AO19_i2c_add = 0xD0;      // 
+    char AO19_BB_CFG[2];              // store result of AO19's register 0x01 BBstCfg0
+    int AO19_read = AO19_read_register(&i2cBus0, AO19_i2c_add, AO19_BB_CFG0, AO19_BB_CFG);
+    
+//    if (AO19_read) {
+//        pc.printf("AO19 Initial Read fail!\r\n");
+//    }
+//    else {
+//        pc.printf("AO19 Initial Read success!\r\n");
+//    } 
+    
+    int AO19_en = AO19_write_register(&i2cBus0, AO19_i2c_add, AO19_BB_CFG0, AO19_BB_CFG[0]|0x80);
+    
+   // if (AO19_en) {
+//        pc.printf("AO19 Enabled fail!\r\n");
+//    }
+//    else {
+//        pc.printf("AO19 Enabledsuccess!\r\n");
+//    } 
+    
+    
     #endif
     
     while (1) {
-        
-    // Application details:
-    //1. Set a fixed timer.
-    //2. Data sent from Master to Slave.
-    //3. Display data and repeat from 1.
-   
-   
+    
     #if SLAVE == 1
     if(get_data_flag) {
         
         //reset the flag
         get_data_flag = false;
-        pc.printf("Timer interval reached!\r\n");
+//        pc.printf("Timer interval reached!\r\n");
         
         /***************************************************************************
         * Temperature Sensor Data Measurement
@@ -273,13 +284,13 @@
 //        pc.printf("OT07 add[%02X] data[%02X] data[%02X]\r\n", OT07_FIFO_DATA, rawtempdata[0], rawtempdata[1]);  
             
         //calculate temperature from data     
-        int count = (int)(rawtempdata[0]*256 + rawtempdata[1]);
-        if (count >= 32768)count = count - 65536;     // 2s comp
-        double Temp = (double)count*0.005; 
-        pc.printf("OT07  temperature[%.3f]  status[%d]\r\n", Temp, temp_error);
+//        int count = (int)(rawtempdata[0]*256 + rawtempdata[1]);
+//        if (count >= 32768)count = count - 65536;     // 2s comp
+//        double Temp = (double)count*0.005; 
+//        pc.printf("OT07  temperature[%.3f]  status[%d]\r\n", Temp, temp_error);
         double tempFinal = calc_temperature(rawtempdata);
-        pc.printf("OT07  Final temperature[%.3f] \r\n", tempFinal);
-        pc.printf("\r\n");
+//        pc.printf("OT07  Final temperature[%.3f] \r\n", tempFinal);
+//        pc.printf("\r\n");
         
         
         //fill raw temp data into the array
@@ -296,15 +307,15 @@
 //        pc.printf("MAX44009 hi_add[%02X] hi_data[%02X] lo_add[%02X] lo_data[%02X]\r\n", MAX44009_LUX_HI, rawluxdata[0], MAX44009_LUX_LO, rawluxdata[1]);
         
         //calculate temperature from data  
-        int exponent = int(rawluxdata[0] >> 4);
-        int mantissa = (int)((rawluxdata[0] << 4) & 0xF0) + (int)(rawluxdata[1]);
-        double lux = 0.045 * mantissa * pow((double) 2, exponent);
+//        int exponent = int(rawluxdata[0] >> 4);
+//        int mantissa = (int)((rawluxdata[0] << 4) & 0xF0) + (int)(rawluxdata[1]);
+//        double lux = 0.045 * mantissa * pow((double) 2, exponent);
 //        pc.printf("MAX44009  exponent[%d]  mantissa[%d]\r\n", exponent, mantissa);
 //        pc.printf("MAX44009  lux[%.2f]  status[%d] status[%d]\r\n", lux, lux_error1, lux_error2);
-        pc.printf("MAX44009  lux[%.2f]  status[%d]\r\n", lux, lux_error);
-        double luxFinal = calc_lux(rawluxdata);
-        pc.printf("MAX44009  Final Lux[%.2f] \r\n", luxFinal);
-        pc.printf("\r\n");
+//        pc.printf("MAX44009  lux[%.2f]  status[%d]\r\n", lux, lux_error);
+        int luxFinal = (int) (calc_lux(rawluxdata));
+//        pc.printf("MAX44009  Final Lux[%.2f] \r\n", luxFinal);
+//        pc.printf("\r\n");
         
         //fill raw lux data into the array
         curr_raw_light_to_master[0] = rawluxdata[0];
@@ -326,19 +337,19 @@
         
         //calculate open circuit voltage from data
         double voltage = (double)(rawOCVdata[0]) / 100;
-        pc.printf("AO32  OCV[%.2f]  status[%d]\r\n", voltage, ocv_error);  
+//        pc.printf("AO32  OCV[%.2f]  status[%d]\r\n", voltage, ocv_error);  
         double OCVFinal = calc_OCV(rawOCVdata);
-        pc.printf("AO32  Final OCV[%.2f]  \r\n", OCVFinal);
-        pc.printf("\r\n");
+//        pc.printf("AO32  Final OCV[%.2f]  \r\n", OCVFinal);
+//        pc.printf("\r\n");
         
         //calculate harvesting counts from data
-        int countHi = int(rawCntdata[0]) * 256;
-        int countLo = int(rawCntdata[1]);
-        int harvest_counts = countHi + countLo;
-        pc.printf("AO32  HarvesterCnt[%d]  status[%d]\r\n", harvest_counts, cnt_error); 
+//        int countHi = int(rawCntdata[0]) * 256;
+//        int countLo = int(rawCntdata[1]);
+//        int harvest_counts = countHi + countLo;
+//        pc.printf("AO32  HarvesterCnt[%d]  status[%d]\r\n", harvest_counts, cnt_error); 
         int countFinal = calc_Harvest(rawCntdata);
-        pc.printf("AO32 Final HarvesterCnt[%d]\r\n",  countFinal);
-        pc.printf("\r\n");
+//        pc.printf("AO32 Final HarvesterCnt[%d]\r\n",  countFinal);
+//        pc.printf("\r\n");
         
         
         //fill raw AO32 data into the array
@@ -346,6 +357,9 @@
         curr_raw_AO32_to_master[1] = rawCntdata[0];         // Fill Harvesting count high byte
         curr_raw_AO32_to_master[2] = rawCntdata[1];         // Fill Harvesting count low byte
         
+        // print out sensor data
+         pc.printf("SENSOR: [%.3f] [%d] [%.2f] [%d] [0]\r\n", tempFinal, luxFinal, OCVFinal, countFinal);
+        
         /***************************************************************************
         * Fill Payload Buffer With Data From Main Program Buffers for next LoRa Transmition
         **************************************************************************/
@@ -376,15 +390,15 @@
         **************************************************************************/
 //        SX1276SensorSend();
         SX1276PingPong(); 
-        int sendTime = TimeOnAirSend();
-        pc.printf("Tx Time on Air: %d \r\n", sendTime);
+//        int sendTime = TimeOnAirSend();
+//        pc.printf("Tx Time on Air: %d \r\n", sendTime);
         
         /***************************************************************************
         * Fill Main Program Buffers With Data From Received Payload Buffer
         **************************************************************************/
         // Slave Device
-        memcpy(ID_of_master,              &BufferRx[rx_idx_signature], size_signature);
-        memcpy(curr_dum_from_master,      &BufferRx[rx_idx_dum],       size_of_dum);
+//        memcpy(ID_of_master,              &BufferRx[rx_idx_signature], size_signature);
+//        memcpy(curr_dum_from_master,      &BufferRx[rx_idx_dum],       size_of_dum);
         
          /***************************************************************************
         * Slave Device: Print out Master Data
@@ -402,7 +416,7 @@
 //        }
             
         // print loop counter
-        pc.printf("Loop Counter Slave: %d \r\n", loopCnt);
+//        pc.printf("Loop Counter Slave: %d \r\n", loopCnt);
         loopCnt = loopCnt + 1;
     } // end of transmission frequency for slave
     #endif    
@@ -413,14 +427,14 @@
      * Fill Payload Buffer With Data From Main Program Buffers for next LoRa Transmition
      **************************************************************************/
     memcpy(&BufferTx[tx_idx_signature], PingMsg,           size_signature);
-    memcpy(&BufferTx[tx_idx_dum],       curr_dum_to_slave, size_of_dum);
+//    memcpy(&BufferTx[tx_idx_dum],       curr_dum_to_slave, size_of_dum);
     
      /***************************************************************************
      * LoRa Communication: Gateway Receive Sensor Data
      **************************************************************************/
 //    SX1276GateWayReceive(333);
     SX1276PingPong();
-    int sendTime = TimeOnAirSend();
+//    int sendTime = TimeOnAirSend();
 //    pc.printf("Tx Time on Air: %d \r\n", sendTime);
     
     /***************************************************************************
@@ -462,7 +476,7 @@
 //        pc.printf("[%02X] \r\n", curr_raw_light_from_slave[i]);
 //    }
     
-    double luxResult = calc_lux(curr_raw_light_from_slave);
+    int luxResult = (int) calc_lux(curr_raw_light_from_slave);
 //    pc.printf("MSG: [%.3f] [%.2f] [] [] []\r\n", tempResult, luxResult);
             
     //        memcpy(curr_raw_AO32_from_slave,  &BufferRx[rx_idx_MAX20361],  size_of_MAX20361);
@@ -480,160 +494,38 @@
     
     double OCVResult = calc_OCV(OCVrawHex);
     int CntResult = calc_Harvest(CntrawHex);
-    pc.printf("MSG: [%.3f] [%.2f] [%.2f] [%d] []\r\n", tempResult, luxResult, OCVResult, CntResult);
-            
-    //        memcpy(curr_raw_other_from_slave,  &BufferRx[rx_idx_other],  size_of_other);
-    //pc.printf("Print Other data\r\n");
-//    for(int i = 0; i < sizeof(curr_raw_other_from_slave); i++){
-//        pc.printf("%d \r\n", curr_raw_other_from_slave[i]);
+    
+    
+    // only print out new results
+//    int tempNew = memcmp(prev_raw_temp_from_slave, curr_raw_temp_from_slave, sizeof(size_of_MAX30208)); 
+//    int luxNew = memcmp(prev_raw_light_from_slave, curr_raw_light_from_slave, sizeof(size_of_MAX44009)); 
+//    int AO32New = memcmp(prev_raw_AO32_from_slave, curr_raw_AO32_from_slave, sizeof(size_of_MAX20361)); 
+    
+//    if (tempNew != 0 || luxNew != 0 || AO32New != 0) {
+    
+//        pc.printf("MSG: [%.3f] [%d] [%.2f] [%d] [0]\r\n", tempResult, luxResult, OCVResult, CntResult);
+    
 //    }
     
+    if(print_data_flag) {
+        
+        //reset the flag
+        print_data_flag = false;
+        pc.printf("MSG: [%.3f] [%d] [%.2f] [%d] [0]\r\n", tempResult, luxResult, OCVResult, CntResult);
+    
+    }
+    
+    // copy the current recceived data into previous data
+//    memcpy(prev_raw_temp_from_slave, curr_raw_temp_from_slave, sizeof(size_of_MAX30208));
+//    memcpy(prev_raw_light_from_slave, c/urr_raw_light_from_slave, sizeof(size_of_MAX44009));         
+//    memcpy(prev_raw_AO32_from_slave, curr_raw_AO32_from_slave, sizeof(size_of_MAX20361)); 
+    
     // print loop counter
 //    pc.printf("Loop Counter Master: %d \r\n", loopCnt);
     loopCnt = loopCnt + 1;
     
-//    wait(3);
-    
     #endif
         
-    ///***************************************************************************
-//     * Fill Payload Buffer With Data From Main Program Buffers for next LoRa Transmition
-//     **************************************************************************/
-//    #if   MASTER == 1 // Master Device
-//        memcpy(&BufferTx[tx_idx_signature], PingMsg,           size_signature);
-//        memcpy(&BufferTx[tx_idx_dum],       curr_dum_to_slave, size_of_dum);
-//    #elif SLAVE == 1 // Slave Device
-//        memcpy(&BufferTx[tx_idx_signature], PongMsg,                  size_signature);
-//        memcpy(&BufferTx[tx_idx_MAX30208],  curr_raw_temp_to_master, size_of_MAX30208);
-//        memcpy(&BufferTx[tx_idx_MAX44009],  curr_raw_light_to_master, size_of_MAX44009);
-//        memcpy(&BufferTx[tx_idx_MAX20361],  curr_raw_AO32_to_master,  size_of_MAX20361);
-//        memcpy(&BufferTx[tx_idx_other],  curr_raw_other_to_master,  size_of_other);
-//    #endif
-//    
-//    /***************************************************************************
-//     * In case of OnRxTimeout
-//     **************************************************************************/
-//    #if   MASTER == 1 // Master Device, these are values when LoRa communication did not happen
-//        ID_of_slave[0] = 10; // 
-//        ID_of_slave[1] = 11; // 
-//        ID_of_slave[2] = 12; // 
-//        ID_of_slave[3] = 13; // 
-//        ID_of_slave[4] = 14; // 
-//        ID_of_slave[5] = 15; // 
-//        ID_of_slave[6] = 16; // 
-//        ID_of_slave[7] = 17; // 
-//    
-//    #elif SLAVE == 1 // Slave Device, these are values when LoRa communication did not happen
-//        ID_of_master[0] = 'N'; // 0x4E or 78
-//        ID_of_master[1] = 'A'; // 0x41 or 65
-//        ID_of_master[2] = 'C'; // 0x43 or 67
-//        ID_of_master[3] = 'K'; // 0x4B or 75
-//        ID_of_master[4] = 'M'; // 0x4D or 77
-//        ID_of_master[5] = 'A'; // 0x41 or 65
-//        ID_of_master[6] = 'S'; // 0x53 or 83
-//        ID_of_master[7] = '!'; // 0x21 or 33
-//        
-//        curr_dum_from_master[0] = 39;
-//        curr_dum_from_master[1] = 40;       
-//    
-//    #endif
-//
-//
-//    /***************************************************************************
-//     * Lora Communications
-//     **************************************************************************/
-//    #if   MASTER == 1 // Master Device
-//        SX1276GateWayReceive();
-//    
-//    #elif SLAVE == 1 // Slave Device
-//        SX1276SensorSend(); 
-//        int sendTime = TimeOnAirSend();
-//        pc.printf("Tx Time on Air: %d \r\n", sendTime);
-//    #endif  
-//    
-////    SX1276PingPong();           // what changes here?
-//    
-//    
-//    /***************************************************************************
-//     * Fill Main Program Buffers With Data From Received Payload Buffer
-//     **************************************************************************/
-//    /* The master and slave devices will have different requirements for offloading payload */
-//    #if   MASTER == 1 // Master Device
-//        memcpy(ID_of_slave,               &BufferRx[rx_idx_signature], size_signature);
-//        memcpy(curr_raw_temp_from_slave, &BufferRx[rx_idx_MAX30208],  size_of_MAX30208);
-//        memcpy(curr_raw_light_from_slave, &BufferRx[rx_idx_MAX44009], size_of_MAX44009);
-//        memcpy(curr_raw_AO32_from_slave,  &BufferRx[rx_idx_MAX20361],  size_of_MAX20361);
-//        memcpy(curr_raw_other_from_slave,  &BufferRx[rx_idx_other],  size_of_other);
-//    #elif SLAVE == 1 // Slave Device
-//        memcpy(ID_of_master,              &BufferRx[rx_idx_signature], size_signature);
-//        memcpy(curr_dum_from_master,      &BufferRx[rx_idx_dum],       size_of_dum);
-//    #endif    
-//        
-//       
-//    /***************************************************************************
-//     * Print Out Data Received
-//     **************************************************************************/       
-//    #if   MASTER == 1 // Master Device
-//    
-////        memcpy(ID_of_slave,               &BufferRx[rx_idx_signature], size_signature);
-//        pc.printf("Print ID_of_slave\r\n");
-//        for(int i = 0; i < sizeof(ID_of_slave); i++){
-//            pc.printf("%d \r\n", ID_of_slave[i]); 
-//            }
-//    
-////        memcpy(curr_raw_temp_from_slave, &BufferRx[rx_idx_MAX30208],  size_of_MAX30208);
-//        pc.printf("Print MAX30208 data\r\n");
-//        for(int i = 0; i < sizeof(curr_raw_temp_from_slave); i++){
-//            pc.printf("%d \r\n", curr_raw_temp_from_slave[i]); 
-//            }
-//            
-////        memcpy(curr_raw_light_from_slave, &BufferRx[rx_idx_MAX44009], size_of_MAX44009);
-//         pc.printf("Print MAX44009 data\r\n");
-//        for(int i = 0; i < sizeof(curr_raw_light_from_slave); i++){
-//            pc.printf("%d \r\n", curr_raw_light_from_slave[i]);
-//            }
-//            
-////        memcpy(curr_raw_AO32_from_slave,  &BufferRx[rx_idx_MAX20361],  size_of_MAX20361);
-//        pc.printf("Print MAX20361 data\r\n");
-//        for(int i = 0; i < sizeof(curr_raw_AO32_from_slave); i++){
-//            pc.printf("%d \r\n", curr_raw_AO32_from_slave[i]);
-//            }
-//            
-////        memcpy(curr_raw_other_from_slave,  &BufferRx[rx_idx_other],  size_of_other);
-//        pc.printf("Print Other data\r\n");
-//        for(int i = 0; i < sizeof(curr_raw_other_from_slave); i++){
-//            pc.printf("%d \r\n", curr_raw_other_from_slave[i]);
-//            }
-//    
-//    // print loop counter
-//    pc.printf("Loop Counter Master: %d \r\n", loopCnt);
-//    loopCnt = loopCnt + 1;
-//            
-//    #elif SLAVE == 1 // Slave Device
-////        memcpy(ID_of_master,              &BufferRx[rx_idx_signature], size_signature);
-//        pc.printf("Print ID_of_master\r\n");
-//        for(int i = 0; i < sizeof(ID_of_master); i++){
-//            pc.printf("%d \r\n", ID_of_master[i]);
-//            }
-//            
-////        memcpy(curr_dum_from_master,      &BufferRx[rx_idx_dum],       size_of_dum);
-//        pc.printf("Print Dum From Master\r\n");
-//        for(int i = 0; i < sizeof(curr_dum_from_master); i++){
-//            pc.printf("%d \r\n", curr_dum_from_master[i]);
-//            }
-//            
-//    // print loop counter
-//    pc.printf("Loop Counter Slave: %d \r\n", loopCnt);
-//    loopCnt = loopCnt + 1;
-//    #endif    
-           
-    // add delay to slow down
-    //    wait(1);
-        
-        
-//        }  //end of get_data_flag
-    
     } // end of while(1) loop
         
-}  // end of main()
-
+}  // end of main()
\ No newline at end of file