okay, drama queen ;D. its actualy working now or close to it
This commit is contained in:
parent
b96e59e543
commit
5fc4565064
8
main.c
8
main.c
|
|
@ -189,14 +189,18 @@ void process_command() {
|
||||||
|
|
||||||
// CRITICAL: Stop any running measurement before reconfiguration
|
// CRITICAL: Stop any running measurement before reconfiguration
|
||||||
AppIMPCtrl(IMPCTRL_STOPNOW, 0);
|
AppIMPCtrl(IMPCTRL_STOPNOW, 0);
|
||||||
|
sleep_ms(10); // Give AFE time to halt
|
||||||
|
|
||||||
if (cmd == 'v') {
|
if (cmd == 'v') {
|
||||||
uint32_t id = AD5940_ReadReg(REG_AFECON_CHIPID);
|
uint32_t id = AD5940_ReadReg(REG_AFECON_CHIPID);
|
||||||
printf("CHIP_ID:0x%04X\n", id);
|
printf("CHIP_ID:0x%04X\n", id);
|
||||||
}
|
}
|
||||||
else if (cmd == 'c') {
|
else if (cmd == 'c') {
|
||||||
|
// Calibration: Run a single measurement at 1kHz
|
||||||
pCfg->SweepCfg.SweepEn = bFALSE;
|
pCfg->SweepCfg.SweepEn = bFALSE;
|
||||||
pCfg->SinFreq = 1000.0f;
|
pCfg->SinFreq = 1000.0f;
|
||||||
|
pCfg->NumOfData = 1; // Single Shot
|
||||||
|
|
||||||
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
||||||
AppIMPCtrl(IMPCTRL_START, 0);
|
AppIMPCtrl(IMPCTRL_START, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -204,11 +208,13 @@ void process_command() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd == 'm') {
|
else if (cmd == 'm') {
|
||||||
|
// Measure: Continuous monitoring at fixed frequency
|
||||||
float freq = 1000.0f;
|
float freq = 1000.0f;
|
||||||
if (strlen(input_buffer) > 2) freq = atof(input_buffer + 2);
|
if (strlen(input_buffer) > 2) freq = atof(input_buffer + 2);
|
||||||
|
|
||||||
pCfg->SweepCfg.SweepEn = bFALSE;
|
pCfg->SweepCfg.SweepEn = bFALSE;
|
||||||
pCfg->SinFreq = freq;
|
pCfg->SinFreq = freq;
|
||||||
|
pCfg->NumOfData = -1; // Continuous
|
||||||
|
|
||||||
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
||||||
AppIMPCtrl(IMPCTRL_START, 0);
|
AppIMPCtrl(IMPCTRL_START, 0);
|
||||||
|
|
@ -217,6 +223,7 @@ void process_command() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd == 's') {
|
else if (cmd == 's') {
|
||||||
|
// Sweep: Run exactly 'steps' measurements then stop
|
||||||
float start = 100.0f, end = 100000.0f;
|
float start = 100.0f, end = 100000.0f;
|
||||||
int steps = 50;
|
int steps = 50;
|
||||||
if (strlen(input_buffer) > 2) sscanf(input_buffer + 2, "%f %f %d", &start, &end, &steps);
|
if (strlen(input_buffer) > 2) sscanf(input_buffer + 2, "%f %f %d", &start, &end, &steps);
|
||||||
|
|
@ -226,6 +233,7 @@ void process_command() {
|
||||||
pCfg->SweepCfg.SweepStop = end;
|
pCfg->SweepCfg.SweepStop = end;
|
||||||
pCfg->SweepCfg.SweepPoints = steps;
|
pCfg->SweepCfg.SweepPoints = steps;
|
||||||
pCfg->SweepCfg.SweepLog = bTRUE;
|
pCfg->SweepCfg.SweepLog = bTRUE;
|
||||||
|
pCfg->NumOfData = steps; // Stop after sweep
|
||||||
|
|
||||||
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
|
||||||
AppIMPCtrl(IMPCTRL_START, 0);
|
AppIMPCtrl(IMPCTRL_START, 0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue