V1.1 For EVIC

Dependencies:   SDFileSystem max32630fthr USBDevice

Revision:
3:35b05d91568d
Parent:
1:7530b7eb757a
diff -r 3a8f285d261a -r 35b05d91568d CmdHandler.cpp
--- a/CmdHandler.cpp	Thu May 28 02:32:15 2020 +0000
+++ b/CmdHandler.cpp	Mon Jun 22 05:27:48 2020 +0000
@@ -33,6 +33,9 @@
 extern uint16_t histogram_pos_num;
 extern uint16_t histogram_per_pos;
 
+extern uint16_t range_step_num;
+extern uint16_t range_per_step;
+
 void CmdHandleTask(void)
 {
     uint8_t ret;
@@ -161,7 +164,7 @@
 
         case VAN_SINGLE_MEAS:// 单次测量
             if(HandleOneTimeMeasure() == 0)
-                UART_CmdAckSend(READ_CMD | 0x80, VAN_SINGLE_MEAS, _uart_send_pbuff, 4);
+                UART_CmdAckSend(READ_CMD | 0x80, VAN_SINGLE_MEAS, _uart_send_pbuff, 10);
             else
                 UART_CmdAckSend(READ_CMD | 0x10, VAN_SINGLE_MEAS, _uart_send_pbuff, 2);
             break;
@@ -211,6 +214,13 @@
                 histogram_pos_num = pd[6] + pd[7]*256;
                 histogram_per_pos = pd[8] + pd[9]*256;
             }
+            else if(pd[5] == 0xF2)
+            {
+                histogram_mode = 5;
+                range_step_num = pd[6] + pd[7]*256;
+                range_per_step = 0;
+                //histogram_per_pos = pd[8] + pd[9]*256;
+            }
             break;
 
         case VAN_MOVING_CTL_CMD:
@@ -257,6 +267,50 @@
             else
                 UART_CmdAckSend(READ_CMD | 0x10, VAN_GET_TDC_PHASE_CMD, _uart_send_pbuff, 2);
             break;
+            
+        case VAN_SET_WINDOW_CMD:
+            if(SetWindow(pd) == 0)
+                UART_CmdAckSend(WRITE_CMD | 0x80, VAN_SET_WINDOW_CMD, _uart_send_pbuff, 2);
+            else
+                UART_CmdAckSend(WRITE_CMD | 0x10, VAN_SET_WINDOW_CMD, _uart_send_pbuff, 2);
+        break;
+        
+        case VAN_RCO_TRIM_CMD:
+            if(RCO_Trim(_uart_send_pbuff) == 0)
+            {
+                _uart_send_pbuff[1] = _uart_send_pbuff[0];
+                _uart_send_pbuff[0] = 0;
+                UART_CmdAckSend(READ_CMD | 0x80, VAN_RCO_TRIM_CMD, _uart_send_pbuff, 2);
+            }
+            else
+            {
+                _uart_send_pbuff[1] = _uart_send_pbuff[0];
+                _uart_send_pbuff[0] = 1;
+                UART_CmdAckSend(READ_CMD | 0x10, VAN_RCO_TRIM_CMD, _uart_send_pbuff, 2);    
+            }    
+        break;
+        
+        case VAN_BVD_TRIM_CMD:
+            if(BVD_Trim(_uart_send_pbuff) == 0)
+            {
+                _uart_send_pbuff[1] = _uart_send_pbuff[0];
+                _uart_send_pbuff[0] = 0;
+                UART_CmdAckSend(READ_CMD | 0x80, VAN_BVD_TRIM_CMD, _uart_send_pbuff, 2);
+            } 
+            else
+            {
+                _uart_send_pbuff[1] = _uart_send_pbuff[0];
+                _uart_send_pbuff[0] = 0;
+                UART_CmdAckSend(READ_CMD | 0x10, VAN_BVD_TRIM_CMD, _uart_send_pbuff, 2);  
+            }      
+        break;
+        
+        case VAN_PIXEL_EN_CMD:
+            if(Pixel_Enable(_uart_send_pbuff) == 0)
+                UART_CmdAckSend(READ_CMD | 0x80, VAN_PIXEL_EN_CMD, _uart_send_pbuff, 2);
+            else
+                UART_CmdAckSend(READ_CMD | 0x10, VAN_PIXEL_EN_CMD, _uart_send_pbuff, 2);        
+        break;
 
         default:
 
@@ -297,7 +351,7 @@
 
 uint8_t HandleOneTimeMeasure(void)
 {
-    return OneTimeMeasure((uint16_t*)_uart_send_pbuff, (uint16_t*)(_uart_send_pbuff + 2));
+    return OneTimeMeasure((uint16_t*)_uart_send_pbuff, (uint16_t*)(_uart_send_pbuff + 2), (uint32_t*)(_uart_send_pbuff + 4), (uint16_t*)(_uart_send_pbuff + 8));
 }
 
 uint8_t HandleContinuousMeasure(uint8_t *pd)
@@ -359,12 +413,16 @@
     return ret;
 }
 
-uint8_t HandleContinuousMeasureReport(uint16_t lsb, uint16_t milimeter)
+uint8_t HandleContinuousMeasureReport(uint16_t lsb, uint16_t milimeter, uint32_t peak, uint16_t noise_level)
 {
     memcpy(_uart_send_pbuff, &lsb, 2);
     memcpy(_uart_send_pbuff + 2, &milimeter, 2);
+    
+    memcpy(_uart_send_pbuff + 4, &peak, 4);
+    memcpy(_uart_send_pbuff + 8, &noise_level, 2);
+    
 
-    UART_CmdAckSend(READ_CMD | 0x80, VAN_CONTIU_MEAS, _uart_send_pbuff, 4);
+    UART_CmdAckSend(READ_CMD | 0x80, VAN_CONTIU_MEAS, _uart_send_pbuff, 10);
 
     return 0;
 }