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.
21 #include <ao_ms5607.h>
23 struct ao_ms5607_prom ao_ms5607_prom = {
34 int32_t D1_mm = 6179630;
35 int32_t D2_mm = 8933155;
37 #include <ao_ms5607_convert.c>
38 #define ao_ms5607_convert ao_ms5607_convert_8051
39 #include <ao_ms5607_convert_8051.c>
44 struct ao_ms5607_sample ao_sample = {
51 void test(int trial, struct ao_ms5607_sample *sample)
53 struct ao_ms5607_value value, value_8051;
55 ao_ms5607_convert(sample, &value);
56 ao_ms5607_convert_8051(sample, &value_8051);
57 if (value.temp != value_8051.temp || value.pres != value_8051.pres) {
59 printf ("trial %d: %d, %d -> %d, %d (should be %d, %d)\n",
61 sample->pres, sample->temp,
62 value_8051.pres, value_8051.temp,
63 value.pres, value.temp);
67 #define TESTS 10000000
71 static int32_t rand24(void) { return random() & 0xffffff; }
74 main(int argc, char **argv)
76 struct ao_ms5607_sample sample;
80 start = atoi(argv[1]);
86 for (i = 0; i < TESTS; i++) {
87 sample.pres = rand24();
88 sample.temp = rand24();