Treehouse Mbed Team / Mbed 2 deprecated APS_DCM1SL2

Dependencies:   mbed

Revision:
6:39442d493098
Parent:
5:09be5bbb5020
Child:
7:860b3a8275cb
diff -r 09be5bbb5020 -r 39442d493098 src/command.cpp
--- a/src/command.cpp	Sat Dec 01 00:08:53 2018 +0000
+++ b/src/command.cpp	Mon Dec 03 01:03:14 2018 +0000
@@ -42,8 +42,9 @@
 extern unsigned int boardsActive;
 extern unsigned int boardMults;
 extern unsigned int binCode[6];
-extern unsigned int thermCode[6];
+extern unsigned int thermCode[17];
 extern unsigned int commandData;
+extern unsigned short my12;
 
 /************* FILE SCOPE VARIABLES ************************/
 char setvalue = FALSE;
@@ -486,6 +487,10 @@
        strcpy(commandString, tok);
        tok = strtok(NULL, "=");
        commandData = atoi(tok);
+       //if(DEBUG){
+       //  sprintf(strbuf, "commandStringBuf= %s, commandData= %d", commandStringBuf, commandData);
+       //  sendSerial(strbuf);
+       //}
     }
     else{
         strcpy(commandString, commandStringBuf);
@@ -952,7 +957,7 @@
 {
    int ival;
    int ch, dac;
-   float fval;
+   //float fval;
    unsigned int data;
 
    char commandString[80] = { 0 };
@@ -1302,8 +1307,9 @@
 **************************************************************/
 void doCommand(void)
 {
-   int channelNum, channelSide, numPoints, i, ival;
-   char channelSideChar;
+   //int channelNum, channelSide, numPoints, i; 
+   int ival;
+   //char channelSideChar;
    unsigned int boardEnables;
 
    char commandString[80] = { 0 };
@@ -1343,7 +1349,7 @@
       else
       {
          if(checkRange(boardsActive, 0, 63) == 1){
-            setBoardEnables(binCode);
+            en_out_code = setBoardWeights(boardsActive);
          }else{
             showRangeError(1, boardsActive, 0.0);
          }
@@ -1370,21 +1376,42 @@
       else
       {
          if(checkRange(boardMults, 0, 63) == 1){
-            setBoardWeights(thermCode);
+            en_out_code = setBoardWeights(boardMults);
          }else{
             showRangeError(1, boardMults, 0.0);
          }
       }
    }
+   else if (!strcmp(commandString, "MY12"))
+   // MULT is used to get/set the en_out value. 
+   // The integer value of boardMults is used to change en_out via setBoardWeights(boardMults).
+   // en_out are binary weighted signals that activate groups of DC-DC converters on the slot cards.
+   // en_out[6] = {en32, en16, en8, en4, en2, en1}
+   {
+      my12 = commandData;
+      
+      //if(DEBUG){
+      //  sprintf(strbuf, "my12=%d commandData=%d\r\n", my12, commandData);
+      //  sendSerial(strbuf);
+      //}
+      
+      if (readback)
+      {
+         sprintf(strbuf, " %d", my12);
+         sendSerial(strbuf);
+      }
+   }
    else if (!strcmp(commandString, "ALLOFF"))
    {
       //hv_en = 1;
-      setBoardEnables(ALLOFF);
+      wr_out_code = setBoardEnables(ALLOFF);
+      //setBoardEnables((unsigned int *)alloff);
    }
    else if (!strcmp(commandString, "ALLON"))
    {
       //hv_en = 0;
-      setBoardEnables((unsigned int *)allon);
+      //setBoardEnables((unsigned int *)allon);
+      wr_out_code = setBoardEnables(ALLON);
    }
    else if (!strcmp(commandString, "DWL1_OV_TIME"))
    {
@@ -1444,7 +1471,6 @@
    else if (!strcmp(commandString, "STOP"))
    {
       stopConverter();
-      setBoardEnables(ALLOFF);
       //hv_en = OFF;
    }
 /*   else if (!strcmp(commandString, "CLEAR"))
@@ -1789,7 +1815,7 @@
 
    if (commandError)
    {
-      sendSerial(" ?");
+      sendSerial(" !");
    }
 
    //sendCRLF();