Mercurial > hg > fxanalyse
annotate dds.h @ 263:8d9a4c5eb7a4
Fixes to make last changes working in CVI
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Tue, 16 Jun 2015 17:19:15 +0200 |
parents | 5296f3bcd160 |
children |
rev | line source |
---|---|
206
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
1 #ifndef __FXANALYSE_DDS_H__ |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
2 #define __FXANALYSE_DDS_H__ |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
3 |
213
fcc988c6f841
Fix ad9956 sweep rate setting. Disable clock divider on init. Simplify
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
206
diff
changeset
|
4 typedef long long int64; |
206
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
5 typedef unsigned long long uint64; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
6 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
7 static inline uint64 ftw(double clock, double freq) |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
8 { |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
9 uint64 ftw = freq * ((double)(1ULL << 48) / clock); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
10 return ftw; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
11 } |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
12 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
13 static inline double freq(double clock, uint64 ftw) |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
14 { |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
15 double freq = (double)ftw * (clock / (double)(1ULL << 48)); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
16 return freq; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
17 } |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
18 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
19 static inline int strtouint64(const char *str, uint64 *v) |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
20 { |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
21 char *end; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
22 *v = strtoull(str, &end, 0); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
23 if (*end != '\0') |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
24 return -1; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
25 return 0; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
26 } |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
27 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
28 #endif |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
29 |