Treehouse Mbed Team / Mbed 2 deprecated APS_DCM1SL2

Dependencies:   mbed

Committer:
Slord2142
Date:
Thu Aug 22 18:31:39 2019 +0000
Revision:
34:419242dc004d
Parent:
33:6c7364ea360f
Child:
35:ec224d706f7c
Fixed RCRD/RTRV error

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfwic 0:44a3005d4f20 1 //-------------------------------------------------------------------------------
mfwic 0:44a3005d4f20 2 //
mfwic 0:44a3005d4f20 3 // Treehouse Inc.
mfwic 0:44a3005d4f20 4 // Colorado Springs, Colorado
mfwic 0:44a3005d4f20 5 //
mfwic 0:44a3005d4f20 6 // Copyright (c) 2016 by Treehouse Designs Inc.
mfwic 0:44a3005d4f20 7 //
mfwic 0:44a3005d4f20 8 // This code is the property of Treehouse, Inc. (Treehouse)
mfwic 0:44a3005d4f20 9 // and may not be redistributed in any form without prior written
mfwic 0:44a3005d4f20 10 // permission of the copyright holder, Treehouse.
mfwic 0:44a3005d4f20 11 //
mfwic 0:44a3005d4f20 12 // The above copyright notice and this permission notice shall be included in
mfwic 0:44a3005d4f20 13 // all copies or substantial portions of the Software.
mfwic 0:44a3005d4f20 14 //
mfwic 0:44a3005d4f20 15 //
mfwic 0:44a3005d4f20 16 //-------------------------------------------------------------------------------
mfwic 0:44a3005d4f20 17 //
mfwic 0:44a3005d4f20 18 // REVISION HISTORY:
mfwic 0:44a3005d4f20 19 //
mfwic 0:44a3005d4f20 20 // $Author: $
mfwic 0:44a3005d4f20 21 // $Rev: $
mfwic 0:44a3005d4f20 22 // $Date: $
mfwic 0:44a3005d4f20 23 // $URL: $
mfwic 0:44a3005d4f20 24 //
mfwic 0:44a3005d4f20 25 //-------------------------------------------------------------------------------
mfwic 0:44a3005d4f20 26
mfwic 0:44a3005d4f20 27 #include "mbed.h"
mfwic 0:44a3005d4f20 28 #include "string.h"
mfwic 0:44a3005d4f20 29 #include "stdio.h"
mfwic 0:44a3005d4f20 30 #include "stdlib.h"
mfwic 0:44a3005d4f20 31 #include "ctype.h"
mfwic 0:44a3005d4f20 32 #include "serial.h"
mfwic 0:44a3005d4f20 33 #include "globals.h"
mfwic 0:44a3005d4f20 34 #include "math.h"
mfwic 0:44a3005d4f20 35 #include "parameters.h"
mfwic 1:9f8583ba2431 36 #include "all_io.h"
mfwic 1:9f8583ba2431 37 #include "boards.h"
mfwic 1:9f8583ba2431 38 #include "menu.h"
mfwic 8:d3d7dca419b3 39 #include "command.h"
Slord2142 33:6c7364ea360f 40 #include "SOFBlock.h"
Slord2142 33:6c7364ea360f 41 #include "adc.h"
mfwic 0:44a3005d4f20 42
Slord2142 33:6c7364ea360f 43 uint8_t *storo;
Slord2142 34:419242dc004d 44 char storoBuild[200], storoFrag[10];
Slord2142 33:6c7364ea360f 45 char storoSpace[2] = ":";
mfwic 21:fe0ea1860c9f 46 unsigned int boardsActive = ALLON;
mfwic 21:fe0ea1860c9f 47 unsigned int boardMults = 32;
Slord2142 33:6c7364ea360f 48 double commandData;
Slord2142 33:6c7364ea360f 49 unsigned int section;
Slord2142 33:6c7364ea360f 50 unsigned int fort;
Slord2142 33:6c7364ea360f 51 unsigned int select;
Slord2142 33:6c7364ea360f 52 double VOLTAGE_48_ACTUAL_VALUE = 1.51;
Slord2142 33:6c7364ea360f 53 double VOLTAGE_24_ACTUAL_VALUE = 1.55;
Slord2142 33:6c7364ea360f 54 double VOLTAGE_12_ACTUAL_VALUE = 1.65;
Slord2142 33:6c7364ea360f 55 double VOLTAGE_48_OFFSET = 0;
Slord2142 33:6c7364ea360f 56 double VOLTAGE_24_OFFSET = 0;
Slord2142 33:6c7364ea360f 57 double VOLTAGE_12_OFFSET = 0;
Slord2142 33:6c7364ea360f 58 int Vloc = 0;
Slord2142 33:6c7364ea360f 59 int Aloc = 0;
Slord2142 33:6c7364ea360f 60 double VOLTAGE_CAL_1;
Slord2142 33:6c7364ea360f 61 double VOLTAGE_CAL_2;
Slord2142 33:6c7364ea360f 62 double VOLTAGE_CAL_3;
Slord2142 33:6c7364ea360f 63 double VSTORE_1;
Slord2142 33:6c7364ea360f 64 double VSTORE_2;
Slord2142 33:6c7364ea360f 65 double VSTORE_3;
Slord2142 33:6c7364ea360f 66 struct adcValues adcVals;
Slord2142 33:6c7364ea360f 67 struct displayValues dvals;
Slord2142 33:6c7364ea360f 68 signed int CURRENT_48_DIV_FACTOR5 = -370;
Slord2142 33:6c7364ea360f 69 signed int CURRENT_48_DIV_FACTOR4 = -570;
Slord2142 33:6c7364ea360f 70 signed int CURRENT_48_DIV_FACTOR3 = -740;
Slord2142 33:6c7364ea360f 71 signed int CURRENT_48_DIV_FACTOR2 = -948;
Slord2142 33:6c7364ea360f 72 signed int CURRENT_48_DIV_FACTOR1 = -1541;
Slord2142 33:6c7364ea360f 73 signed int CURRENT_48_DIV_FACTOR0 = -1610;
Slord2142 33:6c7364ea360f 74
Slord2142 33:6c7364ea360f 75 unsigned int CURRENT_48_DIV_THRESH5 = 3000;
Slord2142 33:6c7364ea360f 76 unsigned int CURRENT_48_DIV_THRESH4 = 2500;
Slord2142 33:6c7364ea360f 77 unsigned int CURRENT_48_DIV_THRESH3 = 2000;
Slord2142 33:6c7364ea360f 78 unsigned int CURRENT_48_DIV_THRESH2 = 1500;
Slord2142 33:6c7364ea360f 79 unsigned int CURRENT_48_DIV_THRESH1 = 500;
Slord2142 33:6c7364ea360f 80
Slord2142 33:6c7364ea360f 81 signed int CURRENT_24_DIV_FACTOR = -376;
Slord2142 33:6c7364ea360f 82
Slord2142 33:6c7364ea360f 83 signed int CURRENT_12_DIV_FACTOR5 = -188;
Slord2142 33:6c7364ea360f 84 signed int CURRENT_12_DIV_FACTOR4 = -186;
Slord2142 33:6c7364ea360f 85 signed int CURRENT_12_DIV_FACTOR3 = -182;
Slord2142 33:6c7364ea360f 86 signed int CURRENT_12_DIV_FACTOR2 = -177;
Slord2142 33:6c7364ea360f 87 signed int CURRENT_12_DIV_FACTOR1 = -179;
Slord2142 33:6c7364ea360f 88 signed int CURRENT_12_DIV_FACTOR0 = -175;
Slord2142 33:6c7364ea360f 89
Slord2142 33:6c7364ea360f 90 unsigned int CURRENT_12_DIV_THRESH5 = 1600;
Slord2142 33:6c7364ea360f 91 unsigned int CURRENT_12_DIV_THRESH4 = 800;
Slord2142 33:6c7364ea360f 92 unsigned int CURRENT_12_DIV_THRESH3 = 600;
Slord2142 33:6c7364ea360f 93 unsigned int CURRENT_12_DIV_THRESH2 = 400;
Slord2142 33:6c7364ea360f 94 unsigned int CURRENT_12_DIV_THRESH1 = 200;
Slord2142 33:6c7364ea360f 95
Slord2142 33:6c7364ea360f 96 unsigned int CURRENT_REF_1;
Slord2142 33:6c7364ea360f 97 unsigned int CURRENT_REF_2;
Slord2142 33:6c7364ea360f 98 unsigned int CURRENT_REF_3;
Slord2142 33:6c7364ea360f 99 unsigned int CURRENT_REF_4;
Slord2142 33:6c7364ea360f 100 unsigned int CURRENT_REF_5;
Slord2142 33:6c7364ea360f 101 unsigned int CURRENT_REF_6;
Slord2142 33:6c7364ea360f 102 double CURRENT_IN_1;
Slord2142 33:6c7364ea360f 103 double CURRENT_IN_2;
Slord2142 33:6c7364ea360f 104 double CURRENT_IN_3;
Slord2142 33:6c7364ea360f 105 double CURRENT_IN_4;
Slord2142 33:6c7364ea360f 106 double CURRENT_IN_5;
Slord2142 33:6c7364ea360f 107 double CURRENT_IN_6;
Slord2142 33:6c7364ea360f 108
Slord2142 33:6c7364ea360f 109 double CURRENT_12_CORRECTION0;
Slord2142 33:6c7364ea360f 110 double CURRENT_12_CORRECTION1;
Slord2142 33:6c7364ea360f 111 double CURRENT_12_CORRECTION2;
Slord2142 33:6c7364ea360f 112 double CURRENT_12_CORRECTION3;
Slord2142 33:6c7364ea360f 113 double CURRENT_12_CORRECTION4;
Slord2142 33:6c7364ea360f 114 double CURRENT_12_CORRECTION5;
mfwic 6:39442d493098 115 extern unsigned short my12;
Slord2142 33:6c7364ea360f 116 char storage[50];
Slord2142 33:6c7364ea360f 117
Slord2142 33:6c7364ea360f 118 /************* TEMPORARY WRITING BLOCK *********************/
Slord2142 33:6c7364ea360f 119
Slord2142 33:6c7364ea360f 120 SOFWriter writer;
Slord2142 33:6c7364ea360f 121 SOFReader reader;
mfwic 0:44a3005d4f20 122
mfwic 0:44a3005d4f20 123 /************* FILE SCOPE VARIABLES ************************/
mfwic 0:44a3005d4f20 124 char setvalue = FALSE;
mfwic 0:44a3005d4f20 125 int endOfCommand = 0;
mfwic 0:44a3005d4f20 126 int commandError = 0;
mfwic 0:44a3005d4f20 127 int menuLevel = LEVEL_MAIN;
mfwic 0:44a3005d4f20 128 int readback = 0;
mfwic 0:44a3005d4f20 129
mfwic 0:44a3005d4f20 130 /************************************************************
mfwic 0:44a3005d4f20 131 * Routine: getDelimiter
mfwic 0:44a3005d4f20 132 * Input: none
mfwic 0:44a3005d4f20 133 * Output: none
mfwic 0:44a3005d4f20 134 * Description:
mfwic 0:44a3005d4f20 135 * searches for a delimiter and moves the buffer location
mfwic 0:44a3005d4f20 136 * to be just past it
mfwic 0:44a3005d4f20 137 *
mfwic 0:44a3005d4f20 138 **************************************************************/
mfwic 0:44a3005d4f20 139 void getDelimiter(void)
mfwic 0:44a3005d4f20 140 {
mfwic 0:44a3005d4f20 141 ++bufloc;
mfwic 0:44a3005d4f20 142
mfwic 0:44a3005d4f20 143 while ((rxbuf[bufloc] != ' ') &&
mfwic 0:44a3005d4f20 144 (rxbuf[bufloc] != ',') &&
mfwic 0:44a3005d4f20 145 (rxbuf[bufloc] != '=') &&
mfwic 0:44a3005d4f20 146 (rxbuf[bufloc] != 0 ))
mfwic 0:44a3005d4f20 147 {
mfwic 0:44a3005d4f20 148 bufloc++;
mfwic 0:44a3005d4f20 149 }
mfwic 0:44a3005d4f20 150 }
mfwic 0:44a3005d4f20 151
mfwic 0:44a3005d4f20 152 /************************************************************
mfwic 0:44a3005d4f20 153 * Routine: gethex
mfwic 0:44a3005d4f20 154 * Input: hex character
mfwic 0:44a3005d4f20 155 * Returns: hex integer
mfwic 0:44a3005d4f20 156 * Description:
mfwic 0:44a3005d4f20 157 * Converts a hex character to a value
mfwic 0:44a3005d4f20 158 **************************************************************/
mfwic 0:44a3005d4f20 159 char gethex(char val)
mfwic 0:44a3005d4f20 160 {
mfwic 0:44a3005d4f20 161 int retval;
mfwic 0:44a3005d4f20 162 switch(val)
mfwic 0:44a3005d4f20 163 {
mfwic 0:44a3005d4f20 164 case '0':
mfwic 0:44a3005d4f20 165 retval = 0;
mfwic 0:44a3005d4f20 166 break;
mfwic 0:44a3005d4f20 167 case '1':
mfwic 0:44a3005d4f20 168 retval = 1;
mfwic 0:44a3005d4f20 169 break;
mfwic 0:44a3005d4f20 170 case '2':
mfwic 0:44a3005d4f20 171 retval = 2;
mfwic 0:44a3005d4f20 172 break;
mfwic 0:44a3005d4f20 173 case '3':
mfwic 0:44a3005d4f20 174 retval = 3;
mfwic 0:44a3005d4f20 175 break;
mfwic 0:44a3005d4f20 176 case '4':
mfwic 0:44a3005d4f20 177 retval = 4;
mfwic 0:44a3005d4f20 178 break;
mfwic 0:44a3005d4f20 179 case '5':
mfwic 0:44a3005d4f20 180 retval = 5;
mfwic 0:44a3005d4f20 181 break;
mfwic 0:44a3005d4f20 182 case '6':
mfwic 0:44a3005d4f20 183 retval = 6;
mfwic 0:44a3005d4f20 184 break;
mfwic 0:44a3005d4f20 185 case '7':
mfwic 0:44a3005d4f20 186 retval = 7;
mfwic 0:44a3005d4f20 187 break;
mfwic 0:44a3005d4f20 188 case '8':
mfwic 0:44a3005d4f20 189 retval = 8;
mfwic 0:44a3005d4f20 190 break;
mfwic 0:44a3005d4f20 191 case '9':
mfwic 0:44a3005d4f20 192 retval = 9;
mfwic 0:44a3005d4f20 193 break;
mfwic 0:44a3005d4f20 194 case 'A':
mfwic 0:44a3005d4f20 195 retval = 10;
mfwic 0:44a3005d4f20 196 break;
mfwic 0:44a3005d4f20 197 case 'B':
mfwic 0:44a3005d4f20 198 retval = 11;
mfwic 0:44a3005d4f20 199 break;
mfwic 0:44a3005d4f20 200 case 'C':
mfwic 0:44a3005d4f20 201 retval = 12;
mfwic 0:44a3005d4f20 202 break;
mfwic 0:44a3005d4f20 203 case 'D':
mfwic 0:44a3005d4f20 204 retval = 13;
mfwic 0:44a3005d4f20 205 break;
mfwic 0:44a3005d4f20 206 case 'E':
mfwic 0:44a3005d4f20 207 retval = 14;
mfwic 0:44a3005d4f20 208 break;
mfwic 0:44a3005d4f20 209 case 'F':
mfwic 0:44a3005d4f20 210 retval = 15;
mfwic 0:44a3005d4f20 211 break;
mfwic 0:44a3005d4f20 212 default:
mfwic 0:44a3005d4f20 213 retval = 0;
mfwic 0:44a3005d4f20 214 break;
mfwic 0:44a3005d4f20 215
mfwic 0:44a3005d4f20 216 }
mfwic 0:44a3005d4f20 217 return retval;
mfwic 0:44a3005d4f20 218 }
mfwic 0:44a3005d4f20 219
mfwic 0:44a3005d4f20 220 /************************************************************
mfwic 0:44a3005d4f20 221 * Routine: showfval
mfwic 0:44a3005d4f20 222 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 223 * value (float value to display)
mfwic 0:44a3005d4f20 224 * Output: none
mfwic 0:44a3005d4f20 225 * Description:
mfwic 0:44a3005d4f20 226 * Sends a floating point number (value) over the serial port
mfwic 0:44a3005d4f20 227 * if it is being retrieved (GET)
mfwic 0:44a3005d4f20 228 *
mfwic 0:44a3005d4f20 229 **************************************************************/
mfwic 0:44a3005d4f20 230 void showfval(char setval,float value)
mfwic 0:44a3005d4f20 231 {
mfwic 0:44a3005d4f20 232 if(!setval)
mfwic 0:44a3005d4f20 233 {
mfwic 1:9f8583ba2431 234 sprintf(strbuf," %4.9f",value);
mfwic 1:9f8583ba2431 235 sendSerial(strbuf);
mfwic 0:44a3005d4f20 236 }
mfwic 0:44a3005d4f20 237 }
mfwic 0:44a3005d4f20 238
mfwic 0:44a3005d4f20 239 /************************************************************
mfwic 0:44a3005d4f20 240 * Routine: showival
mfwic 0:44a3005d4f20 241 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 242 * value (integer value to display)
mfwic 0:44a3005d4f20 243 * Output: none
mfwic 0:44a3005d4f20 244 * Description:
mfwic 0:44a3005d4f20 245 * Sends an integer (value) over the serial port
mfwic 0:44a3005d4f20 246 * if it is being retrieved (GET)
mfwic 0:44a3005d4f20 247 *
mfwic 0:44a3005d4f20 248 **************************************************************/
mfwic 0:44a3005d4f20 249 void showival(char setval, int value)
mfwic 0:44a3005d4f20 250 {
mfwic 0:44a3005d4f20 251 if(!setval)
mfwic 0:44a3005d4f20 252 {
mfwic 1:9f8583ba2431 253 sprintf(strbuf," %i",value);
mfwic 1:9f8583ba2431 254 sendSerial(strbuf);
mfwic 0:44a3005d4f20 255 }
mfwic 0:44a3005d4f20 256 }
mfwic 0:44a3005d4f20 257 /************************************************************
mfwic 0:44a3005d4f20 258 * Routine: showcval
mfwic 0:44a3005d4f20 259 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 260 * value (character to display)
mfwic 0:44a3005d4f20 261 * Output: none
mfwic 0:44a3005d4f20 262 * Description:
mfwic 0:44a3005d4f20 263 * Sends a character over the serial port
mfwic 0:44a3005d4f20 264 * if it is being retrieved (GET)
mfwic 0:44a3005d4f20 265 *
mfwic 0:44a3005d4f20 266 **************************************************************/
mfwic 0:44a3005d4f20 267 void showcval(char setval, int value)
mfwic 0:44a3005d4f20 268 {
mfwic 0:44a3005d4f20 269 if(!setval)
mfwic 0:44a3005d4f20 270 {
mfwic 1:9f8583ba2431 271 sprintf(strbuf," %c",(char)value);
mfwic 1:9f8583ba2431 272 sendSerial(strbuf);
mfwic 0:44a3005d4f20 273 }
mfwic 0:44a3005d4f20 274 }
mfwic 0:44a3005d4f20 275
mfwic 0:44a3005d4f20 276 /************************************************************
mfwic 0:44a3005d4f20 277 * Routine: showlval
mfwic 0:44a3005d4f20 278 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 279 * value (integer value to display)
mfwic 0:44a3005d4f20 280 * Output: none
mfwic 0:44a3005d4f20 281 * Description:
mfwic 0:44a3005d4f20 282 * Sends an long (value) over the serial port
mfwic 0:44a3005d4f20 283 * if it is being retrieved (GET)
mfwic 0:44a3005d4f20 284 *
mfwic 0:44a3005d4f20 285 **************************************************************/
mfwic 0:44a3005d4f20 286 void showlval(char setval, long value)
mfwic 0:44a3005d4f20 287 {
mfwic 0:44a3005d4f20 288 if(!setval)
mfwic 0:44a3005d4f20 289 {
mfwic 1:9f8583ba2431 290 sprintf(strbuf," %ld",value);
mfwic 1:9f8583ba2431 291 sendSerial(strbuf);
mfwic 0:44a3005d4f20 292 }
mfwic 0:44a3005d4f20 293 }
mfwic 0:44a3005d4f20 294
mfwic 0:44a3005d4f20 295 /************************************************************
mfwic 0:44a3005d4f20 296 * Routine: showuival
mfwic 0:44a3005d4f20 297 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 298 * value (integer value to display)
mfwic 0:44a3005d4f20 299 * Output: none
mfwic 0:44a3005d4f20 300 * Description:
mfwic 0:44a3005d4f20 301 * Sends an unsigned int (value) over the serial port
mfwic 0:44a3005d4f20 302 * if it is being retrieved (GET)
mfwic 0:44a3005d4f20 303 *
mfwic 0:44a3005d4f20 304 **************************************************************/
mfwic 0:44a3005d4f20 305 void showuival(char setval, unsigned int value)
mfwic 0:44a3005d4f20 306 {
mfwic 0:44a3005d4f20 307 if(!setval)
mfwic 0:44a3005d4f20 308 {
mfwic 1:9f8583ba2431 309 sprintf(strbuf," %u",value);
mfwic 1:9f8583ba2431 310 sendSerial(strbuf);
mfwic 0:44a3005d4f20 311 }
mfwic 0:44a3005d4f20 312 }
mfwic 0:44a3005d4f20 313
mfwic 0:44a3005d4f20 314 /************************************************************
mfwic 0:44a3005d4f20 315 * Routine: showhval
mfwic 0:44a3005d4f20 316 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 317 * value (hex integeger value to display)
mfwic 0:44a3005d4f20 318 * Output: none
mfwic 0:44a3005d4f20 319 * Description:
mfwic 0:44a3005d4f20 320 * Sends an integer (value) in hex over the serial port
mfwic 0:44a3005d4f20 321 * if it is being retrieved (GET)
mfwic 0:44a3005d4f20 322 *
mfwic 0:44a3005d4f20 323 **************************************************************/
mfwic 0:44a3005d4f20 324 void showhval(char setval, int value)
mfwic 0:44a3005d4f20 325 {
mfwic 0:44a3005d4f20 326 if(!setval)
mfwic 0:44a3005d4f20 327 {
mfwic 0:44a3005d4f20 328 if(serialStatus.computer)
mfwic 1:9f8583ba2431 329 sprintf(strbuf," %u",(unsigned int)value);
mfwic 0:44a3005d4f20 330 else
mfwic 1:9f8583ba2431 331 sprintf(strbuf," 0x%04x",value);
mfwic 1:9f8583ba2431 332 sendSerial(strbuf);
mfwic 0:44a3005d4f20 333 }
mfwic 0:44a3005d4f20 334 }
mfwic 0:44a3005d4f20 335
mfwic 0:44a3005d4f20 336
mfwic 0:44a3005d4f20 337 /************************************************************
mfwic 0:44a3005d4f20 338 * Routine: getival
mfwic 0:44a3005d4f20 339 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 340 * Returns: the value if it is being SET or 0 if it is a GET
mfwic 0:44a3005d4f20 341 * Description:
mfwic 0:44a3005d4f20 342 * Gets an integer from the serial port connection.
mfwic 0:44a3005d4f20 343 *
mfwic 0:44a3005d4f20 344 **************************************************************/
mfwic 0:44a3005d4f20 345 int getival(char setval)
mfwic 0:44a3005d4f20 346 {
mfwic 0:44a3005d4f20 347 if (setval)
mfwic 0:44a3005d4f20 348 {
mfwic 0:44a3005d4f20 349 return atoi(&rxbuf[++bufloc]);
mfwic 0:44a3005d4f20 350 }
mfwic 0:44a3005d4f20 351
mfwic 0:44a3005d4f20 352 return 0;
mfwic 0:44a3005d4f20 353 }
mfwic 0:44a3005d4f20 354
mfwic 0:44a3005d4f20 355 /************************************************************
mfwic 0:44a3005d4f20 356 * Routine: getcval
mfwic 0:44a3005d4f20 357 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 358 * Returns: the value if it is being SET or 0 if it is a GET
mfwic 0:44a3005d4f20 359 * Description:
mfwic 0:44a3005d4f20 360 * Gets an character from the serial port connection.
mfwic 0:44a3005d4f20 361 *
mfwic 0:44a3005d4f20 362 **************************************************************/
mfwic 0:44a3005d4f20 363 int getcval(char setval)
mfwic 0:44a3005d4f20 364 {
mfwic 0:44a3005d4f20 365 if(setval)
mfwic 0:44a3005d4f20 366 {
mfwic 0:44a3005d4f20 367 // skip one space
mfwic 0:44a3005d4f20 368 ++bufloc;
mfwic 0:44a3005d4f20 369 // skip spaces and the equals sign
mfwic 0:44a3005d4f20 370 while((rxbuf[bufloc] == ' ') || (rxbuf[bufloc] == '='))
mfwic 0:44a3005d4f20 371 bufloc++;
mfwic 0:44a3005d4f20 372 return rxbuf[bufloc++];
mfwic 0:44a3005d4f20 373 }
mfwic 0:44a3005d4f20 374 else
mfwic 0:44a3005d4f20 375 return 0;
mfwic 0:44a3005d4f20 376
mfwic 0:44a3005d4f20 377 }
mfwic 0:44a3005d4f20 378 /************************************************************
mfwic 0:44a3005d4f20 379 * Routine: getlval
mfwic 0:44a3005d4f20 380 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 381 * Returns: the value if it is being SET or 0 if it is a GET
mfwic 0:44a3005d4f20 382 * Description:
mfwic 0:44a3005d4f20 383 * Gets an long from the serial port connection.
mfwic 0:44a3005d4f20 384 *
mfwic 0:44a3005d4f20 385 **************************************************************/
mfwic 0:44a3005d4f20 386 long getlval(char setval)
mfwic 0:44a3005d4f20 387 {
mfwic 0:44a3005d4f20 388 if(setval)
mfwic 0:44a3005d4f20 389 return atol(&rxbuf[++bufloc]);
mfwic 0:44a3005d4f20 390 else
mfwic 0:44a3005d4f20 391 return 0;
mfwic 0:44a3005d4f20 392
mfwic 0:44a3005d4f20 393 }
mfwic 0:44a3005d4f20 394
mfwic 0:44a3005d4f20 395 /************************************************************
mfwic 0:44a3005d4f20 396 * Routine: getfval
mfwic 0:44a3005d4f20 397 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 398 * Returns: the value if it is being SET or 0 if it is a GET
mfwic 0:44a3005d4f20 399 * Description:
mfwic 0:44a3005d4f20 400 * Gets an float from the serial port connection.
mfwic 0:44a3005d4f20 401 *
mfwic 0:44a3005d4f20 402 **************************************************************/
mfwic 0:44a3005d4f20 403 float getfval(char setval)
mfwic 0:44a3005d4f20 404 {
mfwic 0:44a3005d4f20 405 if(setval)
mfwic 0:44a3005d4f20 406 return atof(&rxbuf[++bufloc]);
mfwic 0:44a3005d4f20 407 else
mfwic 0:44a3005d4f20 408 return 0;
mfwic 0:44a3005d4f20 409 }
mfwic 0:44a3005d4f20 410
mfwic 0:44a3005d4f20 411 /************************************************************
mfwic 0:44a3005d4f20 412 * Routine: validateEntry
mfwic 0:44a3005d4f20 413 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 414 * limlo -- low limit
mfwic 0:44a3005d4f20 415 * limhi -- high limit
mfwic 0:44a3005d4f20 416 * address -- address in eeprom to use
mfwic 0:44a3005d4f20 417 * Returns: 0 if entry validates and is written
mfwic 0:44a3005d4f20 418 * 1 if entry fails
mfwic 0:44a3005d4f20 419 * Description:
mfwic 0:44a3005d4f20 420 * Gets or sets a value in eeprom at the address but only
mfwic 0:44a3005d4f20 421 * if it is between the limits will it write the value to
mfwic 0:44a3005d4f20 422 * eeprom
mfwic 0:44a3005d4f20 423 *
mfwic 0:44a3005d4f20 424 **************************************************************/
mfwic 0:44a3005d4f20 425 int validateEntry(char setvalue, float limlo, float limhi, float *address)
mfwic 0:44a3005d4f20 426 {
mfwic 0:44a3005d4f20 427 float val;
mfwic 0:44a3005d4f20 428
mfwic 0:44a3005d4f20 429 if (setvalue)
mfwic 0:44a3005d4f20 430 {
mfwic 0:44a3005d4f20 431 val = getfval(SET);
mfwic 0:44a3005d4f20 432
mfwic 0:44a3005d4f20 433 if ((val >= limlo) && (val <= limhi))
mfwic 0:44a3005d4f20 434 {
mfwic 0:44a3005d4f20 435 *address = val;
mfwic 0:44a3005d4f20 436 }
mfwic 0:44a3005d4f20 437 else
mfwic 0:44a3005d4f20 438 {
mfwic 0:44a3005d4f20 439 showRangeError(0, 0, val);
mfwic 0:44a3005d4f20 440 return 0;
mfwic 0:44a3005d4f20 441 }
mfwic 0:44a3005d4f20 442 }
mfwic 0:44a3005d4f20 443 else
mfwic 0:44a3005d4f20 444 {
mfwic 0:44a3005d4f20 445 val = *address;
mfwic 1:9f8583ba2431 446 sprintf(strbuf, " %4.3f", val);
mfwic 1:9f8583ba2431 447 sendSerial(strbuf);
mfwic 0:44a3005d4f20 448 }
mfwic 0:44a3005d4f20 449
mfwic 0:44a3005d4f20 450 return 1;
mfwic 0:44a3005d4f20 451 }
mfwic 0:44a3005d4f20 452
mfwic 0:44a3005d4f20 453
mfwic 0:44a3005d4f20 454 /************************************************************
mfwic 0:44a3005d4f20 455 * Routine: validateEntry
mfwic 0:44a3005d4f20 456 * Input: setval (GET or SET)
mfwic 0:44a3005d4f20 457 * limlo -- low limit
mfwic 0:44a3005d4f20 458 * limhi -- high limit
mfwic 0:44a3005d4f20 459 * address -- address in eeprom to use
mfwic 0:44a3005d4f20 460 *
mfwic 0:44a3005d4f20 461 * Returns: FALSE if entry fails
mfwic 0:44a3005d4f20 462 * TRUE if entry validates and is written
mfwic 0:44a3005d4f20 463 *
mfwic 0:44a3005d4f20 464 * Description:
mfwic 0:44a3005d4f20 465 * Gets or sets a value in eeprom at the address but only
mfwic 0:44a3005d4f20 466 * if it is between the limits will it write the value to
mfwic 0:44a3005d4f20 467 * eeprom
mfwic 0:44a3005d4f20 468 *
mfwic 0:44a3005d4f20 469 **************************************************************/
mfwic 0:44a3005d4f20 470 int validateInt(char setvalue, int limlo, int limhi, int *address)
mfwic 0:44a3005d4f20 471 {
mfwic 0:44a3005d4f20 472 float val;
mfwic 0:44a3005d4f20 473
mfwic 0:44a3005d4f20 474 if (setvalue)
mfwic 0:44a3005d4f20 475 {
mfwic 0:44a3005d4f20 476 val = getfval(SET);
mfwic 0:44a3005d4f20 477
mfwic 0:44a3005d4f20 478 if ((val >= limlo) && (val <= limhi))
mfwic 0:44a3005d4f20 479 {
mfwic 0:44a3005d4f20 480 *address = val;
mfwic 0:44a3005d4f20 481 }
mfwic 0:44a3005d4f20 482 else
mfwic 0:44a3005d4f20 483 {
mfwic 0:44a3005d4f20 484 showRangeError(1, val, 0);
mfwic 0:44a3005d4f20 485 return FALSE;
mfwic 0:44a3005d4f20 486 }
mfwic 0:44a3005d4f20 487 }
mfwic 0:44a3005d4f20 488 else
mfwic 0:44a3005d4f20 489 {
mfwic 0:44a3005d4f20 490 val = *address;
mfwic 1:9f8583ba2431 491 sprintf(strbuf, " %4.0f", val);
mfwic 1:9f8583ba2431 492 sendSerial(strbuf);
mfwic 0:44a3005d4f20 493 }
mfwic 0:44a3005d4f20 494
mfwic 0:44a3005d4f20 495 return TRUE;
mfwic 0:44a3005d4f20 496 }
mfwic 0:44a3005d4f20 497
mfwic 0:44a3005d4f20 498
mfwic 0:44a3005d4f20 499 /************************************************************
mfwic 0:44a3005d4f20 500 * Routine: parseCommand
mfwic 0:44a3005d4f20 501 * Input: setvalue (GET or SET), command buffer
mfwic 0:44a3005d4f20 502 * Returns: none
mfwic 0:44a3005d4f20 503 * Description:
mfwic 0:44a3005d4f20 504 * parses a command and gets the commandstring
mfwic 0:44a3005d4f20 505 **************************************************************/
mfwic 0:44a3005d4f20 506 void parseCommand(char setvalue, char *commandString)
mfwic 0:44a3005d4f20 507 {
mfwic 0:44a3005d4f20 508 int i, endofc;
mfwic 0:44a3005d4f20 509 char store;
mfwic 0:44a3005d4f20 510
mfwic 0:44a3005d4f20 511 // Ignore any white space and the optional ';' character before the start of
mfwic 0:44a3005d4f20 512 // the command string (any ']' character is from the last command so skip that,
mfwic 0:44a3005d4f20 513 // too)
mfwic 0:44a3005d4f20 514 while ((isspace(rxbuf[bufloc])) || (rxbuf[bufloc] == ';') || (rxbuf[bufloc] == ']'))
mfwic 0:44a3005d4f20 515 {
mfwic 0:44a3005d4f20 516 bufloc++;
mfwic 0:44a3005d4f20 517 if ((rxbuf[bufloc] == 0x0D) || (rxbuf[bufloc] == 0)) break;
mfwic 0:44a3005d4f20 518 }
mfwic 0:44a3005d4f20 519
mfwic 0:44a3005d4f20 520 if (setvalue)
mfwic 0:44a3005d4f20 521 {
mfwic 0:44a3005d4f20 522 // We need a value for SET so hitting the end is a problem
mfwic 0:44a3005d4f20 523 if ((rxbuf[bufloc] == 0) || (rxbuf[bufloc] == 0x0D))
mfwic 0:44a3005d4f20 524 {
mfwic 0:44a3005d4f20 525 commandError = 1;
mfwic 0:44a3005d4f20 526 return;
mfwic 0:44a3005d4f20 527 }
mfwic 0:44a3005d4f20 528 }
mfwic 0:44a3005d4f20 529
mfwic 0:44a3005d4f20 530 // Find the end of the command string
mfwic 0:44a3005d4f20 531 endofc = bufloc + 1;
mfwic 0:44a3005d4f20 532
mfwic 0:44a3005d4f20 533 // White space, '[' and '?' all terminate the command string
mfwic 0:44a3005d4f20 534 while ((!isspace(rxbuf[endofc])) && (rxbuf[endofc] != '[') && (rxbuf[endofc] != '?'))
mfwic 0:44a3005d4f20 535 {
mfwic 0:44a3005d4f20 536 endofc++;
mfwic 0:44a3005d4f20 537 // (As does hitting the end of rxbuf!)
mfwic 0:44a3005d4f20 538 if ((rxbuf[endofc] == 0x0D) || (rxbuf[endofc] == 0)) break;
mfwic 0:44a3005d4f20 539 }
mfwic 0:44a3005d4f20 540
mfwic 0:44a3005d4f20 541 // Save the character that marks the end of the command string
mfwic 0:44a3005d4f20 542 store = rxbuf[endofc];
mfwic 0:44a3005d4f20 543
mfwic 1:9f8583ba2431 544 // sprintf(strbuf, "store == %c\r\n", store);
mfwic 1:9f8583ba2431 545 // sendSerial(strbuf);
mfwic 0:44a3005d4f20 546
mfwic 0:44a3005d4f20 547 // Command strings ending in '?' are readbacks
mfwic 0:44a3005d4f20 548 readback = ((store == '?') ? 1 : 0);
mfwic 0:44a3005d4f20 549
mfwic 0:44a3005d4f20 550 // Set end to null character so string can now be copied
mfwic 0:44a3005d4f20 551 rxbuf[endofc] = 0;
mfwic 0:44a3005d4f20 552
mfwic 0:44a3005d4f20 553 // Copy the command string into commandString
mfwic 5:09be5bbb5020 554 char commandStringBuf[80];
mfwic 5:09be5bbb5020 555 char *tok;
mfwic 5:09be5bbb5020 556 strcpy(commandStringBuf, &rxbuf[bufloc]);
mfwic 5:09be5bbb5020 557 if(strstr(commandStringBuf, "=")){
mfwic 5:09be5bbb5020 558 tok = strtok(commandStringBuf, "=");
mfwic 5:09be5bbb5020 559 strcpy(commandString, tok);
mfwic 5:09be5bbb5020 560 tok = strtok(NULL, "=");
Slord2142 33:6c7364ea360f 561 commandData = atof(tok);
mfwic 5:09be5bbb5020 562 }
mfwic 5:09be5bbb5020 563 else{
mfwic 5:09be5bbb5020 564 strcpy(commandString, commandStringBuf);
mfwic 5:09be5bbb5020 565 }
mfwic 0:44a3005d4f20 566
mfwic 0:44a3005d4f20 567 // Convert the command string to all uppercase characters
mfwic 0:44a3005d4f20 568 for (i = 0; i < strlen(commandString); i++)
mfwic 0:44a3005d4f20 569 {
mfwic 0:44a3005d4f20 570 commandString[i] = toupper(commandString[i]);
mfwic 0:44a3005d4f20 571 }
mfwic 0:44a3005d4f20 572
mfwic 0:44a3005d4f20 573 // Replace the character we clobbered in rxbuf
mfwic 0:44a3005d4f20 574 rxbuf[endofc] = store;
mfwic 0:44a3005d4f20 575
mfwic 0:44a3005d4f20 576 // Update bufloc to the end of the command string
mfwic 0:44a3005d4f20 577 bufloc = endofc;
mfwic 11:01dcfb29fbc4 578 }
mfwic 0:44a3005d4f20 579
mfwic 0:44a3005d4f20 580 /************************************************************
mfwic 0:44a3005d4f20 581 * Routine: doCommand
mfwic 0:44a3005d4f20 582 * Input: none
mfwic 0:44a3005d4f20 583 * Returns: none
mfwic 0:44a3005d4f20 584 * Description:
mfwic 0:44a3005d4f20 585 * This is the start of the command string.
mfwic 0:44a3005d4f20 586 **************************************************************/
mfwic 0:44a3005d4f20 587 void doCommand(void)
mfwic 0:44a3005d4f20 588 {
mfwic 6:39442d493098 589 int ival;
mfwic 0:44a3005d4f20 590 unsigned int boardEnables;
mfwic 0:44a3005d4f20 591
mfwic 0:44a3005d4f20 592 char commandString[80] = { 0 };
mfwic 0:44a3005d4f20 593
mfwic 0:44a3005d4f20 594 bufloc = 0;
mfwic 0:44a3005d4f20 595 commandError = 0;
mfwic 0:44a3005d4f20 596
mfwic 0:44a3005d4f20 597 parseCommand(GET, commandString);
mfwic 0:44a3005d4f20 598
mfwic 1:9f8583ba2431 599 if (!strcmp(commandString, "MENU"))
mfwic 1:9f8583ba2431 600 {
mfwic 8:d3d7dca419b3 601 menuRedraw(NO_PROMPT);
mfwic 1:9f8583ba2431 602 }
mfwic 3:d8948c5b2951 603 else if (!strcmp(commandString, "HELP"))
mfwic 3:d8948c5b2951 604 {
mfwic 8:d3d7dca419b3 605 menuRedraw(NO_PROMPT);
mfwic 3:d8948c5b2951 606 }
mfwic 25:8bcc8bea0e31 607 else if (!strcmp(commandString, "MAXB"))
mfwic 25:8bcc8bea0e31 608 // MAXB is used to get/set the max_boards value.
mfwic 25:8bcc8bea0e31 609 // The integer value of max_boards is used to select the appropriate lookup table.
mfwic 25:8bcc8bea0e31 610 {
mfwic 25:8bcc8bea0e31 611 if (readback)
mfwic 25:8bcc8bea0e31 612 {
mfwic 25:8bcc8bea0e31 613 sprintf(strbuf, " %d", max_boards);
mfwic 25:8bcc8bea0e31 614 sendSerial(strbuf);
mfwic 25:8bcc8bea0e31 615 }
mfwic 25:8bcc8bea0e31 616 else if (running == 1)
mfwic 25:8bcc8bea0e31 617 {
mfwic 25:8bcc8bea0e31 618 sprintf(strbuf, " Parameters may not be updated while running!");
mfwic 25:8bcc8bea0e31 619 sendSerial(strbuf);
mfwic 25:8bcc8bea0e31 620 }
mfwic 25:8bcc8bea0e31 621 else
mfwic 25:8bcc8bea0e31 622 {
mfwic 25:8bcc8bea0e31 623 max_boards = commandData;
mfwic 25:8bcc8bea0e31 624 }
mfwic 25:8bcc8bea0e31 625 }
mfwic 1:9f8583ba2431 626 else if (!strcmp(commandString, "BRDS"))
mfwic 1:9f8583ba2431 627 // BRDS is used to get/set the wr_out value.
mfwic 5:09be5bbb5020 628 // The integer value of boardsActive is used to change wr_out via setBoardEnables(boardsActive).
mfwic 1:9f8583ba2431 629 // Slots 12 to 0 are activated with the wr_out signals
mfwic 1:9f8583ba2431 630 // wr_out[13] = slots[12:0]
mfwic 0:44a3005d4f20 631 {
mfwic 0:44a3005d4f20 632 if (readback)
mfwic 0:44a3005d4f20 633 {
mfwic 5:09be5bbb5020 634 sprintf(strbuf, " %d", boardsActive);
mfwic 1:9f8583ba2431 635 sendSerial(strbuf);
mfwic 0:44a3005d4f20 636 }
mfwic 12:fd1fd1857628 637 else if (running == 1)
mfwic 12:fd1fd1857628 638 {
mfwic 12:fd1fd1857628 639 sprintf(strbuf, " Parameters may not be updated while running!");
mfwic 12:fd1fd1857628 640 sendSerial(strbuf);
mfwic 12:fd1fd1857628 641 }
mfwic 0:44a3005d4f20 642 else
mfwic 0:44a3005d4f20 643 {
mfwic 12:fd1fd1857628 644 boardsActive = commandData;
mfwic 12:fd1fd1857628 645 if(checkRange(boardsActive, 0, 8191) == 1){
mfwic 12:fd1fd1857628 646 wr_out_code = setBoardEnables(boardsActive);
mfwic 12:fd1fd1857628 647 testing = TRUE;
mfwic 1:9f8583ba2431 648 }else{
mfwic 5:09be5bbb5020 649 showRangeError(1, boardsActive, 0.0);
mfwic 1:9f8583ba2431 650 }
mfwic 1:9f8583ba2431 651 }
mfwic 1:9f8583ba2431 652 }
mfwic 1:9f8583ba2431 653 else if (!strcmp(commandString, "MULT"))
mfwic 1:9f8583ba2431 654 // MULT is used to get/set the en_out value.
mfwic 5:09be5bbb5020 655 // The integer value of boardMults is used to change en_out via setBoardWeights(boardMults).
mfwic 1:9f8583ba2431 656 // en_out are binary weighted signals that activate groups of DC-DC converters on the slot cards.
mfwic 1:9f8583ba2431 657 // en_out[6] = {en32, en16, en8, en4, en2, en1}
mfwic 1:9f8583ba2431 658 {
mfwic 1:9f8583ba2431 659 if (readback)
mfwic 1:9f8583ba2431 660 {
mfwic 5:09be5bbb5020 661 sprintf(strbuf, " %d", boardMults);
mfwic 1:9f8583ba2431 662 sendSerial(strbuf);
Slord2142 33:6c7364ea360f 663
mfwic 1:9f8583ba2431 664 }
mfwic 12:fd1fd1857628 665 else if (running == 1)
mfwic 12:fd1fd1857628 666 {
mfwic 12:fd1fd1857628 667 sprintf(strbuf, " Parameters may not be updated while running!");
mfwic 12:fd1fd1857628 668 sendSerial(strbuf);
mfwic 12:fd1fd1857628 669 }
mfwic 1:9f8583ba2431 670 else
mfwic 1:9f8583ba2431 671 {
mfwic 12:fd1fd1857628 672 boardMults = commandData;
mfwic 5:09be5bbb5020 673 if(checkRange(boardMults, 0, 63) == 1){
mfwic 6:39442d493098 674 en_out_code = setBoardWeights(boardMults);
mfwic 12:fd1fd1857628 675 testing = TRUE;
mfwic 1:9f8583ba2431 676 }else{
mfwic 5:09be5bbb5020 677 showRangeError(1, boardMults, 0.0);
mfwic 1:9f8583ba2431 678 }
mfwic 0:44a3005d4f20 679 }
Slord2142 33:6c7364ea360f 680 }/*
Slord2142 33:6c7364ea360f 681 else if (!strcmp(commandString, "PERM"))
Slord2142 33:6c7364ea360f 682 {
Slord2142 33:6c7364ea360f 683 if (readback)
Slord2142 33:6c7364ea360f 684 {
Slord2142 33:6c7364ea360f 685 reader.open(sector_index);
Slord2142 33:6c7364ea360f 686 //printf("data %d bytes at %p :\r\n", reader.get_data_size(), reader.get_physical_data_addr());
Slord2142 33:6c7364ea360f 687 //printf("%.*s\r\n", reader.get_data_size(), reader.get_physical_data_addr());
Slord2142 33:6c7364ea360f 688 storo = reader.get_physical_data_addr();
Slord2142 33:6c7364ea360f 689 reader.close();
Slord2142 33:6c7364ea360f 690 printf("%s\r\n", storo);
Slord2142 33:6c7364ea360f 691 sprintf(storage, "%s", storo);
Slord2142 33:6c7364ea360f 692 int storage_size = strlen(storage);
Slord2142 33:6c7364ea360f 693 char delim[] = ":";
Slord2142 33:6c7364ea360f 694 char *ptr = strtok(storage, delim);
Slord2142 33:6c7364ea360f 695 if (ptr != NULL)
Slord2142 33:6c7364ea360f 696 {
Slord2142 33:6c7364ea360f 697 CURRENT_48_DIV_FACTOR0 = atoi(ptr);
Slord2142 33:6c7364ea360f 698 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 699 if (ptr != NULL)
Slord2142 33:6c7364ea360f 700 {
Slord2142 33:6c7364ea360f 701 CURRENT_48_DIV_FACTOR1 = atoi(ptr);
Slord2142 33:6c7364ea360f 702 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 703 if (ptr != NULL)
Slord2142 33:6c7364ea360f 704 {
Slord2142 33:6c7364ea360f 705 CURRENT_48_DIV_FACTOR2 = atoi(ptr);
Slord2142 33:6c7364ea360f 706 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 707 if (ptr != NULL)
Slord2142 33:6c7364ea360f 708 {
Slord2142 33:6c7364ea360f 709 CURRENT_48_DIV_FACTOR3 = atoi(ptr);
Slord2142 33:6c7364ea360f 710 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 711 if (ptr != NULL)
Slord2142 33:6c7364ea360f 712 {
Slord2142 33:6c7364ea360f 713 CURRENT_48_DIV_FACTOR4 = atoi(ptr);
Slord2142 33:6c7364ea360f 714 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 715 if (ptr != NULL)
Slord2142 33:6c7364ea360f 716 {
Slord2142 33:6c7364ea360f 717 CURRENT_48_DIV_FACTOR5 = atoi(ptr);
Slord2142 33:6c7364ea360f 718 printf("%d\r\n", CURRENT_48_DIV_FACTOR0);
Slord2142 33:6c7364ea360f 719 printf("%d\r\n", CURRENT_48_DIV_FACTOR1);
Slord2142 33:6c7364ea360f 720 printf("%d\r\n", CURRENT_48_DIV_FACTOR2);
Slord2142 33:6c7364ea360f 721 printf("%d\r\n", CURRENT_48_DIV_FACTOR3);
Slord2142 33:6c7364ea360f 722 printf("%d\r\n", CURRENT_48_DIV_FACTOR4);
Slord2142 33:6c7364ea360f 723 printf("%d\r\n", CURRENT_48_DIV_FACTOR5);
Slord2142 33:6c7364ea360f 724 } else {
Slord2142 33:6c7364ea360f 725 printf("Insufficient variables found.");
Slord2142 33:6c7364ea360f 726 }
Slord2142 33:6c7364ea360f 727 } else {
Slord2142 33:6c7364ea360f 728 printf("Infussicient variables found.");
Slord2142 33:6c7364ea360f 729 }
Slord2142 33:6c7364ea360f 730 } else {
Slord2142 33:6c7364ea360f 731 printf("Insufficient variables found.");
Slord2142 33:6c7364ea360f 732 }
Slord2142 33:6c7364ea360f 733 } else {
Slord2142 33:6c7364ea360f 734 printf("Insufficient variables found.");
Slord2142 33:6c7364ea360f 735 }
Slord2142 33:6c7364ea360f 736 } else {
Slord2142 33:6c7364ea360f 737 printf("Insufficient variables found.");
Slord2142 33:6c7364ea360f 738 }
Slord2142 33:6c7364ea360f 739 } else {
Slord2142 33:6c7364ea360f 740 printf("Infufficient variables found.");
Slord2142 33:6c7364ea360f 741 }
Slord2142 33:6c7364ea360f 742 sendSerial(strbuf);
Slord2142 33:6c7364ea360f 743
Slord2142 33:6c7364ea360f 744 }
Slord2142 33:6c7364ea360f 745 else if (running == 1)
Slord2142 33:6c7364ea360f 746 {
Slord2142 33:6c7364ea360f 747 sprintf(strbuf, " Parameters may not be updated while running!");
Slord2142 33:6c7364ea360f 748 sendSerial(strbuf);
Slord2142 33:6c7364ea360f 749 }
Slord2142 33:6c7364ea360f 750 else
Slord2142 33:6c7364ea360f 751 {
Slord2142 33:6c7364ea360f 752 if(checkRange(boardMults, 0, 63) == 1){
Slord2142 33:6c7364ea360f 753 writer.open(sector_index) ;
Slord2142 33:6c7364ea360f 754 writer.write_data((uint8_t*) storoBuild, sizeof storoBuild);
Slord2142 33:6c7364ea360f 755 writer.close();
Slord2142 33:6c7364ea360f 756 testing = TRUE;
Slord2142 33:6c7364ea360f 757 }else{
Slord2142 33:6c7364ea360f 758 showRangeError(1, boardMults, 0.0);
Slord2142 33:6c7364ea360f 759 }
Slord2142 33:6c7364ea360f 760 }
mfwic 0:44a3005d4f20 761 }
Slord2142 33:6c7364ea360f 762 else if (!strcmp(commandString, "PREP"))
Slord2142 33:6c7364ea360f 763 {
Slord2142 33:6c7364ea360f 764 if (readback)
Slord2142 33:6c7364ea360f 765 {
Slord2142 33:6c7364ea360f 766 printf("%s\r\n", storo);
Slord2142 33:6c7364ea360f 767 sendSerial(strbuf);
Slord2142 33:6c7364ea360f 768 }
Slord2142 33:6c7364ea360f 769 else
Slord2142 33:6c7364ea360f 770 {
Slord2142 33:6c7364ea360f 771 if (commandData == 0)
Slord2142 33:6c7364ea360f 772 {
Slord2142 33:6c7364ea360f 773 memset(storoBuild, 0, sizeof storoBuild);
Slord2142 33:6c7364ea360f 774 }
Slord2142 33:6c7364ea360f 775 else
Slord2142 33:6c7364ea360f 776 {
Slord2142 33:6c7364ea360f 777 sprintf(storoFrag, "%d", commandData);
Slord2142 33:6c7364ea360f 778 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 779 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 780 if(checkRange(boardMults, 0, 63) == 1){
Slord2142 33:6c7364ea360f 781 printf("%s\r\n", storoBuild);
Slord2142 33:6c7364ea360f 782 testing = TRUE;
Slord2142 33:6c7364ea360f 783 }else{
Slord2142 33:6c7364ea360f 784 showRangeError(1, boardMults, 0.0);
Slord2142 33:6c7364ea360f 785 }
Slord2142 33:6c7364ea360f 786 }
Slord2142 33:6c7364ea360f 787 }
Slord2142 33:6c7364ea360f 788 }*/
Slord2142 33:6c7364ea360f 789 else if (!strcmp(commandString, "SECT"))
Slord2142 33:6c7364ea360f 790 {
Slord2142 33:6c7364ea360f 791 if (commandData == 48)
Slord2142 33:6c7364ea360f 792 {
Slord2142 33:6c7364ea360f 793 section = 48;
Slord2142 33:6c7364ea360f 794 }
Slord2142 33:6c7364ea360f 795 else if (commandData == 24)
Slord2142 33:6c7364ea360f 796 {
Slord2142 33:6c7364ea360f 797 section = 24;
Slord2142 33:6c7364ea360f 798 fort = 0;
Slord2142 33:6c7364ea360f 799 }
Slord2142 33:6c7364ea360f 800 else if (commandData == 12)
Slord2142 33:6c7364ea360f 801 {
Slord2142 33:6c7364ea360f 802 section = 12;
Slord2142 33:6c7364ea360f 803 }
Slord2142 33:6c7364ea360f 804 else {
Slord2142 33:6c7364ea360f 805 printf("Input not accepted.");
Slord2142 33:6c7364ea360f 806 }
Slord2142 33:6c7364ea360f 807 }/*
Slord2142 33:6c7364ea360f 808 else if (!strcmp(commandString, "FORT"))
Slord2142 33:6c7364ea360f 809 {
Slord2142 33:6c7364ea360f 810 if (readback)
Slord2142 33:6c7364ea360f 811 {
Slord2142 33:6c7364ea360f 812 if (fort == 0)
Slord2142 33:6c7364ea360f 813 {
Slord2142 33:6c7364ea360f 814 printf("Currently accessing: Div Factors \r\n");
Slord2142 33:6c7364ea360f 815 }
Slord2142 33:6c7364ea360f 816 else if (fort == 1)
Slord2142 33:6c7364ea360f 817 {
Slord2142 33:6c7364ea360f 818 printf("Currently accessing: Div Thresholds \r\n");
Slord2142 33:6c7364ea360f 819 } else {
Slord2142 33:6c7364ea360f 820 printf("Currently accessing: Nothing \r\n");
Slord2142 33:6c7364ea360f 821 }
Slord2142 33:6c7364ea360f 822 }else if (section != 24){
Slord2142 33:6c7364ea360f 823 if (commandData == 0)
Slord2142 33:6c7364ea360f 824 {
Slord2142 33:6c7364ea360f 825 fort = 0;
Slord2142 33:6c7364ea360f 826 printf("Now accessing: Div Factors \r\n");
Slord2142 33:6c7364ea360f 827 }
Slord2142 33:6c7364ea360f 828 else if (commandData == 1)
Slord2142 33:6c7364ea360f 829 {
Slord2142 33:6c7364ea360f 830 fort = 1;
Slord2142 33:6c7364ea360f 831 printf("Now accessing: Div Thresholds \r\n");
Slord2142 33:6c7364ea360f 832 }
Slord2142 33:6c7364ea360f 833 }
Slord2142 33:6c7364ea360f 834 }*/
Slord2142 33:6c7364ea360f 835 else if (!strcmp(commandString, "DIAL"))
Slord2142 33:6c7364ea360f 836 {
Slord2142 33:6c7364ea360f 837 if (Vloc == 0)
Slord2142 33:6c7364ea360f 838 {
Slord2142 33:6c7364ea360f 839 if (section == 48)
Slord2142 33:6c7364ea360f 840 {
Slord2142 33:6c7364ea360f 841 printf("Begin Voltage 48 calibration? (Enter Dial=1 to continue)");
Slord2142 33:6c7364ea360f 842 Vloc = -1;
Slord2142 33:6c7364ea360f 843 }
Slord2142 33:6c7364ea360f 844 else if (section == 24)
Slord2142 33:6c7364ea360f 845 {
Slord2142 33:6c7364ea360f 846 printf("Begin Voltage 24 calibration? (Enter Dial=1 to continue)");
Slord2142 33:6c7364ea360f 847 Vloc = 7;
Slord2142 33:6c7364ea360f 848 }
Slord2142 33:6c7364ea360f 849 else if (section == 12)
Slord2142 33:6c7364ea360f 850 {
Slord2142 33:6c7364ea360f 851 printf("Begin Voltage 12 calibration? (Enter Dial=1 to continue)");
Slord2142 33:6c7364ea360f 852 Vloc = 1;
Slord2142 33:6c7364ea360f 853 }
Slord2142 33:6c7364ea360f 854 }
Slord2142 33:6c7364ea360f 855 else if (Vloc == 1)
Slord2142 33:6c7364ea360f 856 {
Slord2142 33:6c7364ea360f 857 if (commandData == 1)
Slord2142 33:6c7364ea360f 858 {
Slord2142 33:6c7364ea360f 859 printf("Enter actual output at 12V load. (ex. Dial=1.52)");
Slord2142 33:6c7364ea360f 860 Vloc = 2;
Slord2142 33:6c7364ea360f 861 } else{
Slord2142 33:6c7364ea360f 862 printf("Calibration cancelled.");
Slord2142 33:6c7364ea360f 863 Vloc = 0;
Slord2142 33:6c7364ea360f 864 }
Slord2142 33:6c7364ea360f 865 }
Slord2142 33:6c7364ea360f 866 else if (Vloc == 2)
Slord2142 33:6c7364ea360f 867 {
Slord2142 33:6c7364ea360f 868 VOLTAGE_CAL_1 = commandData;
Slord2142 33:6c7364ea360f 869 printf("Enter actual output at 10V load. (ex. Dial=1.08)");
Slord2142 33:6c7364ea360f 870 Vloc = 3;
Slord2142 33:6c7364ea360f 871 }
Slord2142 33:6c7364ea360f 872 else if (Vloc == 3)
Slord2142 33:6c7364ea360f 873 {
Slord2142 33:6c7364ea360f 874 VOLTAGE_CAL_2 = commandData;
Slord2142 33:6c7364ea360f 875 printf("Enter actual output at 8V load. (ex. Dial=0.58)");
Slord2142 33:6c7364ea360f 876 Vloc = 4;
Slord2142 33:6c7364ea360f 877 }
Slord2142 33:6c7364ea360f 878 else if (Vloc == 4)
Slord2142 33:6c7364ea360f 879 {
Slord2142 33:6c7364ea360f 880 VOLTAGE_CAL_3 = commandData;
Slord2142 33:6c7364ea360f 881 Vloc = 0;
Slord2142 33:6c7364ea360f 882 VOLTAGE_12_ACTUAL_VALUE = (VOLTAGE_CAL_1-VOLTAGE_CAL_3)*0.4125;
Slord2142 33:6c7364ea360f 883 printf("\r\n%4.2f, %4.2f", VOLTAGE_CAL_1, VOLTAGE_CAL_3);
Slord2142 33:6c7364ea360f 884 VOLTAGE_12_OFFSET = VOLTAGE_CAL_1-(VOLTAGE_12_ACTUAL_VALUE*12/1.65)+((VOLTAGE_CAL_2-(VOLTAGE_12_ACTUAL_VALUE*10/1.65))*0.5);
Slord2142 33:6c7364ea360f 885 printf("\r\n12V calibration completed.\r\n");
Slord2142 33:6c7364ea360f 886 printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
Slord2142 33:6c7364ea360f 887 }
Slord2142 33:6c7364ea360f 888 else if (Vloc == -1)
Slord2142 33:6c7364ea360f 889 {
Slord2142 33:6c7364ea360f 890 if (commandData == 1)
Slord2142 33:6c7364ea360f 891 {
Slord2142 33:6c7364ea360f 892 printf("\r\n Enter actual output at 48V load. (ex. Dial=1.52) \r\n");
Slord2142 33:6c7364ea360f 893 Vloc = -2;
Slord2142 33:6c7364ea360f 894 } else{
Slord2142 33:6c7364ea360f 895 printf("Calibration cancelled.");
Slord2142 33:6c7364ea360f 896 Vloc = 0;
Slord2142 33:6c7364ea360f 897 }
Slord2142 33:6c7364ea360f 898 }
Slord2142 33:6c7364ea360f 899 else if (Vloc == -2)
Slord2142 33:6c7364ea360f 900 {
Slord2142 33:6c7364ea360f 901 VOLTAGE_CAL_1 = commandData;
Slord2142 33:6c7364ea360f 902 printf("\r\n Enter actual output at 44V load. (ex. Dial=1.08) \r\n");
Slord2142 33:6c7364ea360f 903 Vloc = -3;
Slord2142 33:6c7364ea360f 904 }
Slord2142 33:6c7364ea360f 905 else if (Vloc == -3)
Slord2142 33:6c7364ea360f 906 {
Slord2142 33:6c7364ea360f 907 VOLTAGE_CAL_2 = commandData;
Slord2142 33:6c7364ea360f 908 printf("\r\n Enter actual output at 40V load. (ex. Dial=0.58) \r\n");
Slord2142 33:6c7364ea360f 909 Vloc = -4;
Slord2142 33:6c7364ea360f 910 }
Slord2142 33:6c7364ea360f 911 else if (Vloc == -4)
Slord2142 33:6c7364ea360f 912 {
Slord2142 33:6c7364ea360f 913 VOLTAGE_CAL_3 = commandData;
Slord2142 33:6c7364ea360f 914 Vloc = 0;
Slord2142 33:6c7364ea360f 915 VOLTAGE_48_ACTUAL_VALUE = (VOLTAGE_CAL_1-VOLTAGE_CAL_3)*0.20625;
Slord2142 33:6c7364ea360f 916 printf("\r\n%4.2f, %4.2f", VOLTAGE_CAL_1, VOLTAGE_CAL_3);
Slord2142 33:6c7364ea360f 917 VOLTAGE_48_OFFSET = VOLTAGE_CAL_1-(VOLTAGE_12_ACTUAL_VALUE*48/1.65)+((VOLTAGE_CAL_2-(VOLTAGE_12_ACTUAL_VALUE*44/1.65))*0.5);
Slord2142 33:6c7364ea360f 918 printf("\r\n48V calibration completed.\r\n");
Slord2142 33:6c7364ea360f 919 printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
Slord2142 33:6c7364ea360f 920 }
Slord2142 33:6c7364ea360f 921 else if (Vloc == 7)
Slord2142 33:6c7364ea360f 922 {
Slord2142 33:6c7364ea360f 923 if (commandData == 1)
Slord2142 33:6c7364ea360f 924 {
Slord2142 33:6c7364ea360f 925 printf("\r\n Enter actual output at 24V load. (ex. Dial=1.52) \r\n");
Slord2142 33:6c7364ea360f 926 Vloc = 13;
Slord2142 33:6c7364ea360f 927 } else{
Slord2142 33:6c7364ea360f 928 printf("Calibration cancelled.");
Slord2142 33:6c7364ea360f 929 Vloc = 0;
Slord2142 33:6c7364ea360f 930 }
Slord2142 33:6c7364ea360f 931 }
Slord2142 33:6c7364ea360f 932 else if (Vloc == 13)
Slord2142 33:6c7364ea360f 933 {
Slord2142 33:6c7364ea360f 934 VOLTAGE_CAL_1 = commandData;
Slord2142 33:6c7364ea360f 935 printf("\r\n Enter actual output at 21V load. (ex. Dial=1.08) \r\n");
Slord2142 33:6c7364ea360f 936 Vloc = 21;
Slord2142 33:6c7364ea360f 937 }
Slord2142 33:6c7364ea360f 938 else if (Vloc == 21)
Slord2142 33:6c7364ea360f 939 {
Slord2142 33:6c7364ea360f 940 VOLTAGE_CAL_2 = commandData;
Slord2142 33:6c7364ea360f 941 printf("\r\n Enter actual output at 18V load. (ex. Dial=0.58) \r\n");
Slord2142 33:6c7364ea360f 942 Vloc = 42;
Slord2142 33:6c7364ea360f 943 }
Slord2142 33:6c7364ea360f 944 else if (Vloc == 42)
Slord2142 33:6c7364ea360f 945 {
Slord2142 33:6c7364ea360f 946 VOLTAGE_CAL_3 = commandData;
Slord2142 33:6c7364ea360f 947 Vloc = 0;
Slord2142 33:6c7364ea360f 948 VOLTAGE_24_ACTUAL_VALUE = (VOLTAGE_CAL_1-VOLTAGE_CAL_3)*0.275;
Slord2142 33:6c7364ea360f 949 printf("\r\n%4.2f, %4.2f", VOLTAGE_CAL_1, VOLTAGE_CAL_3);
Slord2142 33:6c7364ea360f 950 VOLTAGE_24_OFFSET = VOLTAGE_CAL_1-(VOLTAGE_12_ACTUAL_VALUE*24/1.65)+((VOLTAGE_CAL_2-(VOLTAGE_12_ACTUAL_VALUE*21/1.65))*0.5);
Slord2142 33:6c7364ea360f 951 printf("\r\n24V calibration completed.\r\n");
Slord2142 33:6c7364ea360f 952 printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
Slord2142 33:6c7364ea360f 953 }
Slord2142 33:6c7364ea360f 954 }
Slord2142 33:6c7364ea360f 955 else if (!strcmp(commandString, "SCL"))
Slord2142 33:6c7364ea360f 956 {
Slord2142 33:6c7364ea360f 957 if (section == 48)
Slord2142 33:6c7364ea360f 958 {
Slord2142 33:6c7364ea360f 959 printf("Not yet implimented.");
Slord2142 33:6c7364ea360f 960 }
Slord2142 33:6c7364ea360f 961 else if (section == 24)
Slord2142 33:6c7364ea360f 962 {
Slord2142 33:6c7364ea360f 963 printf("Not yet implimented.");
Slord2142 33:6c7364ea360f 964 }
Slord2142 33:6c7364ea360f 965 else if (section == 12)
Slord2142 33:6c7364ea360f 966 {
Slord2142 33:6c7364ea360f 967 if (Aloc == 0)
Slord2142 33:6c7364ea360f 968 {
Slord2142 33:6c7364ea360f 969 printf("Begin Voltage 12 current calibration? (Enter Scl=1 to continue)");
Slord2142 33:6c7364ea360f 970 Aloc = -1;
Slord2142 33:6c7364ea360f 971 }
Slord2142 33:6c7364ea360f 972 else if (Aloc == -1)
Slord2142 33:6c7364ea360f 973 {
Slord2142 33:6c7364ea360f 974 if (commandData == 1)
Slord2142 33:6c7364ea360f 975 {
Slord2142 33:6c7364ea360f 976 printf("Set current to smallest reference point(1/6). Enter actual current amount. (Ex. Scl=1.25)");
Slord2142 33:6c7364ea360f 977 Aloc = -2;
Slord2142 33:6c7364ea360f 978 } else{
Slord2142 33:6c7364ea360f 979 printf("Calibration cancelled.");
Slord2142 33:6c7364ea360f 980 Aloc = 0;
Slord2142 33:6c7364ea360f 981 }
Slord2142 33:6c7364ea360f 982 }
Slord2142 33:6c7364ea360f 983 else if (Aloc == -2)
Slord2142 33:6c7364ea360f 984 {
Slord2142 33:6c7364ea360f 985 CURRENT_IN_1 = commandData;
Slord2142 33:6c7364ea360f 986 adcValues adcVals = getADCresults();
Slord2142 33:6c7364ea360f 987 CURRENT_REF_1 = adcVals.i12;
Slord2142 33:6c7364ea360f 988 printf("Increase input current. Enter new actual input current(2/6).");
Slord2142 33:6c7364ea360f 989 Aloc = -3;
Slord2142 33:6c7364ea360f 990 }
Slord2142 33:6c7364ea360f 991 else if (Aloc == -3)
Slord2142 33:6c7364ea360f 992 {
Slord2142 33:6c7364ea360f 993 CURRENT_IN_2 = commandData;
Slord2142 33:6c7364ea360f 994 adcValues adcVals = getADCresults();
Slord2142 33:6c7364ea360f 995 CURRENT_REF_2 = adcVals.i12;
Slord2142 33:6c7364ea360f 996 printf("Increase input current. Enter new actual input current(3/6).");
Slord2142 33:6c7364ea360f 997 Aloc = -4;
Slord2142 33:6c7364ea360f 998 }
Slord2142 33:6c7364ea360f 999 else if (Aloc == -4)
Slord2142 33:6c7364ea360f 1000 {
Slord2142 33:6c7364ea360f 1001 CURRENT_IN_3 = commandData;
Slord2142 33:6c7364ea360f 1002 adcValues adcVals = getADCresults();
Slord2142 33:6c7364ea360f 1003 CURRENT_REF_3 = adcVals.i12;
Slord2142 33:6c7364ea360f 1004 printf("Increase input current. Enter new actual input current(4/6).");
Slord2142 33:6c7364ea360f 1005 Aloc = -5;
Slord2142 33:6c7364ea360f 1006 }
Slord2142 33:6c7364ea360f 1007 else if (Aloc == -5)
Slord2142 33:6c7364ea360f 1008 {
Slord2142 33:6c7364ea360f 1009 CURRENT_IN_4 = commandData;
Slord2142 33:6c7364ea360f 1010 adcValues adcVals = getADCresults();
Slord2142 33:6c7364ea360f 1011 CURRENT_REF_4 = adcVals.i12;
Slord2142 33:6c7364ea360f 1012 printf("Increase input current. Enter new actual input current(5/6).");
Slord2142 33:6c7364ea360f 1013 Aloc = -6;
Slord2142 33:6c7364ea360f 1014 }
Slord2142 33:6c7364ea360f 1015 else if (Aloc == -6)
Slord2142 33:6c7364ea360f 1016 {
Slord2142 33:6c7364ea360f 1017 CURRENT_IN_5 = commandData;
Slord2142 33:6c7364ea360f 1018 adcValues adcVals = getADCresults();
Slord2142 33:6c7364ea360f 1019 CURRENT_REF_5 = adcVals.i12;
Slord2142 33:6c7364ea360f 1020 printf("Increase input current. Enter new actual input current(6/6).");
Slord2142 33:6c7364ea360f 1021 Aloc = -7;
Slord2142 33:6c7364ea360f 1022 }
Slord2142 33:6c7364ea360f 1023 else if (Aloc == -7)
Slord2142 33:6c7364ea360f 1024 {
Slord2142 33:6c7364ea360f 1025 CURRENT_IN_6 = commandData;
Slord2142 33:6c7364ea360f 1026 adcValues adcVals = getADCresults();
Slord2142 33:6c7364ea360f 1027 CURRENT_REF_6 = adcVals.i12;
Slord2142 33:6c7364ea360f 1028 Aloc = 0;
Slord2142 33:6c7364ea360f 1029 if ((CURRENT_REF_6 - CURRENT_12_OFFSET < 0 && CURRENT_REF_1 - CURRENT_12_OFFSET < 0 && CURRENT_REF_6 > CURRENT_REF_1)
Slord2142 33:6c7364ea360f 1030 || (CURRENT_REF_6 - CURRENT_12_OFFSET > 0 && CURRENT_REF_1 - CURRENT_12_OFFSET > 0 && CURRENT_REF_6 < CURRENT_REF_1))
Slord2142 33:6c7364ea360f 1031 {
Slord2142 33:6c7364ea360f 1032 CURRENT_12_DIV_THRESH5 = CURRENT_REF_1-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1033 CURRENT_12_DIV_THRESH4 = CURRENT_REF_2-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1034 CURRENT_12_DIV_THRESH3 = CURRENT_REF_3-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1035 CURRENT_12_DIV_THRESH2 = CURRENT_REF_4-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1036 CURRENT_12_DIV_THRESH1 = CURRENT_REF_5-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1037 CURRENT_12_DIV_FACTOR5 = (CURRENT_REF_1-CURRENT_12_OFFSET)/CURRENT_IN_1;
Slord2142 33:6c7364ea360f 1038 CURRENT_12_CORRECTION4 = ((CURRENT_REF_1-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR5)-CURRENT_IN_1;
Slord2142 33:6c7364ea360f 1039 CURRENT_12_DIV_FACTOR4 = (CURRENT_REF_2-CURRENT_REF_1)/(CURRENT_IN_2-CURRENT_IN_1);
Slord2142 33:6c7364ea360f 1040 CURRENT_12_CORRECTION4 = ((CURRENT_REF_2-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR4)-CURRENT_IN_2;
Slord2142 33:6c7364ea360f 1041 CURRENT_12_DIV_FACTOR3 = (CURRENT_REF_3-CURRENT_REF_2)/(CURRENT_IN_3-CURRENT_IN_2);
Slord2142 33:6c7364ea360f 1042 CURRENT_12_CORRECTION3 = ((CURRENT_REF_3-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR3)-CURRENT_IN_3;
Slord2142 33:6c7364ea360f 1043 CURRENT_12_DIV_FACTOR2 = (CURRENT_REF_4-CURRENT_REF_3)/(CURRENT_IN_4-CURRENT_IN_3);
Slord2142 33:6c7364ea360f 1044 CURRENT_12_CORRECTION2 = ((CURRENT_REF_4-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR2)-CURRENT_IN_4;
Slord2142 33:6c7364ea360f 1045 CURRENT_12_DIV_FACTOR1 = (CURRENT_REF_5-CURRENT_REF_4)/(CURRENT_IN_5-CURRENT_IN_4);
Slord2142 33:6c7364ea360f 1046 CURRENT_12_CORRECTION1 = ((CURRENT_REF_5-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR1)-CURRENT_IN_5;
Slord2142 33:6c7364ea360f 1047 CURRENT_12_DIV_FACTOR0 = (CURRENT_REF_6-CURRENT_REF_5)/(CURRENT_IN_6-CURRENT_IN_5);
Slord2142 33:6c7364ea360f 1048 CURRENT_12_CORRECTION0 = ((CURRENT_REF_6-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR0)-CURRENT_IN_6;
Slord2142 33:6c7364ea360f 1049 }
Slord2142 33:6c7364ea360f 1050 else if ((CURRENT_REF_6 - CURRENT_12_OFFSET < 0 && CURRENT_REF_1 - CURRENT_12_OFFSET < 0 && CURRENT_REF_6 < CURRENT_REF_1)
Slord2142 33:6c7364ea360f 1051 || (CURRENT_REF_6 - CURRENT_12_OFFSET > 0 && CURRENT_REF_1 - CURRENT_12_OFFSET > 0 && CURRENT_REF_6 > CURRENT_REF_1))
Slord2142 33:6c7364ea360f 1052 {
Slord2142 33:6c7364ea360f 1053 CURRENT_12_DIV_THRESH5 = CURRENT_REF_5-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1054 CURRENT_12_DIV_THRESH4 = CURRENT_REF_4-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1055 CURRENT_12_DIV_THRESH3 = CURRENT_REF_3-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1056 CURRENT_12_DIV_THRESH2 = CURRENT_REF_2-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1057 CURRENT_12_DIV_THRESH1 = CURRENT_REF_1-CURRENT_12_OFFSET;
Slord2142 33:6c7364ea360f 1058 CURRENT_12_DIV_FACTOR0 = (CURRENT_REF_1-CURRENT_12_OFFSET)/CURRENT_IN_1;
Slord2142 33:6c7364ea360f 1059 CURRENT_12_CORRECTION0 = 0;
Slord2142 33:6c7364ea360f 1060 CURRENT_12_DIV_FACTOR1 = (CURRENT_REF_2-CURRENT_REF_1)/(CURRENT_IN_2-CURRENT_IN_1);
Slord2142 33:6c7364ea360f 1061 CURRENT_12_CORRECTION1 = ((CURRENT_REF_2-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR1)-CURRENT_IN_2;
Slord2142 33:6c7364ea360f 1062 CURRENT_12_DIV_FACTOR2 = (CURRENT_REF_3-CURRENT_REF_2)/(CURRENT_IN_3-CURRENT_IN_2);
Slord2142 33:6c7364ea360f 1063 CURRENT_12_CORRECTION2 = ((CURRENT_REF_3-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR2)-CURRENT_IN_3;
Slord2142 33:6c7364ea360f 1064 CURRENT_12_DIV_FACTOR3 = (CURRENT_REF_4-CURRENT_REF_3)/(CURRENT_IN_4-CURRENT_IN_3);
Slord2142 33:6c7364ea360f 1065 CURRENT_12_CORRECTION3 = ((CURRENT_REF_4-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR3)-CURRENT_IN_4;
Slord2142 33:6c7364ea360f 1066 CURRENT_12_DIV_FACTOR4 = (CURRENT_REF_5-CURRENT_REF_4)/(CURRENT_IN_5-CURRENT_IN_4);
Slord2142 33:6c7364ea360f 1067 CURRENT_12_CORRECTION4 = ((CURRENT_REF_5-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR4)-CURRENT_IN_5;
Slord2142 33:6c7364ea360f 1068 CURRENT_12_DIV_FACTOR5 = (CURRENT_REF_6-CURRENT_REF_5)/(CURRENT_IN_6-CURRENT_IN_5);
Slord2142 33:6c7364ea360f 1069 CURRENT_12_CORRECTION5 = ((CURRENT_REF_6-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR5)-CURRENT_IN_6;
Slord2142 33:6c7364ea360f 1070 }
Slord2142 33:6c7364ea360f 1071 printf("\r\n12V current calibration completed.\r\n");
Slord2142 33:6c7364ea360f 1072 //printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
Slord2142 33:6c7364ea360f 1073 }
Slord2142 33:6c7364ea360f 1074 }
Slord2142 33:6c7364ea360f 1075 }
Slord2142 33:6c7364ea360f 1076 else if (!strcmp(commandString, "RCRD"))
Slord2142 33:6c7364ea360f 1077 {
Slord2142 33:6c7364ea360f 1078 if(checkRange(boardMults, 0, 63) == 1){
Slord2142 33:6c7364ea360f 1079 sprintf(storoFrag, "%4.2f", VOLTAGE_48_ACTUAL_VALUE);
Slord2142 33:6c7364ea360f 1080 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1081 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1082 sprintf(storoFrag, "%4.2f", VOLTAGE_48_OFFSET);
Slord2142 33:6c7364ea360f 1083 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1084 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1085 sprintf(storoFrag, "%4.2f", VOLTAGE_24_ACTUAL_VALUE);
Slord2142 33:6c7364ea360f 1086 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1087 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1088 sprintf(storoFrag, "%4.2f", VOLTAGE_24_OFFSET);
Slord2142 33:6c7364ea360f 1089 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1090 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1091 sprintf(storoFrag, "%4.2f", VOLTAGE_12_ACTUAL_VALUE);
Slord2142 33:6c7364ea360f 1092 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1093 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1094 sprintf(storoFrag, "%4.2f", VOLTAGE_12_OFFSET);
Slord2142 33:6c7364ea360f 1095 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1096 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1097 sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH1);
Slord2142 33:6c7364ea360f 1098 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1099 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1100 sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH2);
Slord2142 33:6c7364ea360f 1101 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1102 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1103 sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH3);
Slord2142 33:6c7364ea360f 1104 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1105 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1106 sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH4);
Slord2142 33:6c7364ea360f 1107 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1108 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1109 sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH5);
Slord2142 33:6c7364ea360f 1110 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1111 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1112 sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR0);
Slord2142 33:6c7364ea360f 1113 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1114 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1115 sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION0);
Slord2142 33:6c7364ea360f 1116 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1117 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1118 sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR1);
Slord2142 33:6c7364ea360f 1119 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1120 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1121 sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION1);
Slord2142 33:6c7364ea360f 1122 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1123 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1124 sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR2);
Slord2142 33:6c7364ea360f 1125 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1126 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1127 sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION2);
Slord2142 33:6c7364ea360f 1128 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1129 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1130 sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR3);
Slord2142 33:6c7364ea360f 1131 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1132 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1133 sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION3);
Slord2142 33:6c7364ea360f 1134 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1135 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1136 sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR4);
Slord2142 33:6c7364ea360f 1137 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1138 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1139 sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION4);
Slord2142 33:6c7364ea360f 1140 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1141 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1142 sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR5);
Slord2142 33:6c7364ea360f 1143 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1144 strcat(storoBuild, storoSpace);
Slord2142 33:6c7364ea360f 1145 sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION5);
Slord2142 33:6c7364ea360f 1146 strcat(storoBuild, storoFrag);
Slord2142 33:6c7364ea360f 1147 strcat(storoBuild, storoSpace);
Slord2142 34:419242dc004d 1148 //SOFBlock::format(sector_index);
Slord2142 33:6c7364ea360f 1149 writer.open(sector_index) ;
Slord2142 33:6c7364ea360f 1150 writer.write_data((uint8_t*) storoBuild, sizeof storoBuild);
Slord2142 33:6c7364ea360f 1151 writer.close();
Slord2142 33:6c7364ea360f 1152 testing = TRUE;
Slord2142 33:6c7364ea360f 1153 }else{
Slord2142 33:6c7364ea360f 1154 showRangeError(1, boardMults, 0.0);
Slord2142 33:6c7364ea360f 1155 }
Slord2142 33:6c7364ea360f 1156 }
Slord2142 33:6c7364ea360f 1157 else if (!strcmp(commandString, "RTRV"))
Slord2142 33:6c7364ea360f 1158 {
Slord2142 33:6c7364ea360f 1159 reader.open(sector_index);
Slord2142 33:6c7364ea360f 1160 storo = reader.get_physical_data_addr();
Slord2142 33:6c7364ea360f 1161 reader.close();
Slord2142 33:6c7364ea360f 1162 sprintf(storage, "%s", storo);
Slord2142 33:6c7364ea360f 1163 int storage_size = strlen(storage);
Slord2142 33:6c7364ea360f 1164 char delim[] = ":";
Slord2142 33:6c7364ea360f 1165 char *ptr = strtok(storage, delim);
Slord2142 33:6c7364ea360f 1166 VOLTAGE_48_ACTUAL_VALUE = atof(ptr);
Slord2142 33:6c7364ea360f 1167 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1168 VOLTAGE_48_OFFSET = atof(ptr);
Slord2142 33:6c7364ea360f 1169 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1170 VOLTAGE_24_ACTUAL_VALUE = atof(ptr);
Slord2142 33:6c7364ea360f 1171 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1172 VOLTAGE_24_OFFSET = atof(ptr);
Slord2142 33:6c7364ea360f 1173 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1174 VOLTAGE_12_ACTUAL_VALUE = atof(ptr);
Slord2142 33:6c7364ea360f 1175 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1176 VOLTAGE_12_OFFSET = atof(ptr);
Slord2142 33:6c7364ea360f 1177 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1178 CURRENT_12_DIV_THRESH1 = atoi(ptr);
Slord2142 33:6c7364ea360f 1179 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1180 CURRENT_12_DIV_THRESH2 = atoi(ptr);
Slord2142 33:6c7364ea360f 1181 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1182 CURRENT_12_DIV_THRESH3 = atoi(ptr);
Slord2142 33:6c7364ea360f 1183 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1184 CURRENT_12_DIV_THRESH4 = atoi(ptr);
Slord2142 33:6c7364ea360f 1185 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1186 CURRENT_12_DIV_THRESH5 = atoi(ptr);
Slord2142 33:6c7364ea360f 1187 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1188 CURRENT_12_DIV_FACTOR0 = atoi(ptr);
Slord2142 33:6c7364ea360f 1189 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1190 CURRENT_12_CORRECTION0 = atof(ptr);
Slord2142 33:6c7364ea360f 1191 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1192 CURRENT_12_DIV_FACTOR1 = atoi(ptr);
Slord2142 33:6c7364ea360f 1193 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1194 CURRENT_12_CORRECTION1 = atof(ptr);
Slord2142 33:6c7364ea360f 1195 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1196 CURRENT_12_DIV_FACTOR2 = atoi(ptr);
Slord2142 33:6c7364ea360f 1197 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1198 CURRENT_12_CORRECTION2 = atof(ptr);
Slord2142 33:6c7364ea360f 1199 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1200 CURRENT_12_DIV_FACTOR3 = atoi(ptr);
Slord2142 33:6c7364ea360f 1201 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1202 CURRENT_12_CORRECTION3 = atof(ptr);
Slord2142 33:6c7364ea360f 1203 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1204 CURRENT_12_DIV_FACTOR4 = atoi(ptr);
Slord2142 33:6c7364ea360f 1205 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1206 CURRENT_12_CORRECTION4 = atof(ptr);
Slord2142 33:6c7364ea360f 1207 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1208 CURRENT_12_DIV_FACTOR5 = atoi(ptr);
Slord2142 33:6c7364ea360f 1209 ptr = strtok(NULL, delim);
Slord2142 33:6c7364ea360f 1210 CURRENT_12_CORRECTION5 = atof(ptr);
Slord2142 33:6c7364ea360f 1211 printf("Values retreived. \r\n");
Slord2142 33:6c7364ea360f 1212 }
mfwic 6:39442d493098 1213 else if (!strcmp(commandString, "MY12"))
mfwic 6:39442d493098 1214 // MULT is used to get/set the en_out value.
mfwic 6:39442d493098 1215 // The integer value of boardMults is used to change en_out via setBoardWeights(boardMults).
mfwic 6:39442d493098 1216 // en_out are binary weighted signals that activate groups of DC-DC converters on the slot cards.
mfwic 6:39442d493098 1217 // en_out[6] = {en32, en16, en8, en4, en2, en1}
Slord2142 31:be17caf56d22 1218 {
mfwic 6:39442d493098 1219
mfwic 6:39442d493098 1220 if (readback)
mfwic 6:39442d493098 1221 {
mfwic 6:39442d493098 1222 sprintf(strbuf, " %d", my12);
mfwic 6:39442d493098 1223 sendSerial(strbuf);
mfwic 12:fd1fd1857628 1224 }else{
mfwic 12:fd1fd1857628 1225 my12 = commandData;
mfwic 12:fd1fd1857628 1226 testing = FALSE;
mfwic 6:39442d493098 1227 }
mfwic 6:39442d493098 1228 }
mfwic 0:44a3005d4f20 1229 else if (!strcmp(commandString, "ALLOFF"))
mfwic 0:44a3005d4f20 1230 {
mfwic 7:860b3a8275cb 1231 my12 = 0;
mfwic 7:860b3a8275cb 1232 running = FALSE;
mfwic 12:fd1fd1857628 1233 testing = FALSE;
mfwic 7:860b3a8275cb 1234 if(DEBUG){
mfwic 7:860b3a8275cb 1235 sprintf(strbuf, "wr_out_code=%d\r\n", wr_out_code);
mfwic 7:860b3a8275cb 1236 sendSerial(strbuf);
mfwic 7:860b3a8275cb 1237 }
mfwic 0:44a3005d4f20 1238 }
mfwic 0:44a3005d4f20 1239 else if (!strcmp(commandString, "ALLON"))
mfwic 0:44a3005d4f20 1240 {
mfwic 7:860b3a8275cb 1241 wr_out_code = setBoardEnables((unsigned int)ALLON);
mfwic 12:fd1fd1857628 1242 testing = TRUE;
mfwic 0:44a3005d4f20 1243 }
mfwic 0:44a3005d4f20 1244 else if (!strcmp(commandString, "RUN"))
mfwic 0:44a3005d4f20 1245 {
mfwic 0:44a3005d4f20 1246 // Skip over any white space and the optional '[' character
mfwic 0:44a3005d4f20 1247 while ((isspace(rxbuf[bufloc])) || (rxbuf[bufloc] == '[')) bufloc++;
mfwic 0:44a3005d4f20 1248
mfwic 9:816b9a4e4f21 1249 if(rxbuf[bufloc] == NULL){
mfwic 21:fe0ea1860c9f 1250 boardsActive = ALLON;
mfwic 9:816b9a4e4f21 1251 startConverter(boardsActive);
mfwic 12:fd1fd1857628 1252 testing = FALSE;
mfwic 9:816b9a4e4f21 1253 }
mfwic 9:816b9a4e4f21 1254 else if (rxbuf[bufloc] == '0')
mfwic 0:44a3005d4f20 1255 {
mfwic 1:9f8583ba2431 1256 stopConverter();
mfwic 12:fd1fd1857628 1257 testing = FALSE;
mfwic 0:44a3005d4f20 1258 }
mfwic 25:8bcc8bea0e31 1259 else if ((rxbuf[bufloc] > '0') && (rxbuf[bufloc] < '0' + max_boards))
mfwic 0:44a3005d4f20 1260 {
mfwic 0:44a3005d4f20 1261 ival = atoi(&rxbuf[bufloc]);
mfwic 9:816b9a4e4f21 1262 //ival--;
mfwic 0:44a3005d4f20 1263
mfwic 0:44a3005d4f20 1264 if (running == 0)
mfwic 0:44a3005d4f20 1265 {
mfwic 1:9f8583ba2431 1266 boardsActive = ival;
mfwic 1:9f8583ba2431 1267 startConverter(boardsActive);
mfwic 12:fd1fd1857628 1268 testing = FALSE;
mfwic 0:44a3005d4f20 1269 }
mfwic 0:44a3005d4f20 1270 else
mfwic 0:44a3005d4f20 1271 {
mfwic 0:44a3005d4f20 1272 // Compare the board enable flags between registers
mfwic 25:8bcc8bea0e31 1273 //boardEnables = checkRegisterCompatibility(ival);
mfwic 0:44a3005d4f20 1274
mfwic 0:44a3005d4f20 1275 // If board enable flags match, change the register set
mfwic 0:44a3005d4f20 1276 if (boardEnables == 0)
mfwic 0:44a3005d4f20 1277 {
mfwic 1:9f8583ba2431 1278 boardsActive = ival;
mfwic 0:44a3005d4f20 1279 }
mfwic 0:44a3005d4f20 1280 else
mfwic 0:44a3005d4f20 1281 {
mfwic 1:9f8583ba2431 1282 sprintf(strbuf, " Board enable flags do not match (0x%08x)", boardEnables);
mfwic 1:9f8583ba2431 1283 sendSerial(strbuf);
mfwic 0:44a3005d4f20 1284 }
mfwic 0:44a3005d4f20 1285 }
mfwic 0:44a3005d4f20 1286 }
mfwic 0:44a3005d4f20 1287 else
mfwic 0:44a3005d4f20 1288 {
mfwic 9:816b9a4e4f21 1289 sprintf(strbuf, " Invalid number of boards (1 - %d)", MAX_BOARDS);
mfwic 1:9f8583ba2431 1290 sendSerial(strbuf);
mfwic 0:44a3005d4f20 1291 commandError = 1;
mfwic 0:44a3005d4f20 1292 }
mfwic 0:44a3005d4f20 1293 }
mfwic 0:44a3005d4f20 1294 else if (!strcmp(commandString, "STOP"))
mfwic 0:44a3005d4f20 1295 {
mfwic 1:9f8583ba2431 1296 stopConverter();
mfwic 12:fd1fd1857628 1297 testing = FALSE;
mfwic 12:fd1fd1857628 1298 my12 = 0;
mfwic 0:44a3005d4f20 1299 }
Slord2142 33:6c7364ea360f 1300 else if(!strcmp(commandString, "RAW"))
mfwic 0:44a3005d4f20 1301 {
mfwic 0:44a3005d4f20 1302 if (running == 1)
mfwic 0:44a3005d4f20 1303 {
mfwic 1:9f8583ba2431 1304 sprintf(strbuf, " Parameters may not be updated while running!");
mfwic 1:9f8583ba2431 1305 sendSerial(strbuf);
mfwic 0:44a3005d4f20 1306 commandError = 1;
mfwic 0:44a3005d4f20 1307 }
mfwic 11:01dcfb29fbc4 1308
mfwic 8:d3d7dca419b3 1309 if (!commandError){
mfwic 8:d3d7dca419b3 1310 raw = TRUE;
mfwic 8:d3d7dca419b3 1311 menuRedraw(NO_PROMPT);
mfwic 0:44a3005d4f20 1312 }
mfwic 8:d3d7dca419b3 1313 }
Slord2142 33:6c7364ea360f 1314 else if(!strcmp(commandString, "COOK"))
mfwic 8:d3d7dca419b3 1315 {
mfwic 8:d3d7dca419b3 1316 if (running == 1)
mfwic 8:d3d7dca419b3 1317 {
mfwic 8:d3d7dca419b3 1318 sprintf(strbuf, " Parameters may not be updated while running!");
mfwic 8:d3d7dca419b3 1319 sendSerial(strbuf);
mfwic 8:d3d7dca419b3 1320 commandError = 1;
mfwic 8:d3d7dca419b3 1321 }
mfwic 11:01dcfb29fbc4 1322
mfwic 8:d3d7dca419b3 1323 if (!commandError){
mfwic 8:d3d7dca419b3 1324 raw = FALSE;
mfwic 8:d3d7dca419b3 1325 menuRedraw(NO_PROMPT);
mfwic 8:d3d7dca419b3 1326 }
mfwic 8:d3d7dca419b3 1327 }
mfwic 0:44a3005d4f20 1328 else
mfwic 0:44a3005d4f20 1329 {
mfwic 0:44a3005d4f20 1330 if (strcmp(commandString, ""))
mfwic 0:44a3005d4f20 1331 {
mfwic 0:44a3005d4f20 1332 commandError = 1;
mfwic 0:44a3005d4f20 1333 }
mfwic 0:44a3005d4f20 1334 }
mfwic 0:44a3005d4f20 1335
mfwic 0:44a3005d4f20 1336 if (commandError)
mfwic 0:44a3005d4f20 1337 {
mfwic 6:39442d493098 1338 sendSerial(" !");
mfwic 0:44a3005d4f20 1339 }
mfwic 0:44a3005d4f20 1340
mfwic 3:d8948c5b2951 1341 menuPrompt(MENU_DCM1);
mfwic 0:44a3005d4f20 1342 }
mfwic 0:44a3005d4f20 1343
mfwic 0:44a3005d4f20 1344 /************************************************************
mfwic 0:44a3005d4f20 1345 * Routine: processCommand
mfwic 0:44a3005d4f20 1346 * Input: none
mfwic 0:44a3005d4f20 1347 * Returns: none
mfwic 0:44a3005d4f20 1348 * Description:
mfwic 0:44a3005d4f20 1349 * This is the main serial communications routine. Everything
mfwic 0:44a3005d4f20 1350 * starts here as soon as a command is avaiable for processing.
mfwic 0:44a3005d4f20 1351 **************************************************************/
mfwic 0:44a3005d4f20 1352 void processCommand(void)
mfwic 0:44a3005d4f20 1353 {
mfwic 0:44a3005d4f20 1354 if (!serialStatus.command && !serialStatus.repeat)
mfwic 0:44a3005d4f20 1355 {
mfwic 0:44a3005d4f20 1356 return;
mfwic 0:44a3005d4f20 1357 }
mfwic 0:44a3005d4f20 1358
mfwic 0:44a3005d4f20 1359 doCommand(); // if not computer (i.e. terminal) you can do the command as well
mfwic 0:44a3005d4f20 1360
mfwic 0:44a3005d4f20 1361 bufloc = 0;
mfwic 0:44a3005d4f20 1362 rxbuf[bufloc] = 0;
mfwic 0:44a3005d4f20 1363
mfwic 0:44a3005d4f20 1364 serialStatus.computer = FALSE;
mfwic 0:44a3005d4f20 1365 serialStatus.command = FALSE;
mfwic 0:44a3005d4f20 1366 }
mfwic 8:d3d7dca419b3 1367
mfwic 8:d3d7dca419b3 1368 /************************************************************
mfwic 8:d3d7dca419b3 1369 * Routine: waitCommand
mfwic 8:d3d7dca419b3 1370 * Input: none
mfwic 8:d3d7dca419b3 1371 * Returns: none
mfwic 8:d3d7dca419b3 1372 * Description:
mfwic 8:d3d7dca419b3 1373 **************************************************************/
mfwic 8:d3d7dca419b3 1374 bool waitCommand(void)
mfwic 8:d3d7dca419b3 1375 {
mfwic 8:d3d7dca419b3 1376 if (!serialStatus.command && !serialStatus.repeat)
mfwic 8:d3d7dca419b3 1377 {
mfwic 8:d3d7dca419b3 1378 return TRUE;
mfwic 8:d3d7dca419b3 1379 }
mfwic 8:d3d7dca419b3 1380
mfwic 8:d3d7dca419b3 1381 serialStatus.computer = FALSE;
mfwic 8:d3d7dca419b3 1382 serialStatus.command = FALSE;
mfwic 8:d3d7dca419b3 1383
mfwic 8:d3d7dca419b3 1384 return FALSE;
mfwic 8:d3d7dca419b3 1385 }
mfwic 11:01dcfb29fbc4 1386
mfwic 11:01dcfb29fbc4 1387 // Verify that the same boards are enabled in both the current register and
mfwic 11:01dcfb29fbc4 1388 // the specified register
mfwic 11:01dcfb29fbc4 1389
mfwic 11:01dcfb29fbc4 1390