MAX11410 high speed 24-bit Delta-Sigma ADC

Dependents:   MAX11410BOB_24bit_ADC MAX11410BOB_Serial_Tester

Revision:
29:a677458ac250
Parent:
28:441633d97018
Child:
30:980556537d9f
--- a/MAX11410.cpp	Tue Apr 21 05:54:07 2020 +0000
+++ b/MAX11410.cpp	Fri Apr 24 00:51:24 2020 +0000
@@ -409,7 +409,7 @@
 //
 // @test Init() expect 1
 //
-// @test group POR // verify initial register values (enabled by default)
+// @test group POR // verify initial register values
 // @test group PORverbose // verify initial register values
 // @test group PORverbose tinyTester.print("PART_ID value")
 // @test group POR RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, buffer) expect 1 expect-buffer 0x000F02
@@ -885,21 +885,21 @@
                 {
                     // after RegWrite CMD_r000_0011_xxxx_xddd_CAL_START, poll status until 0x000004 CAL_RDY
                     RegRead(CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS, &status);
-                    // wait until  /* MAX11410_STATUS_enum_t:: */ STATUS_000004_CAL_RDY indicates calibration is ready
-                    // Two conversions will execute at the rate
-                    // controlled by the FILTER register. The SELF_OFFSET and SELF_GAIN_1
-                    // registers will be updated.
-                    // Worst-case (longest) calibration time = 2 x 1 sample/second = 2 seconds
-                    // A bad SPI interface can cause bit slippage, which makes this loop get stuck. Expect *PART_ID? = 0x000F02
-                    // while ((status &  /* MAX11410_STATUS_enum_t:: */ STATUS_000010_DATA_RDY) == 0) {
-                    // possible infinite loop; need a timeout or futility countdown to escape
-                    // with one exception: skip the wait loop in the corner case where
-                    // cal_start=1 and pga is either buffer, bypass, or GAIN_000_1 -- 
-                    // these are effectively 1V/V gain path, and since it's already handled
-                    // by self calibration, the pga calibration command behaves as a no-operation.
-                    if ((regData != 1) || (pgaGain != 1))
+                    switch(regData & 0x07)
                     {
-                        // wait for CAL_RDY unless (cal_start=1 and pgaGain==1)
+                    case 2: // CAL_TYPE_010_reserved = 0x02, //!< 0b010
+                    case 3: // CAL_TYPE_011_reserved = 0x03, //!< 0b011
+                        break; // do not wait for status
+                    case 1: // CAL_TYPE_001_PGA_GAIN = 0x01, //!< 0b001
+                        if (pgaGain == 1) break; // do not wait for status
+                        // fall through to case 0,4,5,6,7
+                    case 0: // CAL_TYPE_000_SELF_CAL = 0x00, //!< 0b000
+                    case 4: // CAL_TYPE_100_SYS_OFF_A = 0x04, //!< 0b100
+                    case 5: // CAL_TYPE_101_SYS_GAIN_A = 0x05, //!< 0b101
+                    case 6: // CAL_TYPE_110_SYS_OFF_B = 0x06, //!< 0b110
+                    case 7: // CAL_TYPE_111_SYS_GAIN_B = 0x07, //!< 0b111
+                        // wait for status CAL_RDY
+                        // Worst-case (longest) calibration time = 2 x 1 sample/second = 2 seconds
                         for (int futility_countdown = loop_limit;
                             ((futility_countdown > 0) &&
                             ((status &  /* MAX11410_STATUS_enum_t:: */ STATUS_000004_CAL_RDY) == 0));
@@ -913,6 +913,7 @@
                                 RegRead(CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS, &status);
                             }
                         }
+                        break;
                     }
                 }
             }