diff dds.h @ 206:c700a2d38fb8

New AD9956 interface
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Mon, 31 Mar 2014 17:03:38 +0200
parents
children fcc988c6f841
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dds.h	Mon Mar 31 17:03:38 2014 +0200
@@ -0,0 +1,36 @@
+#ifndef __FXANALYSE_DDS_H__
+#define __FXANALYSE_DDS_H__
+
+#define usleep(t) Delay((t) / 1000000.0)
+#define strdup(s) StrDup(s)
+#define streq(x, y) (strcmp((x), (y)) == 0)
+
+typedef unsigned long long uint64;
+
+static inline uint64 ftw(double clock, double freq)
+{
+	uint64 ftw = freq * ((double)(1ULL << 48) / clock);
+	return ftw;
+}
+
+static inline double freq(double clock, uint64 ftw)
+{
+	double freq = (double)ftw * (clock / (double)(1ULL << 48));
+	return freq;
+}
+
+static inline int strtouint64(const char *str, uint64 *v)
+{
+	char *end;
+	*v = strtoull(str, &end, 0);
+	if (*end != '\0')
+		return -1;
+	return 0;
+}
+
+int msend(int fd, char *buffer, int n);
+int mrecv(int fd, char *buffer, int len);
+int command(int fd, char *frmt, ...);
+
+#endif
+