comparison ad9912.c @ 201:f8118b90490e

Fix new AD9912 interface
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Mon, 31 Mar 2014 17:03:37 +0200
parents 87dae6d62a61
children 9e0c3541104b
comparison
equal deleted inserted replaced
200:0e0282010be3 201:f8118b90490e
30 typedef unsigned long long uint64; 30 typedef unsigned long long uint64;
31 31
32 32
33 static inline uint64 ftw(double clock, double freq) 33 static inline uint64 ftw(double clock, double freq)
34 { 34 {
35 uint64 ftw = freq * ((double)(1 << 48) / clock); 35 uint64 ftw = freq * ((double)(1ULL << 48) / clock);
36 ftw = ftw & ~1ULL; 36 ftw = ftw & ~1ULL;
37 return ftw; 37 return ftw;
38 } 38 }
39 39
40 40
168 int ad9912_set_frequency(struct ad9912 *d, unsigned channel, double f) 168 int ad9912_set_frequency(struct ad9912 *d, unsigned channel, double f)
169 { 169 {
170 int r; 170 int r;
171 uint64 value = ftw(d->clock, f); 171 uint64 value = ftw(d->clock, f);
172 172
173 r = command(d->fd, "SET CH%d:FTW0 0x%llX", channel, f); 173 r = command(d->fd, "SET CH%d:FTW0 0x%llX", channel, value);
174 if (r < 0) 174 if (r < 0)
175 return r; 175 return r;
176 176
177 d->frequency[channel] = freq(d->clock, value); 177 d->frequency[channel] = freq(d->clock, value);
178 178