annotate test-ad9912.c @ 267:1de805d2d37a

Reuse beatnote enum also for dedrift reference selection
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Thu, 09 Jul 2015 23:08:22 +0200
parents da38cbbc7ec8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
265
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1 #include <stdio.h>
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2 #include <string.h>
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
3 #include <unistd.h>
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
4 #include "ad9912.h"
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
5
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
6 #define die() do { printf("ERROR: %s\n", strerror(-r)); exit(EXIT_FAILURE); } while (0)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
7 #define error() do { printf("ERROR: %s\n", strerror(-r)); } while (0)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
8
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
9 int main(int argc, char **argv)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
10 {
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
11 int r;
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
12 double f;
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
13 struct ad9912 dds;
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
14
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
15 if (argc < 2)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
16 exit(EXIT_FAILURE);
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
17
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
18 r = ad9912_init(&dds, argv[1], 1e9);
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
19 if (r < 0)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
20 error();
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
21
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
22 for (int i = 0; i < 4; i++) {
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
23 r = ad9912_get_frequency(&dds, i, &f);
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
24 if (r < 0)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
25 die();
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
26 printf("DDS%d f=%f Hz\n", i, f);
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
27 }
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
28
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
29 for (int i = 0; i < 4; i++) {
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
30 r = ad9912_set_frequency(&dds, i, i * 10e6);
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
31 if (r < 0)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
32 error();
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
33 }
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
34
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
35 for (int i = 0; i < 4; i++) {
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
36 r = ad9912_get_frequency(&dds, i, &f);
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
37 if (r < 0)
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
38 error();
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
39 printf("DDS%d f=%f Hz\n", i, f);
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
40 }
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
41
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
42 return 0;
da38cbbc7ec8 Add DDS clients test code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
43 }