Mode1 Optical Validation

Dependencies:   max32630fthr

Revision:
13:1baccc6275a7
Parent:
12:17a0bf823462
Child:
14:c8cc6d7fd5f9
diff -r 17a0bf823462 -r 1baccc6275a7 main.cpp
--- a/main.cpp	Thu Apr 01 01:51:52 2021 +0000
+++ b/main.cpp	Thu Apr 01 18:52:19 2021 +0000
@@ -56,7 +56,7 @@
 
 #define ALGO_ONLY 1  // define this if you only want the algo data, comment out if you want raw sensor+algo data
 //#define EXTENDED_ALGO 1  // define this if you want the extended algo format
-
+//#define AGC 1 // define this for AGC, otherwise the default is AEC
 
 #ifdef MAXREFDES103_CFG
 #include "MAX20303.h"
@@ -369,6 +369,29 @@
     sh_i2c.read(SH_ADDR, rsp, 1);
     mfio = 1; mfio = 0; wait_us(300);
     pc.printf("1.8 Status: %x\n\r", rsp[0]);
+#if AGC
+// AGC1.8 Disable auto PD (default
+    cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x12; cmd[3] = 0x00;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("AGC1.8 Status: %x\n\r", rsp[0]);
+// AGC1.9 Disable SCD (default)
+    cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0C; cmd[3] = 0x00;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("AGC1.9 Status: %x\n\r", rsp[0]);
+// AGC1.10 Set AGC target PD TO 10uA
+    cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x11; cmd[3] = 0x00; cmd[3] = 0x64;
+    sh_i2c.write(SH_ADDR, cmd, 5);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("AGC1.10 Status: %x\n\r", rsp[0]);
+#else
 // 1.9 auto PD (default
     cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x12; cmd[3] = 0x01;
     sh_i2c.write(SH_ADDR, cmd, 4);
@@ -383,6 +406,7 @@
     sh_i2c.read(SH_ADDR, rsp, 1);
     mfio = 1; mfio = 0; wait_us(300);
     pc.printf("1.7 Status: %x\n\r", rsp[0]);
+#endif
 #ifdef MAXM86146_CFG
 //1.20 Sec 4.1  map leds to slots for MAXM86146
     cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x19; cmd[3] = 0x13; cmd[4] = 0x56; cmd[5] = 0x00;