Mercurial > hg > fxanalyse
changeset 259:6c748ed6a7c5
Stricter error checks ad9912 ramp frequency function
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Tue, 16 Jun 2015 14:33:36 +0200 |
parents | 5296f3bcd160 |
children | 3622e24a443f |
files | ad9912.c |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ad9912.c Tue Jun 16 14:31:35 2015 +0200 +++ b/ad9912.c Tue Jun 16 14:33:36 2015 +0200 @@ -92,26 +92,29 @@ */ int ad9912_ramp_frequency2(struct ad9912 *d, unsigned channel, double f1, double f2, double fstep) { + int r = 0; const int delay = 10000; /* f2 > f1 */ while ((f2 - f1) > fstep) { f1 += fstep; - ad9912_set_frequency(d, channel, f1); + r = ad9912_set_frequency(d, channel, f1); + if (r < 0) + return r; usleep(delay); } /* f2 < f1 */ while ((f1 - f2) > fstep) { f1 -= fstep; - ad9912_set_frequency(d, channel, f1); + r = ad9912_set_frequency(d, channel, f1); + if (r < 0) + return r; usleep(delay); } /* final adjustment */ - ad9912_set_frequency(d, channel, f2); - - return 0; + return ad9912_set_frequency(d, channel, f2); }