| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
#include "Command.h" |
| 46 |
#include "Console.h" |
| 47 |
#include "ad525x.h" |
| 48 |
#include "TIME.h" |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
const struct cmd_info cmdList[] = { |
| 54 |
[0] = { |
| 55 |
.name = "help?", |
| 56 |
.description = "Displays all available commands.", |
| 57 |
.acceptedValue = "None", |
| 58 |
.example = "", |
| 59 |
}, |
| 60 |
[1] = { |
| 61 |
.name = "rdac=", |
| 62 |
.description = "Load the wiper register with a given value.", |
| 63 |
.acceptedValue = "Accepted value:\r\n\ |
| 64 |
\tchannel:\r\n\ |
| 65 |
\t0 to 3 in function of the device type\r\n\ |
| 66 |
\tvalue:\r\n\ |
| 67 |
\t0 .. 255 or 0 .. 1024 - wiper register value", |
| 68 |
.example = "To load the wiper register of channel B with 128, \ |
| 69 |
type: rdac=1 128", |
| 70 |
}, |
| 71 |
[2] = { |
| 72 |
.name = "rdac?", |
| 73 |
.description = "Read back the value of the wiper register.", |
| 74 |
.acceptedValue = "Accepted values:\r\n\ |
| 75 |
\tchannel:\r\n\ |
| 76 |
\t0 .. 3 in function of the device type", |
| 77 |
.example = "To read back the value of the wiper register of channel B, \ |
| 78 |
type: rdac?1", |
| 79 |
}, |
| 80 |
[3] = { |
| 81 |
.name = "reset!", |
| 82 |
.description = "Reset all wiper register to its stored values", |
| 83 |
.acceptedValue = "None", |
| 84 |
.example = "", |
| 85 |
}, |
| 86 |
[4] = { |
| 87 |
.name = "restore=", |
| 88 |
.description = "Restore the specified wiper register setting form the \ |
| 89 |
memory", |
| 90 |
.acceptedValue = "Accepted value:\r\n\ |
| 91 |
\tchannel:\r\n\ |
| 92 |
\t0 to 3 in function of the device type", |
| 93 |
.example = "To restore the wiper register of channel B, \ |
| 94 |
type: restore=1", |
| 95 |
}, |
| 96 |
[5] = { |
| 97 |
.name = "save=", |
| 98 |
.description = "Save the given wiper register settings to the memory", |
| 99 |
.acceptedValue = "Accepted value:\r\n\ |
| 100 |
\tchannel:\r\n\ |
| 101 |
\t0 to 3 in function of the device type", |
| 102 |
.example = "To save the wiper register of channel B, \ |
| 103 |
type: save=1", |
| 104 |
}, |
| 105 |
[6] = { |
| 106 |
.name = "writemem=", |
| 107 |
.description = "Write to one of the user memory address", |
| 108 |
.acceptedValue = "Accepted value:\r\n\ |
| 109 |
\taddress:\r\n\ |
| 110 |
\t0x0 to 0xF (may vary at some devices)\r\n\ |
| 111 |
\tdata:\r\n\ |
| 112 |
\t0 .. 255 or 0 .. 1023 in function of the position number of the current device.", |
| 113 |
.example = "To write 127 to address 0x8 into the EEMEM memory, type: \ |
| 114 |
writemem=0x8 127", |
| 115 |
}, |
| 116 |
[7] = { |
| 117 |
.name = "readmem=", |
| 118 |
.description = "Read data from the EEMEM memory.", |
| 119 |
.acceptedValue = "Accepted value:\r\n\ |
| 120 |
\taddress:\r\n\ |
| 121 |
\t0x0 to 0xF (may vary at some devices)", |
| 122 |
.example = "To read the 0x8 address from the EEMEM memory, type: \ |
| 123 |
readmem=0x8", |
| 124 |
}, |
| 125 |
[8] = { |
| 126 |
.name = "decrdacdb=", |
| 127 |
.description = "Decrement a given wiper register by 6dB.", |
| 128 |
.acceptedValue = "Accepted value:\r\n\ |
| 129 |
\tchannel:\r\n\ |
| 130 |
\t0 to 3 in function of the device type", |
| 131 |
.example = "To decrement the wiper register of channel A by 6dB, \ |
| 132 |
type: decrdacdb=0", |
| 133 |
}, |
| 134 |
[9] = { |
| 135 |
.name = "decrdacdball!", |
| 136 |
.description = "Decrement all wiper register by 6dB.", |
| 137 |
.acceptedValue = "None", |
| 138 |
.example = "To decrement all the wiper register by 6dB, \ |
| 139 |
type: decrdacdball!", |
| 140 |
}, |
| 141 |
[10] = { |
| 142 |
.name = "decrdac=", |
| 143 |
.description = "Decrement a given wiper register by one.", |
| 144 |
.acceptedValue = "Accepted value:\r\n\ |
| 145 |
\tchannel:\r\n\ |
| 146 |
\t0 to 3 in function of the device type", |
| 147 |
.example = "To decrement the wiper register of channel A by one, \ |
| 148 |
type: decrdac=0", |
| 149 |
}, |
| 150 |
[11] = { |
| 151 |
.name = "decrdacall!", |
| 152 |
.description = "Decrement all wiper register by one.", |
| 153 |
.acceptedValue = "None", |
| 154 |
.example = "To decrement all the wiper register by one, \ |
| 155 |
type: decrdacall!", |
| 156 |
}, |
| 157 |
[12] = { |
| 158 |
.name = "incrdacdb=", |
| 159 |
.description = "Increment a given wiper register by 6dB.", |
| 160 |
.acceptedValue = "Accepted value:\r\n\ |
| 161 |
\tchannel:\r\n\ |
| 162 |
\t0 to 3 in function of the device type", |
| 163 |
.example = "To increment the wiper register of channel A by 6dB, \ |
| 164 |
type: incrdacdb=0", |
| 165 |
}, |
| 166 |
[13] = { |
| 167 |
.name = "incrdacdball!", |
| 168 |
.description = "Increment all wiper register by 6dB.", |
| 169 |
.acceptedValue = "None", |
| 170 |
.example = "To increment all the wiper register by 6dB, \ |
| 171 |
type: incrdacdball!", |
| 172 |
}, |
| 173 |
[14] = { |
| 174 |
.name = "incrdac=", |
| 175 |
.description = "Increment a given wiper register by one.", |
| 176 |
.acceptedValue = "Accepted value:\r\n\ |
| 177 |
\tchannel:\r\n\ |
| 178 |
\t0 to 3 in function of the device type", |
| 179 |
.example = "To increment the wiper register of channel A by one, \ |
| 180 |
type: incrdacdb=0", |
| 181 |
}, |
| 182 |
[15] = { |
| 183 |
.name = "incrdacall!", |
| 184 |
.description = "Increment all wiper register by one.", |
| 185 |
.acceptedValue = "None", |
| 186 |
.example = "To increment all the wiper register by one, \ |
| 187 |
type: incrdacall!", |
| 188 |
}, |
| 189 |
[16] = { |
| 190 |
.name = "setwp=", |
| 191 |
.description = "Set the state of the Write Protect (WP) pin", |
| 192 |
.acceptedValue = "Accepted value:\r\n\ |
| 193 |
\tdesire state of the pin:\r\n\ |
| 194 |
\t0 - inactive\r\n\ |
| 195 |
\t1 - active", |
| 196 |
.example = "To activate the WP pin, type: setwp=1", |
| 197 |
}, |
| 198 |
[17] = { |
| 199 |
.name = "getwp?", |
| 200 |
.description = "Return the current value of the Write Protect (WP) pin", |
| 201 |
.acceptedValue = "None", |
| 202 |
.example = "", |
| 203 |
}, |
| 204 |
[18] = { |
| 205 |
.name = "sethwreset=", |
| 206 |
.description = "Set the state of the Hardware Override Preset (PR) pin", |
| 207 |
.acceptedValue = "Accepted value:\r\n\ |
| 208 |
\tdesire state of the pin:\r\n\ |
| 209 |
\t0 - inactive\r\n\ |
| 210 |
\t1 - active", |
| 211 |
.example = "To activate the hardware RESET pin, type: sethwreset=1", |
| 212 |
}, |
| 213 |
[19] = { |
| 214 |
.name = "gethwreset?", |
| 215 |
.description = "Return the current value of the Hardware Override \ |
| 216 |
Preset (PR) pin", |
| 217 |
.acceptedValue = "None", |
| 218 |
.example = "", |
| 219 |
}, |
| 220 |
[20] = { |
| 221 |
.name = "tolerance=", |
| 222 |
.description = "Read one of the Tolerance register.", |
| 223 |
.acceptedValue = "Accepted value:\r\n\ |
| 224 |
\tchannel:\r\n\ |
| 225 |
\t0 to 7 in function of the device type", |
| 226 |
.example = "To read the value of the first tolerance register, \ |
| 227 |
type: tolerance=0", |
| 228 |
} |
| 229 |
}; |
| 230 |
|
| 231 |
const char cmdNo = (sizeof(cmdList) / sizeof(struct cmd_info)); |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
cmdFunction cmdFunctions[21] = {GetHelp, SetRdac, GetRdac, DoReset, DoRestore, \ |
| 237 |
SaveSettings, WriteToMem, ReadFromMem, \ |
| 238 |
DecRdac6dB, DecAllRdac6dB, DecRdac, DecAllRdac,\ |
| 239 |
IncRdac6dB, IncAllRdac6dB, IncRdac, IncAllRdac, \ |
| 240 |
SetWrPin, GetWrPin, SetPrPin, GetPrPin, \ |
| 241 |
GetTolerance}; |
| 242 |
|
| 243 |
AD525X_type_t deviceType; |
| 244 |
|
| 245 |
unsigned char deviceSlaveId = 1; |
| 246 |
unsigned char channelNo = 0; |
| 247 |
unsigned short maxPosition = 0; |
| 248 |
|
| 249 |
unsigned char lowerAddressLimit = 0; |
| 250 |
unsigned char upperAddressLimit = 0; |
| 251 |
unsigned char nrToleranceReg = 0; |
| 252 |
|
| 253 |
unsigned char writeProtectBuff = 0; |
| 254 |
unsigned char overridePreset = 0; |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
void DisplayError(unsigned char funcNo) |
| 268 |
{ |
| 269 |
|
| 270 |
CONSOLE_Print("Invalid parameter!\r\n"); |
| 271 |
CONSOLE_Print("%s - %s %s\r\n", (char*)cmdList[funcNo].name, \ |
| 272 |
(char*)cmdList[funcNo].description, |
| 273 |
(char*)cmdList[funcNo].acceptedValue); |
| 274 |
CONSOLE_Print("Example: %s\r\n", (char*)cmdList[funcNo].example); |
| 275 |
} |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
void DisplayCmdList() |
| 283 |
{ |
| 284 |
unsigned char displayCmd; |
| 285 |
|
| 286 |
for(displayCmd = 0; displayCmd < cmdNo; displayCmd++) |
| 287 |
{ |
| 288 |
CONSOLE_Print("%s - %s\r\n", (char*)cmdList[displayCmd].name, \ |
| 289 |
(char*)cmdList[displayCmd].description); |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
void paramLimit(double* param, |
| 302 |
unsigned short lowerLimit, |
| 303 |
unsigned short upperLimit) |
| 304 |
{ |
| 305 |
if(*param < lowerLimit) |
| 306 |
{ |
| 307 |
*param = lowerLimit; |
| 308 |
} |
| 309 |
else |
| 310 |
{ |
| 311 |
if(*param > upperLimit) |
| 312 |
{ |
| 313 |
*param = upperLimit; |
| 314 |
} |
| 315 |
} |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
void GetHelp(double* param, char paramNo) |
| 324 |
{ |
| 325 |
unsigned char displayCmd; |
| 326 |
|
| 327 |
CONSOLE_Print("Available commands:\r\n"); |
| 328 |
for(displayCmd = 0; displayCmd < cmdNo; displayCmd++) |
| 329 |
{ |
| 330 |
CONSOLE_Print("%s - %s %s\r\n", (char*)cmdList[displayCmd].name, |
| 331 |
(char*)cmdList[displayCmd].description, |
| 332 |
(char*)cmdList[displayCmd].acceptedValue); |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
void DoDeviceLock(void) |
| 342 |
{ |
| 343 |
char device = 0; |
| 344 |
char deviceLocked = -1; |
| 345 |
|
| 346 |
while(deviceLocked < 0) |
| 347 |
{ |
| 348 |
CONSOLE_Print("Please specify your device.\r\n\ |
| 349 |
For AD5232 type: 0\r\n\ |
| 350 |
For AD5235 type: 1\r\n\ |
| 351 |
For AD5252 type: 2\r\n\ |
| 352 |
For AD5254 type: 3\r\n\ |
| 353 |
For ADN2850 type: 4\r\n"); |
| 354 |
|
| 355 |
CONSOLE_GetCommand(&device); |
| 356 |
if((device >= 0x30) && (device <= 0x34)) |
| 357 |
{ |
| 358 |
deviceLocked = 1; |
| 359 |
switch(device) |
| 360 |
{ |
| 361 |
case 0x30 : |
| 362 |
deviceType = ID_AD5232; |
| 363 |
channelNo = 2; |
| 364 |
maxPosition = 255; |
| 365 |
deviceSlaveId = 1; |
| 366 |
lowerAddressLimit = 0x2; |
| 367 |
upperAddressLimit = 0xF; |
| 368 |
nrToleranceReg = 0; |
| 369 |
break; |
| 370 |
case 0x31 : |
| 371 |
deviceType = ID_AD5235; |
| 372 |
channelNo = 2; |
| 373 |
maxPosition = 1023; |
| 374 |
deviceSlaveId = 1; |
| 375 |
lowerAddressLimit = 0x2; |
| 376 |
upperAddressLimit = 0xE; |
| 377 |
nrToleranceReg = 1; |
| 378 |
break; |
| 379 |
case 0x32 : |
| 380 |
deviceType = ID_AD5252; |
| 381 |
channelNo = 2; |
| 382 |
maxPosition = 255; |
| 383 |
deviceSlaveId = 1; |
| 384 |
lowerAddressLimit = 0x4; |
| 385 |
upperAddressLimit = 0xF; |
| 386 |
nrToleranceReg = 4; |
| 387 |
break; |
| 388 |
case 0x33 : |
| 389 |
deviceType = ID_AD5254; |
| 390 |
channelNo = 4; |
| 391 |
maxPosition = 255; |
| 392 |
deviceSlaveId = 0; |
| 393 |
lowerAddressLimit = 0x4; |
| 394 |
upperAddressLimit = 0xF; |
| 395 |
nrToleranceReg = 8; |
| 396 |
break; |
| 397 |
case 0x34 : |
| 398 |
deviceType = ID_ADN2850; |
| 399 |
channelNo = 2; |
| 400 |
maxPosition = 1023; |
| 401 |
deviceSlaveId = 1; |
| 402 |
lowerAddressLimit = 0x2; |
| 403 |
upperAddressLimit = 0xE; |
| 404 |
nrToleranceReg = 1; |
| 405 |
break; |
| 406 |
} |
| 407 |
} |
| 408 |
else |
| 409 |
{ |
| 410 |
CONSOLE_Print("Please type the number corresponding for \ |
| 411 |
your device!\r\n"); |
| 412 |
} |
| 413 |
} |
| 414 |
} |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
char DoDeviceInit(void) |
| 426 |
{ |
| 427 |
DoDeviceLock(); |
| 428 |
|
| 429 |
if(AD525X_Init(deviceType) == 0) |
| 430 |
{ |
| 431 |
CONSOLE_Print("Device OK\r\n"); |
| 432 |
DisplayCmdList(); |
| 433 |
return SUCCESS; |
| 434 |
} |
| 435 |
else |
| 436 |
{ |
| 437 |
CONSOLE_Print("Device Error\r\n"); |
| 438 |
return ERROR; |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
void SetRdac(double* param, char paramNo) |
| 452 |
{ |
| 453 |
unsigned char channel = 0; |
| 454 |
unsigned short data = 0; |
| 455 |
|
| 456 |
|
| 457 |
if(paramNo >= 2) |
| 458 |
{ |
| 459 |
paramLimit(¶m[0], 0, channelNo-1); |
| 460 |
paramLimit(¶m[1], 0, maxPosition); |
| 461 |
channel = (unsigned char)param[0]; |
| 462 |
data = (unsigned short)param[1]; |
| 463 |
|
| 464 |
AD525X_WriteRdac(deviceSlaveId, channel, data); |
| 465 |
CONSOLE_Print("RDAC[%d]=%d\r\n", channel, data); |
| 466 |
} |
| 467 |
else |
| 468 |
{ |
| 469 |
|
| 470 |
DisplayError(1); |
| 471 |
} |
| 472 |
} |
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
void GetRdac(double* param, char paramNo) |
| 483 |
{ |
| 484 |
unsigned char channel = 0; |
| 485 |
unsigned short data = 0; |
| 486 |
|
| 487 |
|
| 488 |
if(paramNo >= 1) |
| 489 |
{ |
| 490 |
paramLimit(¶m[0], 0, channelNo-1); |
| 491 |
channel = (unsigned char)param[0]; |
| 492 |
data = AD525X_ReadRdac(deviceSlaveId, channel); |
| 493 |
CONSOLE_Print("RDAC[%d]=%d\r\n", channel, data); |
| 494 |
} |
| 495 |
else |
| 496 |
{ |
| 497 |
|
| 498 |
DisplayError(2); |
| 499 |
} |
| 500 |
} |
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
void DoReset(double* param, char paramNo) |
| 511 |
{ |
| 512 |
AD525X_WriteCommand(deviceSlaveId, |
| 513 |
AD525X_CMD_RESET, |
| 514 |
0x0); |
| 515 |
CONSOLE_Print("Reset done.\r\n"); |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
void DoRestore(double* param, char paramNo) |
| 527 |
{ |
| 528 |
unsigned char channel = 0; |
| 529 |
|
| 530 |
|
| 531 |
if(paramNo >= 1) |
| 532 |
{ |
| 533 |
paramLimit(¶m[0], 0, (channelNo - 1)); |
| 534 |
channel = (unsigned char)param[0]; |
| 535 |
AD525X_WriteCommand(deviceSlaveId, |
| 536 |
AD525X_CMD_MEM2RDAC, |
| 537 |
channel); |
| 538 |
CONSOLE_Print("The channel %d was restored to its saved value.\r\n", \ |
| 539 |
channel); |
| 540 |
} |
| 541 |
else |
| 542 |
{ |
| 543 |
|
| 544 |
DisplayError(4); |
| 545 |
} |
| 546 |
} |
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
void SaveSettings(double* param, char paramNo) |
| 557 |
{ |
| 558 |
unsigned char channel = 0; |
| 559 |
|
| 560 |
|
| 561 |
if(paramNo >= 1) |
| 562 |
{ |
| 563 |
paramLimit(¶m[0], 0, (channelNo - 1)); |
| 564 |
channel = (unsigned char)param[0]; |
| 565 |
AD525X_WriteCommand(deviceSlaveId, |
| 566 |
AD525X_CMD_RDAC2MEM, |
| 567 |
channel); |
| 568 |
CONSOLE_Print("The value of channel %d was saved to memory.\r\n", \ |
| 569 |
channel); |
| 570 |
} |
| 571 |
else |
| 572 |
{ |
| 573 |
|
| 574 |
DisplayError(5); |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
void WriteToMem(double* param, char paramNo) |
| 588 |
{ |
| 589 |
unsigned char address = 0; |
| 590 |
unsigned short data = 0; |
| 591 |
|
| 592 |
if(paramNo >= 2) |
| 593 |
{ |
| 594 |
paramLimit(¶m[0], lowerAddressLimit, upperAddressLimit); |
| 595 |
paramLimit(¶m[1], 0, maxPosition); |
| 596 |
address = (unsigned char)param[0]; |
| 597 |
data = (unsigned short)param[1]; |
| 598 |
AD525X_WriteMem(deviceSlaveId, |
| 599 |
address, |
| 600 |
data); |
| 601 |
CONSOLE_Print("EEMEM[0x%.2x]=%d\r\n", address, data); |
| 602 |
} |
| 603 |
else |
| 604 |
{ |
| 605 |
|
| 606 |
DisplayError(6); |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
void ReadFromMem(double* param, char paramNo) |
| 619 |
{ |
| 620 |
unsigned char address = 0; |
| 621 |
unsigned short data = 0; |
| 622 |
|
| 623 |
if(paramNo >= 1) |
| 624 |
{ |
| 625 |
paramLimit(¶m[0], lowerAddressLimit, upperAddressLimit); |
| 626 |
address = (unsigned char)param[0]; |
| 627 |
data = AD525X_ReadMem(deviceSlaveId, |
| 628 |
address); |
| 629 |
CONSOLE_Print("EEMEM[0x%.2x]=%d\r\n", address, data); |
| 630 |
} |
| 631 |
else |
| 632 |
{ |
| 633 |
|
| 634 |
DisplayError(7); |
| 635 |
} |
| 636 |
} |
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
void DecRdac6dB(double* param, char paramNo) |
| 647 |
{ |
| 648 |
unsigned char channel = 0; |
| 649 |
|
| 650 |
if(paramNo >= 1) |
| 651 |
{ |
| 652 |
paramLimit(¶m[0], 0, (channelNo - 1)); |
| 653 |
channel = (unsigned char)param[0]; |
| 654 |
AD525X_WriteCommand(deviceSlaveId, |
| 655 |
AD525X_CMD_DECRDAC_6DB, |
| 656 |
channel); |
| 657 |
CONSOLE_Print("The value of channel %d was decremented by 6 dB.\r\n", \ |
| 658 |
channel); |
| 659 |
} |
| 660 |
else |
| 661 |
{ |
| 662 |
|
| 663 |
DisplayError(8); |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
void DecAllRdac6dB(double* param, char paramNo) |
| 676 |
{ |
| 677 |
AD525X_WriteCommand(deviceSlaveId, |
| 678 |
AD525X_CMD_DECALLRDAC_6DB, |
| 679 |
0x0); |
| 680 |
CONSOLE_Print("All channels were decremented by 6 dB.\r\n"); |
| 681 |
} |
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
void DecRdac(double* param, char paramNo) |
| 692 |
{ |
| 693 |
unsigned char channel = 0; |
| 694 |
|
| 695 |
if(paramNo >= 1) |
| 696 |
{ |
| 697 |
paramLimit(¶m[0], 0, (channelNo - 1)); |
| 698 |
channel = (unsigned char)param[0]; |
| 699 |
AD525X_WriteCommand(deviceSlaveId, |
| 700 |
AD525X_CMD_DECRDAC_ONE, |
| 701 |
channel); |
| 702 |
CONSOLE_Print("The value of channel %d was decremented by one.\r\n", \ |
| 703 |
channel); |
| 704 |
} |
| 705 |
else |
| 706 |
{ |
| 707 |
|
| 708 |
DisplayError(10); |
| 709 |
} |
| 710 |
} |
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
void DecAllRdac(double* param, char paramNo) |
| 721 |
{ |
| 722 |
AD525X_WriteCommand(deviceSlaveId, |
| 723 |
AD525X_CMD_DECALLRDAC_ONE, |
| 724 |
0x0); |
| 725 |
CONSOLE_Print("All channels were decremented by one.\r\n"); |
| 726 |
} |
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
void IncRdac6dB(double* param, char paramNo) |
| 737 |
{ |
| 738 |
unsigned char channel = 0; |
| 739 |
|
| 740 |
if(paramNo >= 1) |
| 741 |
{ |
| 742 |
paramLimit(¶m[0], 0, (channelNo - 1)); |
| 743 |
channel = (unsigned char)param[0]; |
| 744 |
AD525X_WriteCommand(deviceSlaveId, |
| 745 |
AD525X_CMD_INCRDAC_6DB, |
| 746 |
channel); |
| 747 |
CONSOLE_Print("The value of channel %d was incremented by 6 dB.\r\n", \ |
| 748 |
channel); |
| 749 |
} |
| 750 |
else |
| 751 |
{ |
| 752 |
|
| 753 |
DisplayError(12); |
| 754 |
} |
| 755 |
} |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
void IncAllRdac6dB(double* param, char paramNo) |
| 766 |
{ |
| 767 |
AD525X_WriteCommand(deviceSlaveId, |
| 768 |
AD525X_CMD_INCALLRDAC_6DB, |
| 769 |
0x0); |
| 770 |
CONSOLE_Print("All channels were incremented by 6 dB.\r\n"); |
| 771 |
} |
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
void IncRdac(double* param, char paramNo) |
| 782 |
{ |
| 783 |
unsigned char channel = 0; |
| 784 |
|
| 785 |
if(paramNo >= 1) |
| 786 |
{ |
| 787 |
paramLimit(¶m[0], 0, (channelNo - 1)); |
| 788 |
channel = (unsigned char)param[0]; |
| 789 |
AD525X_WriteCommand(deviceSlaveId, |
| 790 |
AD525X_CMD_INCRDAC_ONE, |
| 791 |
channel); |
| 792 |
CONSOLE_Print("The value of channel %d was incremented by one.\r\n", \ |
| 793 |
channel); |
| 794 |
} |
| 795 |
else |
| 796 |
{ |
| 797 |
|
| 798 |
DisplayError(14); |
| 799 |
} |
| 800 |
} |
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
void IncAllRdac(double* param, char paramNo) |
| 811 |
{ |
| 812 |
AD525X_WriteCommand(deviceSlaveId, |
| 813 |
AD525X_CMD_INCALLRDAC_ONE, |
| 814 |
0x0); |
| 815 |
CONSOLE_Print("All channels were incremented by one.\r\n"); |
| 816 |
} |
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
void SetWrPin(double* param, char paramNo) |
| 832 |
{ |
| 833 |
if(paramNo >= 1) |
| 834 |
{ |
| 835 |
paramLimit(¶m[0], 0, 1); |
| 836 |
if((param[0] == 0) && (writeProtectBuff == 1)) |
| 837 |
{ |
| 838 |
|
| 839 |
AD525X_WriteCommand(deviceSlaveId, |
| 840 |
AD525X_CMD_NOP, |
| 841 |
0); |
| 842 |
TIME_DelayUs(50); |
| 843 |
AD525X_WP_BF_HIGH; |
| 844 |
writeProtectBuff = 0; |
| 845 |
CONSOLE_Print("WP is inactive.\r\n"); |
| 846 |
} |
| 847 |
else if((param[0] == 1) && (writeProtectBuff == 0)) |
| 848 |
{ |
| 849 |
AD525X_WP_BF_LOW; |
| 850 |
writeProtectBuff = 1; |
| 851 |
CONSOLE_Print("WP was activated.\r\n"); |
| 852 |
} |
| 853 |
} |
| 854 |
else |
| 855 |
{ |
| 856 |
|
| 857 |
DisplayError(16); |
| 858 |
} |
| 859 |
} |
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
void GetWrPin(double* param, char paramNo) |
| 870 |
{ |
| 871 |
if(writeProtectBuff) |
| 872 |
{ |
| 873 |
CONSOLE_Print("The WR pin is at active low state.\r\n"); |
| 874 |
} |
| 875 |
else |
| 876 |
{ |
| 877 |
CONSOLE_Print("The WR pin is at inactive high state.\r\n"); |
| 878 |
} |
| 879 |
} |
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
void SetPrPin(double* param, char paramNo) |
| 893 |
{ |
| 894 |
if((deviceType == ID_AD5252) || (deviceType == ID_AD5254)) |
| 895 |
{ |
| 896 |
CONSOLE_Print("This function is not supported by the current device.\r\n"); |
| 897 |
} |
| 898 |
else |
| 899 |
{ |
| 900 |
if(paramNo >= 1) |
| 901 |
{ |
| 902 |
paramLimit(¶m[0], 0, 1); |
| 903 |
if((param[0] == 1) && (overridePreset == 0)) |
| 904 |
{ |
| 905 |
AD525X_RESET_LOW; |
| 906 |
overridePreset = 1; |
| 907 |
CONSOLE_Print("The hardware RESET is activated.\r\n"); |
| 908 |
} else if((param[0] == 0) && (overridePreset == 1)) |
| 909 |
{ |
| 910 |
AD525X_RESET_HIGH; |
| 911 |
overridePreset = 0; |
| 912 |
CONSOLE_Print("The hardware RESET is inactive.\r\n"); |
| 913 |
} |
| 914 |
} |
| 915 |
else |
| 916 |
{ |
| 917 |
|
| 918 |
DisplayError(18); |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
} |
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
void GetPrPin(double* param, char paramNo) |
| 933 |
{ |
| 934 |
if((deviceType == ID_AD5252) || (deviceType == ID_AD5254)) |
| 935 |
{ |
| 936 |
CONSOLE_Print("This function is not supported by the current device.\r\n"); |
| 937 |
} |
| 938 |
else |
| 939 |
{ |
| 940 |
if(overridePreset) |
| 941 |
{ |
| 942 |
CONSOLE_Print("The RESET pin is at active low state.\r\n"); |
| 943 |
} |
| 944 |
else |
| 945 |
{ |
| 946 |
CONSOLE_Print("The RESET pin is at inactive high state.\r\n"); |
| 947 |
} |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
void GetTolerance(double* param, char paramNo) |
| 964 |
{ |
| 965 |
unsigned char address = 0; |
| 966 |
unsigned short data = 0; |
| 967 |
|
| 968 |
if(deviceType == ID_AD5232) |
| 969 |
{ |
| 970 |
CONSOLE_Print("This function is not supported by the current device.\r\n"); |
| 971 |
} |
| 972 |
else |
| 973 |
{ |
| 974 |
if(paramNo >= 1) |
| 975 |
{ |
| 976 |
|
| 977 |
paramLimit(¶m[0], 0, (nrToleranceReg - 1)); |
| 978 |
switch(deviceType) |
| 979 |
{ |
| 980 |
case ID_AD5235 : |
| 981 |
address = 0xF + (unsigned char)param[0]; |
| 982 |
break; |
| 983 |
case ID_AD5252 : |
| 984 |
address = (param[0]>1) ? (0x1C + (unsigned char)param[0]) : |
| 985 |
(0x1A + (unsigned char)param[0]); |
| 986 |
break; |
| 987 |
case ID_AD5254 : |
| 988 |
address = 0x18 + (unsigned char)param[0]; |
| 989 |
break; |
| 990 |
case ID_ADN2850 : |
| 991 |
address = 0xF + (unsigned char)param[0]; |
| 992 |
break; |
| 993 |
default : |
| 994 |
break; |
| 995 |
} |
| 996 |
data = AD525X_ReadMem(deviceSlaveId, |
| 997 |
address); |
| 998 |
CONSOLE_Print("TolReg[0x%02x]=0x%4x\r\n", \ |
| 999 |
(unsigned char)param[0], data); |
| 1000 |
} |
| 1001 |
else |
| 1002 |
{ |
| 1003 |
|
| 1004 |
DisplayError(20); |
| 1005 |
} |
| 1006 |
} |
| 1007 |
} |