okay, drama queen ;D. its actualy working now or close to it

This commit is contained in:
pszsh 2026-01-23 04:02:56 -08:00
parent b96e59e543
commit 5fc4565064
1 changed files with 8 additions and 0 deletions

8
main.c
View File

@ -189,14 +189,18 @@ void process_command() {
// CRITICAL: Stop any running measurement before reconfiguration
AppIMPCtrl(IMPCTRL_STOPNOW, 0);
sleep_ms(10); // Give AFE time to halt
if (cmd == 'v') {
uint32_t id = AD5940_ReadReg(REG_AFECON_CHIPID);
printf("CHIP_ID:0x%04X\n", id);
}
else if (cmd == 'c') {
// Calibration: Run a single measurement at 1kHz
pCfg->SweepCfg.SweepEn = bFALSE;
pCfg->SinFreq = 1000.0f;
pCfg->NumOfData = 1; // Single Shot
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
AppIMPCtrl(IMPCTRL_START, 0);
} else {
@ -204,11 +208,13 @@ void process_command() {
}
}
else if (cmd == 'm') {
// Measure: Continuous monitoring at fixed frequency
float freq = 1000.0f;
if (strlen(input_buffer) > 2) freq = atof(input_buffer + 2);
pCfg->SweepCfg.SweepEn = bFALSE;
pCfg->SinFreq = freq;
pCfg->NumOfData = -1; // Continuous
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
AppIMPCtrl(IMPCTRL_START, 0);
@ -217,6 +223,7 @@ void process_command() {
}
}
else if (cmd == 's') {
// Sweep: Run exactly 'steps' measurements then stop
float start = 100.0f, end = 100000.0f;
int steps = 50;
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.SweepPoints = steps;
pCfg->SweepCfg.SweepLog = bTRUE;
pCfg->NumOfData = steps; // Stop after sweep
if(AppIMPInit(AppBuff, APPBUFF_SIZE) == AD5940ERR_OK) {
AppIMPCtrl(IMPCTRL_START, 0);