JLC test

Dependencies:   PinDetect libmDot mbed-rtos mbed

Committer:
tmulrooney
Date:
Sat Jan 30 17:02:23 2016 +0000
Revision:
2:376af6a70e8a
Parent:
1:96c429800568
using UART 2 - not working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tmulrooney 1:96c429800568 1 /* ========================================
tmulrooney 1:96c429800568 2 * Filename: commandLine.c
tmulrooney 1:96c429800568 3 *
tmulrooney 1:96c429800568 4 * Description: functions and operations needed for command line operation
tmulrooney 1:96c429800568 5 *
tmulrooney 1:96c429800568 6 * Copyright J-Factor Embedded Technologies 2015
tmulrooney 1:96c429800568 7 * Copyright TJM Embedded Software 2015
tmulrooney 1:96c429800568 8 * All Rights Reserved
tmulrooney 1:96c429800568 9 * UNPUBLISHED, LICENSED SOFTWARE.
tmulrooney 1:96c429800568 10 *
tmulrooney 1:96c429800568 11 * CONFIDENTIAL AND PROPRIETARY INFORMATION
tmulrooney 1:96c429800568 12 * WHICH IS THE PROPERTY OF J-Factor Embedded Technologies.
tmulrooney 1:96c429800568 13 *
tmulrooney 1:96c429800568 14 * ========================================
tmulrooney 1:96c429800568 15 */
tmulrooney 1:96c429800568 16 //#include <project.h>
tmulrooney 1:96c429800568 17 #include "mbed.h"
tmulrooney 1:96c429800568 18 #include "stdio.h"
tmulrooney 1:96c429800568 19 #include "common.h"
tmulrooney 1:96c429800568 20
tmulrooney 1:96c429800568 21 /** \file
tmulrooney 1:96c429800568 22 * \brief command line - contains all functions related to the command line.
tmulrooney 1:96c429800568 23 */
tmulrooney 1:96c429800568 24
tmulrooney 1:96c429800568 25 /* externals */
tmulrooney 1:96c429800568 26
tmulrooney 1:96c429800568 27 /* Globals */
tmulrooney 1:96c429800568 28 char line[LINE_SIZE]; //!< character array read
tmulrooney 1:96c429800568 29 char lastLine[NUM_LINES][LINE_SIZE]; //!< array of previous command lines
tmulrooney 1:96c429800568 30 int8 indexNextLineIn = 0; //!< index of next position to save current command line
tmulrooney 1:96c429800568 31 int8 indexNextLineOut = 0; //!< index of next position to read out saved comman dlines
tmulrooney 1:96c429800568 32 int8 linesInBuffer = 0; //!< number of lines in command line buffer
tmulrooney 1:96c429800568 33 uint8 enableCLI = 1;
tmulrooney 1:96c429800568 34 uint8 escapeSeen = 0; //!< escape character seen
tmulrooney 1:96c429800568 35 int8 charCount; //!< number of characters in the current command line
tmulrooney 1:96c429800568 36 int8 cursorPosition; //!< current cursor position in the current command line
tmulrooney 1:96c429800568 37 char TransmitBuffer[TRANSMIT_BUFFER_SIZE]; //!< charaters to be sent to the console
tmulrooney 1:96c429800568 38 uint8 ptrCmd = 0;
tmulrooney 1:96c429800568 39 uint8 binaryParameter; //!< result of any 8 bit integer read operation
tmulrooney 1:96c429800568 40 uint16 digitalParameter; //!< result of any 16 bit integer read operation
tmulrooney 1:96c429800568 41 float analogParameter; //!< result of any floating point read operation
tmulrooney 1:96c429800568 42 char *validCmds[] = {"help","version","read","readReg","write","writeReg","info","find","run","stop","date","hvstate"}; //!< array of valid commands - case insensitive
tmulrooney 1:96c429800568 43 uint16 regAddress;
tmulrooney 1:96c429800568 44 uint16 regLength;
tmulrooney 1:96c429800568 45 uint8 regData[MAX_REGISTER_DATA];
tmulrooney 1:96c429800568 46
tmulrooney 1:96c429800568 47 /**
tmulrooney 1:96c429800568 48 * \fn getLine
tmulrooney 1:96c429800568 49 *
tmulrooney 1:96c429800568 50 * \brief Reads characters from UART and retuns a line when new line seen.
tmulrooney 1:96c429800568 51 * if enableCLI == 1 - process input characters<p>
tmulrooney 1:96c429800568 52 * if enableCLI == 0 - return 0<p>
tmulrooney 1:96c429800568 53 *
tmulrooney 1:96c429800568 54 * will call UART_1_CetChar() to get the next character.<p>
tmulrooney 1:96c429800568 55 * if ch == 0 - no character available<p>
tmulrooney 1:96c429800568 56 * if ch != 0 - add ch to line array<p>
tmulrooney 1:96c429800568 57 * features: <p>
tmulrooney 1:96c429800568 58 * up arrow will go through last NUM_LINES commands. <p>
tmulrooney 1:96c429800568 59 * backspace will remove last typed character<p>
tmulrooney 1:96c429800568 60 *
tmulrooney 1:96c429800568 61 * \return uint8 - 0 - no character ready or line not finished, 1 - line complete (CR seen)<p>
tmulrooney 1:96c429800568 62 *
tmulrooney 1:96c429800568 63 */
tmulrooney 1:96c429800568 64 uint8 getLine()
tmulrooney 1:96c429800568 65 {
tmulrooney 1:96c429800568 66 /* Variable to store UART received character */
tmulrooney 1:96c429800568 67 uint8 ch,i;
tmulrooney 1:96c429800568 68
tmulrooney 1:96c429800568 69 /* check if CLI enabled */
tmulrooney 1:96c429800568 70 if(enableCLI == 0)
tmulrooney 1:96c429800568 71 return 0;
tmulrooney 1:96c429800568 72
tmulrooney 1:96c429800568 73 /* Non-blocking call to get the latest data recieved */
tmulrooney 1:96c429800568 74 if(pc.readable())
tmulrooney 1:96c429800568 75 ch = pc.getc();
tmulrooney 1:96c429800568 76 else
tmulrooney 1:96c429800568 77 ch = '\0';
tmulrooney 1:96c429800568 78
tmulrooney 1:96c429800568 79 /* Set flags based on UART command */
tmulrooney 1:96c429800568 80 switch(ch)
tmulrooney 1:96c429800568 81 {
tmulrooney 1:96c429800568 82 case 0:
tmulrooney 1:96c429800568 83 /* No new data was recieved */
tmulrooney 1:96c429800568 84 return 0;
tmulrooney 1:96c429800568 85
tmulrooney 1:96c429800568 86 case 0x1B: /* up arrow seen */
tmulrooney 1:96c429800568 87 escapeSeen = 1;
tmulrooney 1:96c429800568 88 break;
tmulrooney 1:96c429800568 89
tmulrooney 1:96c429800568 90 case '\n': /* new line seen */
tmulrooney 1:96c429800568 91 case '\r':
tmulrooney 1:96c429800568 92 pc.printf("\r\n");
tmulrooney 1:96c429800568 93 line[charCount] = '\0';
tmulrooney 1:96c429800568 94 charCount = 0;
tmulrooney 1:96c429800568 95 cursorPosition = charCount;
tmulrooney 1:96c429800568 96 escapeSeen = 0;
tmulrooney 1:96c429800568 97 if(strlen(line) > 0)
tmulrooney 1:96c429800568 98 {
tmulrooney 1:96c429800568 99 strcpy(&lastLine[indexNextLineIn][0],line); /* save current command line in buffer */
tmulrooney 1:96c429800568 100 if(linesInBuffer < NUM_LINES)
tmulrooney 1:96c429800568 101 linesInBuffer++;
tmulrooney 1:96c429800568 102 indexNextLineIn++; /* point to next free space in command line buffer */
tmulrooney 1:96c429800568 103 if(indexNextLineIn == NUM_LINES - 1) /* wrap around if past end */
tmulrooney 1:96c429800568 104 indexNextLineIn = 0;
tmulrooney 1:96c429800568 105 indexNextLineOut = indexNextLineIn;
tmulrooney 1:96c429800568 106 }
tmulrooney 1:96c429800568 107 return 1;
tmulrooney 1:96c429800568 108
tmulrooney 1:96c429800568 109 default:
tmulrooney 1:96c429800568 110 // sprintf(TransmitBuffer,"char: %02X %c charCount: %d\r\n",ch,ch,charCount);
tmulrooney 1:96c429800568 111 // UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 112 if( (escapeSeen == 1) && (ch == '[') )
tmulrooney 1:96c429800568 113 {
tmulrooney 1:96c429800568 114 escapeSeen++;
tmulrooney 1:96c429800568 115 break;
tmulrooney 1:96c429800568 116 }
tmulrooney 1:96c429800568 117 else if( (escapeSeen == 2) && (ch == 'A') ) /* look for up arrow escape sequence */
tmulrooney 1:96c429800568 118 {
tmulrooney 1:96c429800568 119 if(linesInBuffer == 0)
tmulrooney 1:96c429800568 120 break;
tmulrooney 1:96c429800568 121 indexNextLineOut--; /* point to last line in */
tmulrooney 1:96c429800568 122 if(indexNextLineOut < 0) /* check if wrap around */
tmulrooney 1:96c429800568 123 {
tmulrooney 1:96c429800568 124 if(linesInBuffer < NUM_LINES)
tmulrooney 1:96c429800568 125 indexNextLineOut = linesInBuffer -1;
tmulrooney 1:96c429800568 126 else
tmulrooney 1:96c429800568 127 indexNextLineOut = NUM_LINES - 1;
tmulrooney 1:96c429800568 128 }
tmulrooney 1:96c429800568 129 strcpy(line,&lastLine[indexNextLineOut][0]); /* copy command line from buffer to command line */
tmulrooney 1:96c429800568 130 charCount = strlen(line);
tmulrooney 1:96c429800568 131 cursorPosition = charCount;
tmulrooney 1:96c429800568 132 escapeSeen = 0;
tmulrooney 1:96c429800568 133 pc.printf("\r");
tmulrooney 1:96c429800568 134 for (i=0;i<sizeof(line);i++) /* clear line of last command */
tmulrooney 1:96c429800568 135 pc.printf(" ");
tmulrooney 1:96c429800568 136 sprintf(TransmitBuffer,"\r%s cmd>%s",time_string,line); /* restore with selected command */
tmulrooney 1:96c429800568 137 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 138 break;
tmulrooney 1:96c429800568 139 }
tmulrooney 1:96c429800568 140 else if( (escapeSeen == 2) && (ch == 'D') ) /* look for left arrow escape sequence */
tmulrooney 1:96c429800568 141 {
tmulrooney 1:96c429800568 142 if( cursorPosition > 0 )
tmulrooney 1:96c429800568 143 {
tmulrooney 1:96c429800568 144 pc.printf("\b");
tmulrooney 1:96c429800568 145 cursorPosition--;
tmulrooney 1:96c429800568 146 }
tmulrooney 1:96c429800568 147 escapeSeen = 0;
tmulrooney 1:96c429800568 148 break;
tmulrooney 1:96c429800568 149 }
tmulrooney 1:96c429800568 150 else if( (escapeSeen == 2) && (ch == 'C') ) /* look for right arrow escape sequence */
tmulrooney 1:96c429800568 151 {
tmulrooney 1:96c429800568 152 if( cursorPosition < charCount )
tmulrooney 1:96c429800568 153 {
tmulrooney 1:96c429800568 154 sprintf(TransmitBuffer,"%c",line[cursorPosition]);
tmulrooney 1:96c429800568 155 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 156 cursorPosition++;
tmulrooney 1:96c429800568 157 }
tmulrooney 1:96c429800568 158 escapeSeen = 0;
tmulrooney 1:96c429800568 159 break;
tmulrooney 1:96c429800568 160 }
tmulrooney 1:96c429800568 161 else if( (ch == 0x7F) || (ch == '\b') ) /* backspace seen */
tmulrooney 1:96c429800568 162 {
tmulrooney 1:96c429800568 163 if( (charCount > 0) && (charCount == cursorPosition) )
tmulrooney 1:96c429800568 164 {
tmulrooney 1:96c429800568 165 pc.printf("\b \b");
tmulrooney 1:96c429800568 166 charCount--;
tmulrooney 1:96c429800568 167 cursorPosition = charCount;
tmulrooney 1:96c429800568 168 line[charCount] = '\0';
tmulrooney 1:96c429800568 169 }
tmulrooney 1:96c429800568 170 }
tmulrooney 1:96c429800568 171 else
tmulrooney 1:96c429800568 172 {
tmulrooney 1:96c429800568 173 if(charCount < (LINE_SIZE - 1))
tmulrooney 1:96c429800568 174 {
tmulrooney 1:96c429800568 175 sprintf(TransmitBuffer,"%c",ch);
tmulrooney 1:96c429800568 176 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 177 if(charCount != cursorPosition) /* move characters at cursor up to fit in new character */
tmulrooney 1:96c429800568 178 {
tmulrooney 1:96c429800568 179 for(i = charCount ; i > cursorPosition; i--)
tmulrooney 1:96c429800568 180 line[i] = line[i-1];
tmulrooney 1:96c429800568 181 line[cursorPosition] = ch;
tmulrooney 1:96c429800568 182 line[++charCount] = '\0';
tmulrooney 1:96c429800568 183 for (i=cursorPosition + 1;i<charCount;i++)
tmulrooney 1:96c429800568 184 {
tmulrooney 1:96c429800568 185 sprintf(TransmitBuffer,"%c",line[i]);
tmulrooney 1:96c429800568 186 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 187 }
tmulrooney 1:96c429800568 188 cursorPosition = charCount;
tmulrooney 1:96c429800568 189 }
tmulrooney 1:96c429800568 190 else
tmulrooney 1:96c429800568 191 {
tmulrooney 1:96c429800568 192 line[charCount++] = ch;
tmulrooney 1:96c429800568 193 cursorPosition = charCount;
tmulrooney 1:96c429800568 194 }
tmulrooney 1:96c429800568 195 }
tmulrooney 1:96c429800568 196 }
tmulrooney 1:96c429800568 197 break;
tmulrooney 1:96c429800568 198 }
tmulrooney 1:96c429800568 199 return 0;
tmulrooney 1:96c429800568 200 }
tmulrooney 1:96c429800568 201
tmulrooney 1:96c429800568 202
tmulrooney 1:96c429800568 203 /**
tmulrooney 1:96c429800568 204 * \fn executeCmd
tmulrooney 1:96c429800568 205 *
tmulrooney 1:96c429800568 206 * \brief executes the command in line array.
tmulrooney 1:96c429800568 207 *
tmulrooney 1:96c429800568 208 * calls getCmd to parse command and then switches to proper command handler.
tmulrooney 1:96c429800568 209 * command list kept short for simplicity.<p>
tmulrooney 1:96c429800568 210 * read, write, and info command will read and verify parametsr on command line.
tmulrooney 1:96c429800568 211 * \return None<p>
tmulrooney 1:96c429800568 212 *
tmulrooney 1:96c429800568 213 */
tmulrooney 1:96c429800568 214 void executeCmd()
tmulrooney 1:96c429800568 215 {
tmulrooney 1:96c429800568 216 int8 cmd;
tmulrooney 1:96c429800568 217 uint8 type,i;
tmulrooney 1:96c429800568 218 int32 convertFloat1,convertFloat2;
tmulrooney 1:96c429800568 219 float floatValue;
tmulrooney 1:96c429800568 220 int value,num, pos;
tmulrooney 1:96c429800568 221 char str[40] = "", str2[40] = "";
tmulrooney 1:96c429800568 222 uint8 statusRegister;
tmulrooney 1:96c429800568 223
tmulrooney 1:96c429800568 224 cmd = getCmd();
tmulrooney 1:96c429800568 225 // sprintf(TransmitBuffer,"cmd: %d ptrCmd: %d\r\n",cmd,ptrCmd);
tmulrooney 1:96c429800568 226 // UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 227
tmulrooney 1:96c429800568 228 /* execute command */
tmulrooney 1:96c429800568 229 switch (cmd)
tmulrooney 1:96c429800568 230 {
tmulrooney 1:96c429800568 231 case HELP:
tmulrooney 1:96c429800568 232 pc.printf("Valid Commands (case insensitive)\r\n");
tmulrooney 1:96c429800568 233 pc.printf("find [string] - find all parameters or all parameters that contain the string\r\n");
tmulrooney 1:96c429800568 234 pc.printf("help - display list of valid commands\r\n");
tmulrooney 1:96c429800568 235 pc.printf("info [parameter]- display info on all or parameter\r\n");
tmulrooney 1:96c429800568 236 pc.printf("read parameter - read value of parameter\r\n");
tmulrooney 1:96c429800568 237 pc.printf("readReg parameter register length - read N values from parameter registers\r\n");
tmulrooney 1:96c429800568 238 pc.printf("version - display version information\r\n");
tmulrooney 1:96c429800568 239 pc.printf("write parameter register value - write value to parameter register\r\n");
tmulrooney 1:96c429800568 240 pc.printf("writeReg parameter value - write value to parameter\r\n");
tmulrooney 1:96c429800568 241 pc.printf("run - start control running\r\n");
tmulrooney 1:96c429800568 242 pc.printf("stop - stop control running\r\n");
tmulrooney 1:96c429800568 243 pc.printf("date [date string]- display/set current time and date\r\n");
tmulrooney 1:96c429800568 244 pc.printf("hvstate - current HV status\r\n");
tmulrooney 1:96c429800568 245 break;
tmulrooney 1:96c429800568 246
tmulrooney 1:96c429800568 247 case DATE:
tmulrooney 1:96c429800568 248 num = sscanf(&line[ptrCmd],"%s",str); /* optional parameter on the command line - date string */
tmulrooney 1:96c429800568 249 if(num > 0)
tmulrooney 1:96c429800568 250 {
tmulrooney 1:96c429800568 251 setDate(&line[ptrCmd]);
tmulrooney 1:96c429800568 252 }
tmulrooney 1:96c429800568 253 date();
tmulrooney 1:96c429800568 254 sprintf(TransmitBuffer,"current time is %s\r\n",c_time_string);
tmulrooney 1:96c429800568 255 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 256 break;
tmulrooney 1:96c429800568 257
tmulrooney 1:96c429800568 258 case VERSION:
tmulrooney 1:96c429800568 259 printVersion();
tmulrooney 1:96c429800568 260 // sprintf(TransmitBuffer,"PSK15-5 CSE: V%d.%02d %s\r\n",VERSION_MAJOR,VERSION_MINOR,VERSION_DATE);
tmulrooney 1:96c429800568 261 // UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 262 // sprintf(TransmitBuffer,"Built on: %s %s\r\n",__DATE__,__TIME__);
tmulrooney 1:96c429800568 263 // UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 264 break;
tmulrooney 1:96c429800568 265
tmulrooney 1:96c429800568 266 case READ:
tmulrooney 1:96c429800568 267 num = sscanf(&line[ptrCmd],"%s",str); /* expecting one parameter on the command line - parameter name */
tmulrooney 1:96c429800568 268 if(num == 1)
tmulrooney 1:96c429800568 269 {
tmulrooney 1:96c429800568 270 num = getParameter(str); /* get paramter position in parameters array from paramter name */
tmulrooney 1:96c429800568 271 if (num >= 0)
tmulrooney 1:96c429800568 272 {
tmulrooney 1:96c429800568 273 type = readParam(num); /* read paramter value and return parameter type */
tmulrooney 1:96c429800568 274 if(type == BINARY)
tmulrooney 1:96c429800568 275 {
tmulrooney 1:96c429800568 276 sprintf(TransmitBuffer,"%s: %d %s\r\n",parameters[num].name,binaryParameter,parameters[num].uints);
tmulrooney 1:96c429800568 277 }
tmulrooney 1:96c429800568 278 else if(type == DIGITAL)
tmulrooney 1:96c429800568 279 {
tmulrooney 1:96c429800568 280 sprintf(TransmitBuffer,"%s: %d %s\r\n",parameters[num].name,digitalParameter,parameters[num].uints);
tmulrooney 1:96c429800568 281 }
tmulrooney 1:96c429800568 282 else if(type == ANALOG)
tmulrooney 1:96c429800568 283 {
tmulrooney 1:96c429800568 284 convertFloat1 = analogParameter * 100.0;
tmulrooney 1:96c429800568 285 sprintf(TransmitBuffer,"%s: %ld.%02ld %s\r\n",parameters[num].name,convertFloat1/100,convertFloat1%100,parameters[num].uints);
tmulrooney 1:96c429800568 286 }
tmulrooney 1:96c429800568 287 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 288 }
tmulrooney 1:96c429800568 289 else
tmulrooney 1:96c429800568 290 {
tmulrooney 1:96c429800568 291 sprintf(TransmitBuffer,"Invalid parameter\r\nType help for list of valid parameters\r\n");
tmulrooney 1:96c429800568 292 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 293 }
tmulrooney 1:96c429800568 294 }
tmulrooney 1:96c429800568 295 else
tmulrooney 1:96c429800568 296 {
tmulrooney 1:96c429800568 297 sprintf(TransmitBuffer,"Missing parameter\r\nformat: read parameter\r\n");
tmulrooney 1:96c429800568 298 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 299 }
tmulrooney 1:96c429800568 300 break;
tmulrooney 1:96c429800568 301
tmulrooney 1:96c429800568 302 case READ_REG:
tmulrooney 1:96c429800568 303 num = sscanf(&line[ptrCmd],"%s %X %X",str, &regAddress, &regLength);
tmulrooney 1:96c429800568 304 if(num < 0)
tmulrooney 1:96c429800568 305 {
tmulrooney 1:96c429800568 306 sprintf(TransmitBuffer,"Missing parameter\r\nformat: read parameter [Reg Address (hex)] [Length (hex)]\r\n");
tmulrooney 1:96c429800568 307 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 308 return;
tmulrooney 1:96c429800568 309 }
tmulrooney 1:96c429800568 310 pos = getParameter(str); /* get paramter position in parameters array from paramter name */
tmulrooney 1:96c429800568 311 if(pos == -1)
tmulrooney 1:96c429800568 312 {
tmulrooney 1:96c429800568 313 sprintf(TransmitBuffer,"Invalid parameter\r\nType help for list of valid parameters\r\n");
tmulrooney 1:96c429800568 314 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 315 return;
tmulrooney 1:96c429800568 316 }
tmulrooney 1:96c429800568 317 switch(num)
tmulrooney 1:96c429800568 318 {
tmulrooney 1:96c429800568 319 case 1:
tmulrooney 1:96c429800568 320 regAddress = 0;
tmulrooney 1:96c429800568 321 regLength = 1;
tmulrooney 1:96c429800568 322 break;
tmulrooney 1:96c429800568 323
tmulrooney 1:96c429800568 324 case 2:
tmulrooney 1:96c429800568 325 regLength = 1;
tmulrooney 1:96c429800568 326 break;
tmulrooney 1:96c429800568 327
tmulrooney 1:96c429800568 328 case 3:
tmulrooney 1:96c429800568 329 break;
tmulrooney 1:96c429800568 330
tmulrooney 1:96c429800568 331 }
tmulrooney 1:96c429800568 332 type = readParam(pos); /* read paramter value and return parameter type */
tmulrooney 1:96c429800568 333 for(i=0; i< bytesRead; i++)
tmulrooney 1:96c429800568 334 {
tmulrooney 1:96c429800568 335 if( i == 0 )
tmulrooney 1:96c429800568 336 pc.printf("%04X ",regAddress);
tmulrooney 1:96c429800568 337 else if( (i % 0x10) == 0 )
tmulrooney 1:96c429800568 338 pc.printf("\r\n%04X ",regAddress + i);
tmulrooney 1:96c429800568 339 pc.printf("%02X ",regData[i]);
tmulrooney 1:96c429800568 340 }
tmulrooney 1:96c429800568 341 pc.printf("\r\n");
tmulrooney 1:96c429800568 342 break;
tmulrooney 1:96c429800568 343 #if 0
tmulrooney 1:96c429800568 344 case WRITE:
tmulrooney 1:96c429800568 345 floatValue = 0.0;
tmulrooney 1:96c429800568 346 num = sscanf(&line[ptrCmd],"%s %s",str,str2); /* expecting two parameters on the command line - parameter name and parameter value */
tmulrooney 1:96c429800568 347 if(num == 2)
tmulrooney 1:96c429800568 348 {
tmulrooney 1:96c429800568 349 num = getParameter(str); /* get paramter position in parameters array from paramter name */
tmulrooney 1:96c429800568 350 if (num >= 0)
tmulrooney 1:96c429800568 351 {
tmulrooney 1:96c429800568 352 type = readParam(num); /* read paramter value and return parameter type */
tmulrooney 1:96c429800568 353 if(type == ANALOG)
tmulrooney 1:96c429800568 354 {
tmulrooney 1:96c429800568 355 floatValue = strtofloat(str2); /* paramters name and floating point number */
tmulrooney 1:96c429800568 356 }
tmulrooney 1:96c429800568 357 else
tmulrooney 1:96c429800568 358 {
tmulrooney 1:96c429800568 359 sscanf(&line[ptrCmd],"%s %d",str,&value); /* parameters name and integer value */
tmulrooney 1:96c429800568 360 }
tmulrooney 1:96c429800568 361 if(type == BINARY)
tmulrooney 1:96c429800568 362 {
tmulrooney 1:96c429800568 363 if(value > parameters[num].maxInt)
tmulrooney 1:96c429800568 364 {
tmulrooney 1:96c429800568 365 sprintf(TransmitBuffer,"%d exceeds maximum value %d\r\n",value,parameters[num].maxInt);
tmulrooney 1:96c429800568 366 }
tmulrooney 1:96c429800568 367 else
tmulrooney 1:96c429800568 368 {
tmulrooney 1:96c429800568 369 writeParam(num,value,floatValue);
tmulrooney 1:96c429800568 370 type = readParam(num);
tmulrooney 1:96c429800568 371 sprintf(TransmitBuffer,"%s: %d %s\r\n",parameters[num].name,binaryParameter,parameters[num].uints);
tmulrooney 1:96c429800568 372 }
tmulrooney 1:96c429800568 373 }
tmulrooney 1:96c429800568 374 else if(type == DIGITAL)
tmulrooney 1:96c429800568 375 {
tmulrooney 1:96c429800568 376 if(value > parameters[num].maxInt)
tmulrooney 1:96c429800568 377 {
tmulrooney 1:96c429800568 378 sprintf(TransmitBuffer,"%d %s exceeds maximum value %d %s\r\n",value,parameters[num].uints,parameters[num].maxInt,parameters[num].uints);
tmulrooney 1:96c429800568 379 }
tmulrooney 1:96c429800568 380 else if(value < parameters[num].minInt)
tmulrooney 1:96c429800568 381 {
tmulrooney 1:96c429800568 382 sprintf(TransmitBuffer,"%d %s less than minimum value %d %s\r\n",value,parameters[num].uints,parameters[num].minInt,parameters[num].uints);
tmulrooney 1:96c429800568 383 }
tmulrooney 1:96c429800568 384 else
tmulrooney 1:96c429800568 385 {
tmulrooney 1:96c429800568 386 writeParam(num,value,floatValue);
tmulrooney 1:96c429800568 387 type = readParam(num);
tmulrooney 1:96c429800568 388 sprintf(TransmitBuffer,"%s: %d %s\r\n",parameters[num].name,digitalParameter,parameters[num].uints);
tmulrooney 1:96c429800568 389 }
tmulrooney 1:96c429800568 390 }
tmulrooney 1:96c429800568 391 else if(type == ANALOG)
tmulrooney 1:96c429800568 392 {
tmulrooney 1:96c429800568 393 if(floatValue > parameters[num].maxFloat)
tmulrooney 1:96c429800568 394 {
tmulrooney 1:96c429800568 395 convertFloat1 = floatValue * 100;
tmulrooney 1:96c429800568 396 convertFloat2 = parameters[num].maxFloat * 100;
tmulrooney 1:96c429800568 397 sprintf(TransmitBuffer,"%ld.%02ld %s exceeds maximum value %ld.%02ld %s\r\n",convertFloat1/100,convertFloat1%100,parameters[num].uints,convertFloat2/100,convertFloat2%100,parameters[num].uints);
tmulrooney 1:96c429800568 398 }
tmulrooney 1:96c429800568 399 else if(floatValue < parameters[num].minFloat)
tmulrooney 1:96c429800568 400 {
tmulrooney 1:96c429800568 401 convertFloat1 = floatValue * 100;
tmulrooney 1:96c429800568 402 convertFloat2 = parameters[num].minFloat * 100;
tmulrooney 1:96c429800568 403 sprintf(TransmitBuffer,"%ld.%02ld %s is less than value %ld.%02ld %s\r\n",convertFloat1/100,convertFloat1%100,parameters[num].uints,convertFloat2/100,convertFloat2%100,parameters[num].uints);
tmulrooney 1:96c429800568 404 }
tmulrooney 1:96c429800568 405 else
tmulrooney 1:96c429800568 406 {
tmulrooney 1:96c429800568 407 writeParam(num,value,floatValue);
tmulrooney 1:96c429800568 408 type = readParam(num);
tmulrooney 1:96c429800568 409 convertFloat1 = analogParameter * 100;
tmulrooney 1:96c429800568 410 sprintf(TransmitBuffer,"%s: %ld.%02ld %s\r\n",parameters[num].name,convertFloat1/100,convertFloat1%100,parameters[num].uints);
tmulrooney 1:96c429800568 411 }
tmulrooney 1:96c429800568 412 }
tmulrooney 1:96c429800568 413 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 414 }
tmulrooney 1:96c429800568 415 else
tmulrooney 1:96c429800568 416 {
tmulrooney 1:96c429800568 417 pc.printf("Invalid parameter\r\nType help for list of valid parameters\r\n");
tmulrooney 1:96c429800568 418 }
tmulrooney 1:96c429800568 419 }
tmulrooney 1:96c429800568 420 else
tmulrooney 1:96c429800568 421 {
tmulrooney 1:96c429800568 422 pc.printf("Missing parameter(s)\r\nformat: write parameter value\r\n");
tmulrooney 1:96c429800568 423 }
tmulrooney 1:96c429800568 424 break;
tmulrooney 1:96c429800568 425 #endif
tmulrooney 1:96c429800568 426 case WRITE_REG:
tmulrooney 1:96c429800568 427 num = sscanf(&line[ptrCmd],"%s %X %X",str, &regAddress, &regData);
tmulrooney 1:96c429800568 428 if(num != 3)
tmulrooney 1:96c429800568 429 {
tmulrooney 1:96c429800568 430 pc.printf("Missing parameter\r\nformat: write parameter Reg Address (hex) Value (hex)\r\n");
tmulrooney 1:96c429800568 431 return;
tmulrooney 1:96c429800568 432 }
tmulrooney 1:96c429800568 433 pos = getParameter(str); /* get paramter position in parameters array from paramter name */
tmulrooney 1:96c429800568 434 if(pos == -1)
tmulrooney 1:96c429800568 435 {
tmulrooney 1:96c429800568 436 sprintf(TransmitBuffer,"Invalid parameter\r\nType help for list of valid parameters\r\n");
tmulrooney 1:96c429800568 437 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 438 return;
tmulrooney 1:96c429800568 439 }
tmulrooney 1:96c429800568 440 writeParam(pos,regData); /* write paramter value and return parameter type */
tmulrooney 1:96c429800568 441 regLength = 1;
tmulrooney 1:96c429800568 442 readParam(pos);
tmulrooney 1:96c429800568 443 for(i=0; i< bytesRead; i++)
tmulrooney 1:96c429800568 444 {
tmulrooney 1:96c429800568 445 if( i == 0 )
tmulrooney 1:96c429800568 446 pc.printf("%04X ",regAddress);
tmulrooney 1:96c429800568 447 else if( (i % 0x10) == 0 )
tmulrooney 1:96c429800568 448 pc.printf("\r\n%04X ",regAddress + i);
tmulrooney 1:96c429800568 449 pc.printf("%02X ",regData[i]);
tmulrooney 1:96c429800568 450 }
tmulrooney 1:96c429800568 451 pc.printf("\r\n");
tmulrooney 1:96c429800568 452 break;
tmulrooney 1:96c429800568 453 #if 0
tmulrooney 1:96c429800568 454 floatValue = 0.0;
tmulrooney 1:96c429800568 455 num = sscanf(&line[ptrCmd],"%s %s",str,str2); /* expecting two parameters on the command line - parameter name and parameter value */
tmulrooney 1:96c429800568 456 if(num == 2)
tmulrooney 1:96c429800568 457 {
tmulrooney 1:96c429800568 458 num = getParameter(str); /* get paramter position in parameters array from paramter name */
tmulrooney 1:96c429800568 459 if (num >= 0)
tmulrooney 1:96c429800568 460 {
tmulrooney 1:96c429800568 461 type = readParam(num); /* read paramter value and return parameter type */
tmulrooney 1:96c429800568 462 if(type == ANALOG)
tmulrooney 1:96c429800568 463 {
tmulrooney 1:96c429800568 464 floatValue = strtofloat(str2); /* paramters name and floating point number */
tmulrooney 1:96c429800568 465 }
tmulrooney 1:96c429800568 466 else
tmulrooney 1:96c429800568 467 {
tmulrooney 1:96c429800568 468 sscanf(&line[ptrCmd],"%s %d",str,&value); /* parameters name and integer value */
tmulrooney 1:96c429800568 469 }
tmulrooney 1:96c429800568 470 if(type == BINARY)
tmulrooney 1:96c429800568 471 {
tmulrooney 1:96c429800568 472 if(value > parameters[num].maxInt)
tmulrooney 1:96c429800568 473 {
tmulrooney 1:96c429800568 474 sprintf(TransmitBuffer,"%d exceeds maximum value %d\r\n",value,parameters[num].maxInt);
tmulrooney 1:96c429800568 475 }
tmulrooney 1:96c429800568 476 else
tmulrooney 1:96c429800568 477 {
tmulrooney 1:96c429800568 478 writeParam(num,value,floatValue);
tmulrooney 1:96c429800568 479 type = readParam(num);
tmulrooney 1:96c429800568 480 sprintf(TransmitBuffer,"%s: %d %s\r\n",parameters[num].name,binaryParameter,parameters[num].uints);
tmulrooney 1:96c429800568 481 }
tmulrooney 1:96c429800568 482 }
tmulrooney 1:96c429800568 483 else if(type == DIGITAL)
tmulrooney 1:96c429800568 484 {
tmulrooney 1:96c429800568 485 if(value > parameters[num].maxInt)
tmulrooney 1:96c429800568 486 {
tmulrooney 1:96c429800568 487 sprintf(TransmitBuffer,"%d %s exceeds maximum value %d %s\r\n",value,parameters[num].uints,parameters[num].maxInt,parameters[num].uints);
tmulrooney 1:96c429800568 488 }
tmulrooney 1:96c429800568 489 else if(value < parameters[num].minInt)
tmulrooney 1:96c429800568 490 {
tmulrooney 1:96c429800568 491 sprintf(TransmitBuffer,"%d %s less than minimum value %d %s\r\n",value,parameters[num].uints,parameters[num].minInt,parameters[num].uints);
tmulrooney 1:96c429800568 492 }
tmulrooney 1:96c429800568 493 else
tmulrooney 1:96c429800568 494 {
tmulrooney 1:96c429800568 495 writeParam(num,value,floatValue);
tmulrooney 1:96c429800568 496 type = readParam(num);
tmulrooney 1:96c429800568 497 sprintf(TransmitBuffer,"%s: %d %s\r\n",parameters[num].name,digitalParameter,parameters[num].uints);
tmulrooney 1:96c429800568 498 }
tmulrooney 1:96c429800568 499 }
tmulrooney 1:96c429800568 500 else if(type == ANALOG)
tmulrooney 1:96c429800568 501 {
tmulrooney 1:96c429800568 502 if(floatValue > parameters[num].maxFloat)
tmulrooney 1:96c429800568 503 {
tmulrooney 1:96c429800568 504 convertFloat1 = floatValue * 100;
tmulrooney 1:96c429800568 505 convertFloat2 = parameters[num].maxFloat * 100;
tmulrooney 1:96c429800568 506 sprintf(TransmitBuffer,"%ld.%02ld %s exceeds maximum value %ld.%02ld %s\r\n",convertFloat1/100,convertFloat1%100,parameters[num].uints,convertFloat2/100,convertFloat2%100,parameters[num].uints);
tmulrooney 1:96c429800568 507 }
tmulrooney 1:96c429800568 508 else if(floatValue < parameters[num].minFloat)
tmulrooney 1:96c429800568 509 {
tmulrooney 1:96c429800568 510 convertFloat1 = floatValue * 100;
tmulrooney 1:96c429800568 511 convertFloat2 = parameters[num].minFloat * 100;
tmulrooney 1:96c429800568 512 sprintf(TransmitBuffer,"%ld.%02ld %s is less than value %ld.%02ld %s\r\n",convertFloat1/100,convertFloat1%100,parameters[num].uints,convertFloat2/100,convertFloat2%100,parameters[num].uints);
tmulrooney 1:96c429800568 513 }
tmulrooney 1:96c429800568 514 else
tmulrooney 1:96c429800568 515 {
tmulrooney 1:96c429800568 516 writeParam(num,value,floatValue);
tmulrooney 1:96c429800568 517 type = readParam(num);
tmulrooney 1:96c429800568 518 convertFloat1 = analogParameter * 100;
tmulrooney 1:96c429800568 519 sprintf(TransmitBuffer,"%s: %ld.%02ld %s\r\n",parameters[num].name,convertFloat1/100,convertFloat1%100,parameters[num].uints);
tmulrooney 1:96c429800568 520 }
tmulrooney 1:96c429800568 521 }
tmulrooney 1:96c429800568 522 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 523 }
tmulrooney 1:96c429800568 524 else
tmulrooney 1:96c429800568 525 {
tmulrooney 1:96c429800568 526 pc.printf("Invalid parameter\r\nType help for list of valid parameters\r\n");
tmulrooney 1:96c429800568 527 }
tmulrooney 1:96c429800568 528 }
tmulrooney 1:96c429800568 529 else
tmulrooney 1:96c429800568 530 {
tmulrooney 1:96c429800568 531 pc.printf("Missing parameter(s)\r\nformat: write parameter value\r\n");
tmulrooney 1:96c429800568 532 }
tmulrooney 1:96c429800568 533 break;
tmulrooney 1:96c429800568 534 #endif
tmulrooney 1:96c429800568 535 #if 0
tmulrooney 1:96c429800568 536 case INFO:
tmulrooney 1:96c429800568 537 num = sscanf(&line[ptrCmd],"%s",str); /* expecting one parameter on the command line - parameter name */
tmulrooney 1:96c429800568 538 if(num == 1)
tmulrooney 1:96c429800568 539 {
tmulrooney 1:96c429800568 540 num = getParameter(str); /* get paramter position in parameters array from paramter name */
tmulrooney 1:96c429800568 541 if (num >= 0)
tmulrooney 1:96c429800568 542 {
tmulrooney 1:96c429800568 543 // type = readParam(num);
tmulrooney 1:96c429800568 544 displayParameter(num);
tmulrooney 1:96c429800568 545 }
tmulrooney 1:96c429800568 546 else
tmulrooney 1:96c429800568 547 {
tmulrooney 1:96c429800568 548 UART_1_PutString("Invalid parameter\r\nType help for list of valid parameters\r\n");
tmulrooney 1:96c429800568 549 }
tmulrooney 1:96c429800568 550 }
tmulrooney 1:96c429800568 551 else
tmulrooney 1:96c429800568 552 {
tmulrooney 1:96c429800568 553 // for(i=0;strcmpi(parameters[i].name,"end") != 0;i++)
tmulrooney 1:96c429800568 554 for(i=0;strcasecmp(parameters[i].name,"end") != 0;i++)
tmulrooney 1:96c429800568 555 displayParameter(i);
tmulrooney 1:96c429800568 556 }
tmulrooney 1:96c429800568 557 break;
tmulrooney 1:96c429800568 558
tmulrooney 1:96c429800568 559 case FIND:
tmulrooney 1:96c429800568 560 num = sscanf(&line[ptrCmd],"%s",str); /* expecting one parameter on the command line - parameter name */
tmulrooney 1:96c429800568 561 if(num == 1)
tmulrooney 1:96c429800568 562 {
tmulrooney 1:96c429800568 563 num = findParameter(str); /* get paramter position in parameters array from paramter name */
tmulrooney 1:96c429800568 564 if (num < 0)
tmulrooney 1:96c429800568 565 {
tmulrooney 1:96c429800568 566 sprintf(TransmitBuffer,"String %s not found in any parameter name\r\n",str);
tmulrooney 1:96c429800568 567 UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 568 }
tmulrooney 1:96c429800568 569 }
tmulrooney 1:96c429800568 570 else
tmulrooney 1:96c429800568 571 {
tmulrooney 1:96c429800568 572 UART_1_PutString("\r\nValid Paramters\r\n");
tmulrooney 1:96c429800568 573
tmulrooney 1:96c429800568 574 /* print parameter list */
tmulrooney 1:96c429800568 575 // for(i=0;strcmpi(parameters[i].name,"end") != 0;i++)
tmulrooney 1:96c429800568 576 for(i=0;strcasecmp(parameters[i].name,"end") != 0;i++)
tmulrooney 1:96c429800568 577 {
tmulrooney 1:96c429800568 578 sprintf(TransmitBuffer,"%s\r\n",parameters[i].name);
tmulrooney 1:96c429800568 579 UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 580 }
tmulrooney 1:96c429800568 581 }
tmulrooney 1:96c429800568 582 break;
tmulrooney 1:96c429800568 583
tmulrooney 1:96c429800568 584 case RUN:
tmulrooney 1:96c429800568 585 if(runStatus == TRUE)
tmulrooney 1:96c429800568 586 {
tmulrooney 1:96c429800568 587 sprintf(TransmitBuffer,"%s Control already Running\r\n",time_string);
tmulrooney 1:96c429800568 588 UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 589 }
tmulrooney 1:96c429800568 590 else
tmulrooney 1:96c429800568 591 {
tmulrooney 1:96c429800568 592 runStatus = TRUE;
tmulrooney 1:96c429800568 593 lampTestStatus = LAMPTESTNOTRUN;
tmulrooney 1:96c429800568 594 sprintf(TransmitBuffer,"%s Control Running\r\n",time_string);
tmulrooney 1:96c429800568 595 UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 596 }
tmulrooney 1:96c429800568 597 break;
tmulrooney 1:96c429800568 598
tmulrooney 1:96c429800568 599 case STOP:
tmulrooney 1:96c429800568 600 if(runStatus == FALSE)
tmulrooney 1:96c429800568 601 {
tmulrooney 1:96c429800568 602 sprintf(TransmitBuffer,"%s Control already Stopped\r\n",time_string);
tmulrooney 1:96c429800568 603 UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 604 }
tmulrooney 1:96c429800568 605 else
tmulrooney 1:96c429800568 606 {
tmulrooney 1:96c429800568 607 runStatus = FALSE;
tmulrooney 1:96c429800568 608 sprintf(TransmitBuffer,"%s Control Stopped\r\n",time_string);
tmulrooney 1:96c429800568 609 UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 610 phaseUV = (PHASE_AB_UV_Read() << 0);
tmulrooney 1:96c429800568 611 phaseUV |= (PHASE_AC_UV_Read() << 1);
tmulrooney 1:96c429800568 612 phaseUV |= (PHASE_BC_UV_Read() << 2);
tmulrooney 1:96c429800568 613 statusRegister = STATUS_REGISTER1_ReadMask();
tmulrooney 1:96c429800568 614 statusRegister |= (PHASEABUVIN | PHASEBCUVIN | PHASEACUVIN);
tmulrooney 1:96c429800568 615 STATUS_REGISTER1_INT_ClearPending();
tmulrooney 1:96c429800568 616 STATUS_REGISTER1_WriteMask(statusRegister);
tmulrooney 1:96c429800568 617 HVState = HVSTATEOFF;
tmulrooney 1:96c429800568 618 eStopSeen = FALSE;
tmulrooney 1:96c429800568 619 outputOCSeen = FALSE;
tmulrooney 1:96c429800568 620 HVStateMsg = 0; /* no messages printed yet */
tmulrooney 1:96c429800568 621 flashCtrlSys = 0;
tmulrooney 1:96c429800568 622 tempFailed = FALSE;
tmulrooney 1:96c429800568 623 pendantTestStatus = 0;
tmulrooney 1:96c429800568 624 pendantPresent = FALSE;
tmulrooney 1:96c429800568 625 waitForPowerCycle = FALSE;
tmulrooney 1:96c429800568 626 PEND_PRESENT_NOT_INT_Stop();
tmulrooney 1:96c429800568 627 SOFT_START_RELAY_CTRL_Write(0);
tmulrooney 1:96c429800568 628 PWM_DC_Stop();
tmulrooney 1:96c429800568 629 statusRegister = STATUS_REGISTER1_ReadMask();
tmulrooney 1:96c429800568 630 statusRegister &= ~(BRIDGEOCFLAGIN | OUTPUTOCFLAGIN | UTILOCFLAGIN );
tmulrooney 1:96c429800568 631 STATUS_REGISTER1_WriteMask(statusRegister);
tmulrooney 1:96c429800568 632 ENCODER_COUNTER_Stop();
tmulrooney 1:96c429800568 633 initializeAllParameters();
tmulrooney 1:96c429800568 634 writeCurrent0(0.0); /* test prurposes only */
tmulrooney 1:96c429800568 635 }
tmulrooney 1:96c429800568 636 break;
tmulrooney 1:96c429800568 637
tmulrooney 1:96c429800568 638 case HVSTATE:
tmulrooney 1:96c429800568 639 sprintf(TransmitBuffer,"%s HV State: %02X\r\n",time_string,HVState);
tmulrooney 1:96c429800568 640 UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 641 printHVState();
tmulrooney 1:96c429800568 642 break;
tmulrooney 1:96c429800568 643 #endif
tmulrooney 1:96c429800568 644
tmulrooney 1:96c429800568 645 default:
tmulrooney 1:96c429800568 646 if(strlen(line) !=0)
tmulrooney 1:96c429800568 647 {
tmulrooney 1:96c429800568 648 sprintf(TransmitBuffer,"Unknown cmd: %s\r\nType help for list of valid commands\r\n",line);
tmulrooney 1:96c429800568 649 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 650 // linesInBuffer--;
tmulrooney 1:96c429800568 651 // indexNextLineIn--;
tmulrooney 1:96c429800568 652 // if(linesInBuffer == NUM_LINES)
tmulrooney 1:96c429800568 653 // indexNextLineIn = NUM_LINES -1;
tmulrooney 1:96c429800568 654 }
tmulrooney 1:96c429800568 655 break;
tmulrooney 1:96c429800568 656 }
tmulrooney 1:96c429800568 657 for(i=0;i < sizeof(line);i++)
tmulrooney 1:96c429800568 658 line[i] = '\0';
tmulrooney 1:96c429800568 659 }
tmulrooney 1:96c429800568 660
tmulrooney 1:96c429800568 661 /**
tmulrooney 1:96c429800568 662 * \fn getCmd
tmulrooney 1:96c429800568 663 *
tmulrooney 1:96c429800568 664 * \brief parses command line to find position of command in validCmds array.
tmulrooney 1:96c429800568 665 *
tmulrooney 1:96c429800568 666 * copies line array into cmd array until a space or end of line then
tmulrooney 1:96c429800568 667 * searches cmd array for a match in validCmds array.
tmulrooney 1:96c429800568 668 * \return int8 - position of command in command array if found. -1 if not found<p>
tmulrooney 1:96c429800568 669 *
tmulrooney 1:96c429800568 670 */
tmulrooney 1:96c429800568 671 int8 getCmd()
tmulrooney 1:96c429800568 672 {
tmulrooney 1:96c429800568 673 uint i;
tmulrooney 1:96c429800568 674 char cmd[40];
tmulrooney 1:96c429800568 675
tmulrooney 1:96c429800568 676 for(i=0;i<strlen(line);i++)
tmulrooney 1:96c429800568 677 {
tmulrooney 1:96c429800568 678 if(line[i] == ' ')
tmulrooney 1:96c429800568 679 {
tmulrooney 1:96c429800568 680 break;
tmulrooney 1:96c429800568 681 }
tmulrooney 1:96c429800568 682 cmd[i] = line[i];
tmulrooney 1:96c429800568 683 }
tmulrooney 1:96c429800568 684 cmd[i] = '\0';
tmulrooney 1:96c429800568 685 ptrCmd = strlen(cmd) + 1;
tmulrooney 1:96c429800568 686 // sprintf(TransmitBuffer,"cmd: %d %s\r\n",strlen(cmd),cmd);
tmulrooney 1:96c429800568 687 // UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 688
tmulrooney 1:96c429800568 689 for(i=0;i< sizeof(validCmds)/sizeof(validCmds[0]);i++)
tmulrooney 1:96c429800568 690 {
tmulrooney 1:96c429800568 691 // if(strcmpi(validCmds[i],cmd) == 0)
tmulrooney 1:96c429800568 692 if(strcasecmp(validCmds[i],cmd) == 0)
tmulrooney 1:96c429800568 693 {
tmulrooney 1:96c429800568 694 return i;
tmulrooney 1:96c429800568 695 }
tmulrooney 1:96c429800568 696 }
tmulrooney 1:96c429800568 697 return -1;
tmulrooney 1:96c429800568 698 }
tmulrooney 1:96c429800568 699
tmulrooney 1:96c429800568 700 /**
tmulrooney 1:96c429800568 701 * \fn int8 getParameter(char *param)
tmulrooney 1:96c429800568 702 *
tmulrooney 1:96c429800568 703 * \brief searches parameters array to find position of command in parameters array.
tmulrooney 1:96c429800568 704 *
tmulrooney 1:96c429800568 705 * searches the entire parameters array for a name match with param.
tmulrooney 1:96c429800568 706 *
tmulrooney 1:96c429800568 707 * \param[in] param - pointer to an array containing the parameter name.
tmulrooney 1:96c429800568 708 *
tmulrooney 1:96c429800568 709 * \return int8 - position of command in command array if found. -1 if not found<p>
tmulrooney 1:96c429800568 710 *
tmulrooney 1:96c429800568 711 */
tmulrooney 1:96c429800568 712 int8 getParameter(char *param)
tmulrooney 1:96c429800568 713 {
tmulrooney 1:96c429800568 714 uint i;
tmulrooney 1:96c429800568 715
tmulrooney 1:96c429800568 716 // sprintf(TransmitBuffer,"param: %d %s\r\n",strlen(param),param);
tmulrooney 1:96c429800568 717 // pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 718
tmulrooney 1:96c429800568 719 for(i=0;strcasecmp(parameters[i].name,"end") != 0;i++)
tmulrooney 1:96c429800568 720 {
tmulrooney 1:96c429800568 721 if(strcasecmp(parameters[i].name,param) == 0)
tmulrooney 1:96c429800568 722 {
tmulrooney 1:96c429800568 723 return i;
tmulrooney 1:96c429800568 724 }
tmulrooney 1:96c429800568 725 }
tmulrooney 1:96c429800568 726 return -1;
tmulrooney 1:96c429800568 727 }
tmulrooney 1:96c429800568 728
tmulrooney 1:96c429800568 729 /**
tmulrooney 1:96c429800568 730 * \fn int8 findParameter(char *string)
tmulrooney 1:96c429800568 731 *
tmulrooney 1:96c429800568 732 * \brief finds all parameters with string in the name.
tmulrooney 1:96c429800568 733 *
tmulrooney 1:96c429800568 734 * searches the entire parameters array for all names
tmulrooney 1:96c429800568 735 * that contain string.
tmulrooney 1:96c429800568 736 *
tmulrooney 1:96c429800568 737 * \param[in] string - pointer to a string.
tmulrooney 1:96c429800568 738 *
tmulrooney 1:96c429800568 739 * \return int8 - 0 string found in some names. -1 if string not found in any name<p>
tmulrooney 1:96c429800568 740 *
tmulrooney 1:96c429800568 741 */
tmulrooney 1:96c429800568 742 int8 findParameter(char *string)
tmulrooney 1:96c429800568 743 {
tmulrooney 1:96c429800568 744 uint i,j;
tmulrooney 1:96c429800568 745 int8 result = -1;
tmulrooney 1:96c429800568 746 char name[40];
tmulrooney 1:96c429800568 747 char string1[40];
tmulrooney 1:96c429800568 748
tmulrooney 1:96c429800568 749 // sprintf(TransmitBuffer,"param: %d %s\r\n",strlen(param),param);
tmulrooney 1:96c429800568 750 // UART_1_PutString(TransmitBuffer);
tmulrooney 1:96c429800568 751
tmulrooney 1:96c429800568 752 strcpy(string1,string);
tmulrooney 1:96c429800568 753 for(i=0;i < strlen(string1);i++)
tmulrooney 1:96c429800568 754 string1[i] = tolower((unsigned char)string1[i]);
tmulrooney 1:96c429800568 755
tmulrooney 1:96c429800568 756 // for(i=0;strcmpi(parameters[i].name,"end") != 0;i++)
tmulrooney 1:96c429800568 757 for(i=0;strcasecmp(parameters[i].name,"end") != 0;i++)
tmulrooney 1:96c429800568 758 {
tmulrooney 1:96c429800568 759 strcpy(name,parameters[i].name); /* copy parameter name and convert to lower case */
tmulrooney 1:96c429800568 760 for(j=0;j < strlen(name);j++)
tmulrooney 1:96c429800568 761 name[j] = tolower((unsigned char)name[j]);
tmulrooney 1:96c429800568 762 if(strstr(name,string1) != NULL)
tmulrooney 1:96c429800568 763 {
tmulrooney 1:96c429800568 764 sprintf(TransmitBuffer,"%s\r\n",parameters[i].name);
tmulrooney 1:96c429800568 765 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 766 result = 0;
tmulrooney 1:96c429800568 767 }
tmulrooney 1:96c429800568 768 }
tmulrooney 1:96c429800568 769 return result;
tmulrooney 1:96c429800568 770 }
tmulrooney 1:96c429800568 771
tmulrooney 1:96c429800568 772 /**
tmulrooney 1:96c429800568 773 * \fn uint8 readParam(uint8 paramNum)
tmulrooney 1:96c429800568 774 *
tmulrooney 1:96c429800568 775 * \brief reads in parameter at position paramNum.
tmulrooney 1:96c429800568 776 *
tmulrooney 1:96c429800568 777 * This will only be called if there was a valid parameter match found.
tmulrooney 1:96c429800568 778 * will read correct parameter based on parameter type. This will call the
tmulrooney 1:96c429800568 779 * correct read function specified in the paramter array. A parameter will be
tmulrooney 1:96c429800568 780 * read into one of binaryParameter, digitalParameter, or analogParameter based on type.
tmulrooney 1:96c429800568 781 *
tmulrooney 1:96c429800568 782 * \param[in] paramNum - pointer to a character string containing parameter name
tmulrooney 1:96c429800568 783 * \return uint8 - type of parameter<p>
tmulrooney 1:96c429800568 784 *
tmulrooney 1:96c429800568 785 */
tmulrooney 1:96c429800568 786 uint8 readParam(uint8 paramNum)
tmulrooney 1:96c429800568 787 {
tmulrooney 1:96c429800568 788 uint8 type = parameters[paramNum].type;
tmulrooney 1:96c429800568 789
tmulrooney 1:96c429800568 790 if(type == BINARY)
tmulrooney 1:96c429800568 791 {
tmulrooney 1:96c429800568 792 if(parameters[paramNum].ptrRead == NULL)
tmulrooney 1:96c429800568 793 {
tmulrooney 1:96c429800568 794 sprintf(TransmitBuffer,"%s has a NULL ptrRead parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 795 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 796 binaryParameter = 0;
tmulrooney 1:96c429800568 797 }
tmulrooney 1:96c429800568 798 else
tmulrooney 1:96c429800568 799 binaryParameter = parameters[paramNum].ptrRead();
tmulrooney 1:96c429800568 800 return type;
tmulrooney 1:96c429800568 801 }
tmulrooney 1:96c429800568 802 if(type == ANALOG)
tmulrooney 1:96c429800568 803 {
tmulrooney 1:96c429800568 804 if(parameters[paramNum].ptrRead == NULL)
tmulrooney 1:96c429800568 805 {
tmulrooney 1:96c429800568 806 sprintf(TransmitBuffer,"%s has a NULL ptrRead parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 807 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 808 analogParameter = 0.0;
tmulrooney 1:96c429800568 809 }
tmulrooney 1:96c429800568 810 else
tmulrooney 1:96c429800568 811 parameters[paramNum].ptrRead();
tmulrooney 1:96c429800568 812 return type;
tmulrooney 1:96c429800568 813 }
tmulrooney 1:96c429800568 814 if(type == DIGITAL)
tmulrooney 1:96c429800568 815 {
tmulrooney 1:96c429800568 816 if(parameters[paramNum].ptrRead == NULL)
tmulrooney 1:96c429800568 817 {
tmulrooney 1:96c429800568 818 sprintf(TransmitBuffer,"%s has a NULL ptrRead parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 819 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 820 digitalParameter = 0;
tmulrooney 1:96c429800568 821 }
tmulrooney 1:96c429800568 822 else
tmulrooney 1:96c429800568 823 parameters[paramNum].ptrRead();
tmulrooney 1:96c429800568 824 return type;
tmulrooney 1:96c429800568 825 }
tmulrooney 1:96c429800568 826 if(type == REGISTER)
tmulrooney 1:96c429800568 827 {
tmulrooney 1:96c429800568 828 bytesRead = 0;
tmulrooney 1:96c429800568 829 if(parameters[paramNum].ptrReadRegLength == NULL)
tmulrooney 1:96c429800568 830 {
tmulrooney 1:96c429800568 831 sprintf(TransmitBuffer,"%s has a NULL ptrReadRegLength parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 832 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 833 digitalParameter = 0;
tmulrooney 1:96c429800568 834 }
tmulrooney 1:96c429800568 835 else
tmulrooney 1:96c429800568 836 bytesRead = parameters[paramNum].ptrReadRegLength(regAddress, regData, regLength);
tmulrooney 1:96c429800568 837 return type;
tmulrooney 1:96c429800568 838 }
tmulrooney 1:96c429800568 839 return type;
tmulrooney 1:96c429800568 840 }
tmulrooney 1:96c429800568 841
tmulrooney 1:96c429800568 842 /**
tmulrooney 1:96c429800568 843 * \fn void writeParam(uint8 paramNum,uint16 value, float floatValue)
tmulrooney 1:96c429800568 844 *
tmulrooney 1:96c429800568 845 * \brief reads in parameter at position paramNum.
tmulrooney 1:96c429800568 846 *
tmulrooney 1:96c429800568 847 * This will only be called if there was a valid parameter match found.
tmulrooney 1:96c429800568 848 * will write value to the correct parameter based on parameter type. This will call the
tmulrooney 1:96c429800568 849 * correct write function specified in the paramter array. value will not be written
tmulrooney 1:96c429800568 850 * to read only paramters.
tmulrooney 1:96c429800568 851 *
tmulrooney 1:96c429800568 852 * \param[in] paramNum - pointer to a character string containing the parameter name
tmulrooney 1:96c429800568 853 * \param[in] value - 16 bit value to write to a digital parameter.
tmulrooney 1:96c429800568 854 * \param[in] floatValue - analog value to write to an anlog parameter.
tmulrooney 1:96c429800568 855 * \return uint8 - type of parameter<p>
tmulrooney 1:96c429800568 856 *
tmulrooney 1:96c429800568 857 */
tmulrooney 1:96c429800568 858 void writeParam(uint8 paramNum,uint8 *value)
tmulrooney 1:96c429800568 859 {
tmulrooney 1:96c429800568 860 uint8 type = parameters[paramNum].type;
tmulrooney 1:96c429800568 861 if(parameters[paramNum].mode == READONLY)
tmulrooney 1:96c429800568 862 {
tmulrooney 1:96c429800568 863 sprintf(TransmitBuffer,"%s is a read only parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 864 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 865 return;
tmulrooney 1:96c429800568 866 }
tmulrooney 1:96c429800568 867 #if 0
tmulrooney 1:96c429800568 868 if(type == BINARY)
tmulrooney 1:96c429800568 869 {
tmulrooney 1:96c429800568 870 if(parameters[paramNum].ptrWrite8 == NULL)
tmulrooney 1:96c429800568 871 {
tmulrooney 1:96c429800568 872 sprintf(TransmitBuffer,"%s has a NULL pteWrite8 parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 873 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 874 }
tmulrooney 1:96c429800568 875 else
tmulrooney 1:96c429800568 876 parameters[paramNum].ptrWrite8(value);
tmulrooney 1:96c429800568 877 }
tmulrooney 1:96c429800568 878 else if(type == DIGITAL)
tmulrooney 1:96c429800568 879 {
tmulrooney 1:96c429800568 880 if(parameters[paramNum].ptrWrite16 == NULL)
tmulrooney 1:96c429800568 881 {
tmulrooney 1:96c429800568 882 sprintf(TransmitBuffer,"%s has a NULL pteWrite16 parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 883 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 884 }
tmulrooney 1:96c429800568 885 else
tmulrooney 1:96c429800568 886 parameters[paramNum].ptrWrite16(value);
tmulrooney 1:96c429800568 887 }
tmulrooney 1:96c429800568 888 #endif
tmulrooney 1:96c429800568 889 else if(type == REGISTER)
tmulrooney 1:96c429800568 890 {
tmulrooney 1:96c429800568 891 if(parameters[paramNum].ptrWriteReg8 == NULL)
tmulrooney 1:96c429800568 892 {
tmulrooney 1:96c429800568 893 sprintf(TransmitBuffer,"%s has a NULL ptrWriteReg8 parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 894 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 895 }
tmulrooney 1:96c429800568 896 else
tmulrooney 1:96c429800568 897 parameters[paramNum].ptrWriteReg8(regAddress, value);
tmulrooney 1:96c429800568 898 }
tmulrooney 1:96c429800568 899 #if 0
tmulrooney 1:96c429800568 900 else if(type == ANALOG)
tmulrooney 1:96c429800568 901 {
tmulrooney 1:96c429800568 902 if(parameters[paramNum].ptrWriteAnalog == NULL)
tmulrooney 1:96c429800568 903 {
tmulrooney 1:96c429800568 904 sprintf(TransmitBuffer,"%s has a NULL pteWriteAnalog parameter\r\n",parameters[paramNum].name);
tmulrooney 1:96c429800568 905 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 906 }
tmulrooney 1:96c429800568 907 else
tmulrooney 1:96c429800568 908 parameters[paramNum].ptrWriteAnalog(floatValue);
tmulrooney 1:96c429800568 909 }
tmulrooney 1:96c429800568 910 #endif
tmulrooney 1:96c429800568 911 return;
tmulrooney 1:96c429800568 912 }
tmulrooney 1:96c429800568 913
tmulrooney 1:96c429800568 914 /**
tmulrooney 1:96c429800568 915 * \fn void displayParameter(uint8 num)
tmulrooney 1:96c429800568 916 *
tmulrooney 1:96c429800568 917 * \brief displays information about a parameter
tmulrooney 1:96c429800568 918 *
tmulrooney 1:96c429800568 919 * This routine all of the information in the parameters array
tmulrooney 1:96c429800568 920 * for the selected parameter.
tmulrooney 1:96c429800568 921 *
tmulrooney 1:96c429800568 922 * \param[in] num - 8 bit integer location in the parameters array
tmulrooney 1:96c429800568 923 * \return uint16 - 16 bit num to the power pow<p>
tmulrooney 1:96c429800568 924 *
tmulrooney 1:96c429800568 925 */
tmulrooney 1:96c429800568 926 void displayParameter(uint8 num)
tmulrooney 1:96c429800568 927 {
tmulrooney 1:96c429800568 928 char *strType;
tmulrooney 1:96c429800568 929 char *strMode;
tmulrooney 1:96c429800568 930 uint16 convertFloat1,convertFloat2,convertFloat3;
tmulrooney 1:96c429800568 931
tmulrooney 1:96c429800568 932 switch (parameters[num].type)
tmulrooney 1:96c429800568 933 {
tmulrooney 1:96c429800568 934 case BINARY:
tmulrooney 1:96c429800568 935 strType = "Binary";
tmulrooney 1:96c429800568 936 break;
tmulrooney 1:96c429800568 937
tmulrooney 1:96c429800568 938 case DIGITAL:
tmulrooney 1:96c429800568 939 strType = "16 Bit";
tmulrooney 1:96c429800568 940 break;
tmulrooney 1:96c429800568 941
tmulrooney 1:96c429800568 942 case ANALOG:
tmulrooney 1:96c429800568 943 strType = "Analog";
tmulrooney 1:96c429800568 944 break;
tmulrooney 1:96c429800568 945
tmulrooney 1:96c429800568 946 default:
tmulrooney 1:96c429800568 947 strType = "Unknown";
tmulrooney 1:96c429800568 948 break;
tmulrooney 1:96c429800568 949 }
tmulrooney 1:96c429800568 950
tmulrooney 1:96c429800568 951 switch (parameters[num].mode)
tmulrooney 1:96c429800568 952 {
tmulrooney 1:96c429800568 953 case READONLY:
tmulrooney 1:96c429800568 954 strMode = "Read Only";
tmulrooney 1:96c429800568 955 break;
tmulrooney 1:96c429800568 956
tmulrooney 1:96c429800568 957 case READWRITE:
tmulrooney 1:96c429800568 958 strMode = "Read/Write";
tmulrooney 1:96c429800568 959 break;
tmulrooney 1:96c429800568 960
tmulrooney 1:96c429800568 961 case WRITEONLY:
tmulrooney 1:96c429800568 962 strMode = "Write Only";
tmulrooney 1:96c429800568 963 break;
tmulrooney 1:96c429800568 964
tmulrooney 1:96c429800568 965 default:
tmulrooney 1:96c429800568 966 strMode = "Unknown";
tmulrooney 1:96c429800568 967 break;
tmulrooney 1:96c429800568 968 }
tmulrooney 1:96c429800568 969
tmulrooney 1:96c429800568 970 sprintf(TransmitBuffer,"Name:\t'%s' Port: '%s' Connector: '%s' Units: '%s'\r\n",parameters[num].name,parameters[num].port,parameters[num].connector,parameters[num].uints);
tmulrooney 1:96c429800568 971 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 972 sprintf(TransmitBuffer,"\tDescription: '%s'\r\n",parameters[num].description);
tmulrooney 1:96c429800568 973 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 974
tmulrooney 1:96c429800568 975 if(parameters[num].type != ANALOG)
tmulrooney 1:96c429800568 976 {
tmulrooney 1:96c429800568 977 sprintf(TransmitBuffer,"\tType: '%s' mode: '%s' Initial: %d Min: %d Max: %d\r\n",strType,strMode,parameters[num].initialInt,parameters[num].minInt,parameters[num].maxInt);
tmulrooney 1:96c429800568 978 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 979 }
tmulrooney 1:96c429800568 980 else
tmulrooney 1:96c429800568 981 {
tmulrooney 1:96c429800568 982 convertFloat1 = parameters[num].initialFloat * 100;
tmulrooney 1:96c429800568 983 convertFloat2 = parameters[num].minFloat * 100;
tmulrooney 1:96c429800568 984 convertFloat3 = parameters[num].maxFloat * 100;
tmulrooney 1:96c429800568 985 sprintf(TransmitBuffer,"\tType: '%s' mode: '%s' Initial: %d.%02d Min: %d.%02d Max: %d.%02d\r\n",strType,strMode,convertFloat1/100,convertFloat1%100,convertFloat2/100,convertFloat2%100,convertFloat3/100,convertFloat3%100);
tmulrooney 1:96c429800568 986 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 987 }
tmulrooney 1:96c429800568 988 }
tmulrooney 1:96c429800568 989
tmulrooney 1:96c429800568 990 uint16 readSPIReg(uint16 regAddress, uint8 *regData, uint16 length)
tmulrooney 1:96c429800568 991 {
tmulrooney 1:96c429800568 992
tmulrooney 1:96c429800568 993 // sprintf(TransmitBuffer,"read SPI %02X %04X\r\n",regAddress, length);
tmulrooney 1:96c429800568 994 // pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 995 if(length > MAX_REGISTER_DATA)
tmulrooney 1:96c429800568 996 {
tmulrooney 1:96c429800568 997 sprintf(TransmitBuffer,"Length 0x%X > 0x%X",length,MAX_REGISTER_DATA);
tmulrooney 1:96c429800568 998 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 999 return 0;
tmulrooney 1:96c429800568 1000 }
tmulrooney 1:96c429800568 1001 SPIRead(regAddress,regData,length);
tmulrooney 1:96c429800568 1002 return(length);
tmulrooney 1:96c429800568 1003 }
tmulrooney 1:96c429800568 1004
tmulrooney 1:96c429800568 1005 void writeSPIReg(uint16 regAddress, uint8 *regData)
tmulrooney 1:96c429800568 1006 {
tmulrooney 1:96c429800568 1007 sprintf(TransmitBuffer,"write SPI %02X %02X\r\n",regAddress, regData[0]);
tmulrooney 1:96c429800568 1008 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 1009 SPIWrite(regAddress, regData,1);
tmulrooney 1:96c429800568 1010 return;
tmulrooney 1:96c429800568 1011 }
tmulrooney 1:96c429800568 1012
tmulrooney 1:96c429800568 1013 uint16 readI2CReg(uint16 regAddress, uint8 *regData, uint16 length)
tmulrooney 1:96c429800568 1014 {
tmulrooney 1:96c429800568 1015
tmulrooney 1:96c429800568 1016 // sprintf(TransmitBuffer,"read I2C %02X %04X\r\n",regAddress, length);
tmulrooney 1:96c429800568 1017 // pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 1018 if(length > MAX_REGISTER_DATA)
tmulrooney 1:96c429800568 1019 {
tmulrooney 1:96c429800568 1020 sprintf(TransmitBuffer,"Length 0x%X > 0x%X",length,MAX_REGISTER_DATA);
tmulrooney 1:96c429800568 1021 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 1022 return 0;
tmulrooney 1:96c429800568 1023 }
tmulrooney 1:96c429800568 1024 I2CRead(regAddress,regData,length);
tmulrooney 1:96c429800568 1025 return(length);
tmulrooney 1:96c429800568 1026 }
tmulrooney 1:96c429800568 1027
tmulrooney 1:96c429800568 1028
tmulrooney 1:96c429800568 1029 void writeI2CReg(uint16 regAddress, uint8 *regData)
tmulrooney 1:96c429800568 1030 {
tmulrooney 1:96c429800568 1031 sprintf(TransmitBuffer,"write I2C %02X %02X\r\n",regAddress, regData[0]);
tmulrooney 1:96c429800568 1032 pc.printf(TransmitBuffer);
tmulrooney 1:96c429800568 1033 I2CWrite(regAddress, regData,1);
tmulrooney 1:96c429800568 1034 return;
tmulrooney 1:96c429800568 1035 }
tmulrooney 1:96c429800568 1036
tmulrooney 1:96c429800568 1037 /* [] END OF FILE */