Mercurial > hg > fxanalyse
annotate dds.h @ 244:4db8746bd575
Add NaN and isnan() compatibility macros to future.h
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Thu, 26 Feb 2015 23:10:06 +0100 |
parents | fcc988c6f841 |
children | 5296f3bcd160 |
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 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
4 #define usleep(t) Delay((t) / 1000000.0) |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
5 #define strdup(s) StrDup(s) |
213
fcc988c6f841
Fix ad9956 sweep rate setting. Disable clock divider on init. Simplify
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
206
diff
changeset
|
6 |
206
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
7 |
213
fcc988c6f841
Fix ad9956 sweep rate setting. Disable clock divider on init. Simplify
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
206
diff
changeset
|
8 typedef long long int64; |
206
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
9 typedef unsigned long long uint64; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
10 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
11 static inline uint64 ftw(double clock, double freq) |
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 uint64 ftw = freq * ((double)(1ULL << 48) / clock); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
14 return ftw; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
15 } |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
16 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
17 static inline double freq(double clock, uint64 ftw) |
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 double freq = (double)ftw * (clock / (double)(1ULL << 48)); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
20 return freq; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
21 } |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
22 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
23 static inline int strtouint64(const char *str, uint64 *v) |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
24 { |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
25 char *end; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
26 *v = strtoull(str, &end, 0); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
27 if (*end != '\0') |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
28 return -1; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
29 return 0; |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
30 } |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
31 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
32 int msend(int fd, char *buffer, int n); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
33 int mrecv(int fd, char *buffer, int len); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
34 int command(int fd, char *frmt, ...); |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
35 |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
36 #endif |
c700a2d38fb8
New AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
37 |