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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 #include <ao_ms5607.h>
26 struct ao_ms5607_prom ao_ms5607_prom = {
37 int32_t D1_mm = 6179630;
38 int32_t D2_mm = 8933155;
40 #include <ao_ms5607_convert.c>
41 #define ao_ms5607_convert ao_ms5607_convert_8051
42 #include <ao_ms5607_convert_8051.c>
47 struct ao_ms5607_sample ao_sample = {
54 void test(int trial, struct ao_ms5607_sample *sample)
56 struct ao_ms5607_value value, value_8051;
58 ao_ms5607_convert(sample, &value);
59 ao_ms5607_convert_8051(sample, &value_8051);
60 if (value.temp != value_8051.temp || value.pres != value_8051.pres) {
62 printf ("trial %d: %d, %d -> %d, %d (should be %d, %d)\n",
64 sample->pres, sample->temp,
65 value_8051.pres, value_8051.temp,
66 value.pres, value.temp);
70 #define TESTS 10000000
74 static int32_t rand24(void) { return random() & 0xffffff; }
77 main(int argc, char **argv)
79 struct ao_ms5607_sample sample;
83 start = atoi(argv[1]);
89 for (i = 0; i < TESTS; i++) {
90 sample.pres = rand24();
91 sample.temp = rand24();