joey shelton / Mbed OS OT07_I2C_GUI_Firmware

Dependencies:   SDFileSystem max32630fthr USBDevice

Fork of FTHR_SD_Demo by Maxim Integrated

Revision:
26:9ae9d097253a
Parent:
25:08b220797bd9
Child:
27:87f7adba07d7
--- a/main.cpp	Thu Mar 28 19:58:23 2019 +0000
+++ b/main.cpp	Thu May 09 17:07:21 2019 +0000
@@ -24,21 +24,21 @@
 #define OT07_ADC_SETUP      0x14    // OT07 Temp Seneor Setup (ADC_RES[7:6]) & Convert Temperature [0]
 #define OT07_GPIO_SETUP     0x20    // OT07 GPIO Setup,  sets GPIO modes
 #define OT07_GPIO_CTRL      0x21    // OT07 GPIO control
-#define OT07_ROM_ID         0x30    // OT07 ROM_ID address of LSB?
+#define OT07_ROM_ID         0x31    // OT07 ROM_ID address of LSB?
 
 #define DEVICE_ACK      0
 #define DEVICE_NACK     1
 #define DEVICE_BAD_RESP 2
 
 #define MAX_DEVICES 64      // Maximum number of rom devices allowed
-#define ID_LENGTH   8       // Rom ID length in bytes
+#define ID_LENGTH   6       // Rom ID length in bytes
 
 
 #define BS          8       // ASCII Back Space
 #define CR          13      // ASCII Carriage Return
 
 struct OT07_struct {
-    char rom_id[ID_LENGTH];     // device 8 byte ROM ID
+    char rom_id[ID_LENGTH];     // device ROM ID
     char I2C_address;           // I2C addess, based on GPIO0 and GPIO1 at power up
 }; 
 
@@ -276,8 +276,8 @@
             
                 OT07[device_count].I2C_address = I2C_add;
                 
-                OT07_read_register(I2C_add,OT07_ROM_ID,data,8);
-                for(j=7;j>=0;j--){
+                OT07_read_register(I2C_add,OT07_ROM_ID,data,ID_LENGTH);
+                for(j=ID_LENGTH-1;j>=0;j--){
                     OT07[device_count].rom_id[j] = data[j];
                      
                 }
@@ -608,27 +608,11 @@
     rLED = LED_OFF;
     gLED = LED_ON;
     bLED = LED_ON;
-
+    
+    // ******************  search for all devices on bus  *****************
 
-    // reset DS2484
-    //data[0] = 0xE1;
-    //data[1] = 0xF0;
-    //i2c.write(DS2484_ADD,data,1,1);
-    //i2c.read(DS2484_ADD,data,1);   
-    
-    // ******************  search for all OW devices on bus  *****************
-    
-    //device_count = search_rom(rom_id_list);
     device_count = search_I2C_bus(OT07);
     
-    /*for(j=0;j<device_count;j++){                                   
-        for(k=0;k<8;k++){                   
-            device_id[k] = rom_id_list[j][k];   // get device_id from rom_id_list
-        }
-        set_test_mode(device_id);
-    }*/ 
-    
-    
     rx_index = 0;               //character buffer index for input from PC
     
     button.fall(&btn_pressed);
@@ -668,7 +652,7 @@
                         if(device_logged[j])
                         {
                             fprintf(fp,"%d,0x%02X,0x",j, OT07[j].I2C_address);
-                            for(i=7;i>=0;i--)
+                            for(i=ID_LENGTH-1;i>=0;i--)
                             {            
                                 fprintf(fp,"%02X",OT07[j].rom_id[i]); 
                             }    
@@ -722,19 +706,7 @@
                 if(n > 0){//got input so process it
                     switch(c){
                         case 'a':   
-                        case 'A':   // alarm search
-                                    // ******************  search for all OW devices with alarm triggered on bus  *****************
-                                    /*
-                                    device_count = alarm_search(rom_id_list);
-    
-                                    pc.printf("%d devices:\r\n", device_count);
-                                    for(j=0;j<device_count;j++){
-                                        pc.printf("device[%02X]  rom id[",j);
-                                        for(i=7;i>=0;i--){            
-                                            pc.printf("%02X",rom_id_list[j][i]); 
-                                        }    
-                                        pc.printf("]\r\n");
-                                    } */
+                        case 'A':   
                             break;
                         case 'c':
                         case 'C':
@@ -940,7 +912,7 @@
                                     pc.printf("%d devices:\r\n", device_count);
                                     for(j=0;j<device_count;j++){
                                         pc.printf("device[%02X] addr[%02X] rom id[",j, OT07[j].I2C_address);
-                                        for(i=7;i>=0;i--){            
+                                        for(i=ID_LENGTH-1;i>=0;i--){            
                                             pc.printf("%02X",OT07[j].rom_id[i]); 
                                         }    
                                         pc.printf("]\r\n");
@@ -986,16 +958,6 @@
                         
                         case 'x':   
                         case 'X':   // experimental modes
-                                    // ******************  set up ADC enabled in test mode*****************
-                                    /*
-                                    pc.printf("<set ADC_ENABLED in test mode>\r\n");
-                                    
-                                    for(j=0;j<device_count;j++){                                   
-                                        for(k=0;k<8;k++){                   
-                                            device_id[k] = rom_id_list[j][k];   // get device_id from rom_id_list
-                                        }
-                                        set_test_mode(device_id);
-                                    } */
                             break;