2 * Copyright © 2013 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 #include <ao_ms5607.h>
27 struct ao_ms5607_prom ao_ms5607_prom = {
38 int32_t D1_mm = 6179630;
39 int32_t D2_mm = 8933155;
41 #include <ao_ms5607_convert.c>
42 #define ao_ms5607_convert ao_ms5607_convert_8051
43 #include <ao_ms5607_convert_8051.c>
48 struct ao_ms5607_sample ao_sample = {
55 void test(int trial, struct ao_ms5607_sample *sample)
57 struct ao_ms5607_value value, value_8051;
59 ao_ms5607_convert(sample, &value);
60 ao_ms5607_convert_8051(sample, &value_8051);
61 if (value.temp != value_8051.temp || value.pres != value_8051.pres) {
63 printf ("trial %d: %d, %d -> %d, %d (should be %d, %d)\n",
65 sample->pres, sample->temp,
66 value_8051.pres, value_8051.temp,
67 value.pres, value.temp);
71 #define TESTS 10000000
75 static int32_t rand24(void) { return random() & 0xffffff; }
78 main(int argc, char **argv)
80 struct ao_ms5607_sample sample;
84 start = atoi(argv[1]);
90 for (i = 0; i < TESTS; i++) {
91 sample.pres = rand24();
92 sample.temp = rand24();