# HG changeset patch # User Daniele Nicolodi # Date 1396278218 -7200 # Node ID 11a88d3897057e3eca0ad59e0f47682e5392de39 # Parent b955e35c07ae0e9b6c933553ac213dea7abeae15 Adapt to new AD9956 interface diff -r b955e35c07ae -r 11a88d389705 FXAnalyse.c --- a/FXAnalyse.c Mon Mar 31 17:03:38 2014 +0200 +++ b/FXAnalyse.c Mon Mar 31 17:03:38 2014 +0200 @@ -12,7 +12,7 @@ #include "Plot.h" #include "Allan.h" #include "ad9912.h" -#include "DDS_Fox.h" +#include "ad9956.h" #include "muParserDLL.h" #include "utils.h" #include "stat.h" @@ -184,6 +184,47 @@ } +static inline int ad9956_set_sweep_rate_w(struct ad9956 *d, double s) +{ + int r = ad9956_set_sweep_rate(d, s); + if (r) + logmessage(ERROR, "ad9956 set sweep rate error=%d", -r); + return r; +} + + +static int ad9956_set_w(struct ad9956 *d, double f, double s) +{ + int r; + + r = ad9956_sweep_stop(d); + if (r) { + logmessage(ERROR, "ad9956 sweep stop error=%d", -r); + return r; + } + + r = ad9956_set_frequency(d, f); + if (r) { + logmessage(ERROR, "ad9956 set frequency error=%d", -r); + return r; + } + + r = ad9956_set_sweep_rate(d, s); + if (r) { + logmessage(ERROR, "ad9956 set sweep rate error=%d", -r); + return r; + } + + r = ad9956_sweep_start(d); + if (r) { + logmessage(ERROR, "ad9956 sweep start error=%d", -r); + return r; + } + + return 0; +} + + enum { LO = 1, HG = 2, @@ -415,7 +456,6 @@ double frequency; char expr[1024]; char host[256]; - int port; double clock; if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) @@ -448,15 +488,14 @@ rv = Ini_GetStringIntoBuffer(configuration, "AD9956", "host", host, sizeof(host)); if (! rv) return -1; - rv = Ini_GetInt(configuration, "AD9956", "port", &port); - if (! rv) - return -1; rv = Ini_GetDouble(configuration, "AD9956", "clock", &clock); if (! rv) return -1; - // dedrift DDS - DDSFox_Init(&ad9956, host, port); + // initialize AD9956 dedrift DDS + rv = ad9956_init(&ad9956, host, clock); + if (rv) + logmessage(ERROR, "ad9956 init erorr=%d", -rv); // ad9912 configuration parameters rv = Ini_GetStringIntoBuffer(configuration, "AD9912", "host", host, sizeof(host)); @@ -1228,11 +1267,11 @@ if (! dedrift.keep_slope) { dedrift.applied = 0.0; - DDSFox_SetSweepRate(&ad9956, dedrift.applied); + ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, dedrift.applied); } if (! dedrift.keep_freq) { - DDSFox_Set(&ad9956, dedrift.freq0, dedrift.applied); + ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); } stat_zero(&freq); @@ -1261,9 +1300,9 @@ SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, dedrift.applied); if (dedrift.doubleslope) - DDSFox_SetSweepRate(&ad9956, dedrift.applied * 2.0); + ad9956_set_sweep_rate_w(&ad9956, 2 * dedrift.applied); else - DDSFox_SetSweepRate(&ad9956, dedrift.applied); + ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); logmsg("dedrift update: adjustment=%+3e slope=%+3e", freq.slope, dedrift.applied); @@ -1743,11 +1782,11 @@ } else { if (! dedrift.keep_slope) { dedrift.applied = 0.0; - DDSFox_SetSweepRate(&ad9956, dedrift.applied); + ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, dedrift.applied); } if (! dedrift.keep_freq) { - DDSFox_Set(&ad9956, dedrift.freq0, dedrift.applied); + ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); } stat_zero(&freq); SetCtrlVal(panel, PANEL_SLOPE_MEASURED, freq.slope); @@ -1766,7 +1805,7 @@ case EVENT_COMMIT: dedrift.applied = 0.0; SetCtrlVal(panel, PANEL_SLOPE_APPLIED, dedrift.applied); - DDSFox_Set(&ad9956, dedrift.freq0, dedrift.applied); + ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); logmsg("dedrift reset"); break; } @@ -1945,7 +1984,7 @@ { case EVENT_COMMIT: GetCtrlVal(panel, control, &dedrift.applied); - DDSFox_SetSweepRate(&ad9956, dedrift.applied); + ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); break; } return 0; @@ -1975,7 +2014,7 @@ dedrift.applied = 0.0; SetCtrlVal(panel, PANEL_SLOPE_APPLIED, dedrift.applied); // reset DDS - DDSFox_Reset(&ad9956, dedrift.freq0); + ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); break; } return 0; @@ -2125,7 +2164,7 @@ { case EVENT_COMMIT: GetCtrlVal(panel, control, &dedrift.freq0); - DDSFox_Set(&ad9956, dedrift.freq0, dedrift.applied); + ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); break; } return 0;