X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fdrivers%2Fao_ms5607.c;h=492199b8b4061d4d1d856f3f6b770d13efcbc1a5;hb=mm-ms5611;hp=704b4583ec9e973848b82e22e1a9ef52aed82241;hpb=e2b458a448106ba1ab207f0ea6824b56927d8547;p=fw%2Faltos diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 704b4583..492199b8 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -19,7 +19,7 @@ #include #include "ao_ms5607.h" -#if HAS_MS5607 +#if HAS_MS5607 || HAS_MS5611 static struct ao_ms5607_prom ms5607_prom; static uint8_t ms5607_configured; @@ -92,7 +92,7 @@ ao_ms5607_prom_read(struct ao_ms5607_prom *prom) printf ("MS5607 PROM CRC error (computed %x actual %x)\n", crc, (((uint8_t *) prom)[15] & 0xf)); flush(); -// ao_panic(AO_PANIC_SELF_TEST_MS5607); + ao_panic(AO_PANIC_SELF_TEST_MS5607); } #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -179,9 +179,13 @@ ao_ms5607_convert(struct ao_ms5607_sample *sample, struct ao_ms5607_value *value TEMP = 2000 + (((int64_t) dT * ms5607_prom.tempsens) >> 23); +#if HAS_MS5611 + OFF = ((int64_t) ms5607_prom.off << 16) + (((int64_t) ms5607_prom.tco * dT) >> 7); + SENS = ((int64_t) ms5607_prom.sens << 15) + (((int64_t) ms5607_prom.tcs * dT) >> 8); +#else OFF = ((int64_t) ms5607_prom.off << 17) + (((int64_t) ms5607_prom.tco * dT) >> 6); - SENS = ((int64_t) ms5607_prom.sens << 16) + (((int64_t) ms5607_prom.tcs * dT) >> 7); +#endif if (TEMP < 2000) { int32_t T2 = ((int64_t) dT * (int64_t) dT) >> 31; @@ -203,13 +207,15 @@ ao_ms5607_convert(struct ao_ms5607_sample *sample, struct ao_ms5607_value *value value->temp = TEMP; } +struct ao_ms5607_sample ao_ms5607_current; + static void ao_ms5607(void) { ao_ms5607_setup(); for (;;) { - ao_ms5607_sample((struct ao_ms5607_sample *) &ao_data_ring[ao_data_head].ms5607_raw); + ao_ms5607_sample(&ao_ms5607_current); ao_arch_critical( AO_DATA_PRESENT(AO_DATA_MS5607); AO_DATA_WAIT(); @@ -235,14 +241,13 @@ ao_ms5607_info(void) static void ao_ms5607_dump(void) { - struct ao_ms5607_sample sample; + struct ao_data data; struct ao_ms5607_value value; - ao_ms5607_setup(); - ao_ms5607_sample(&sample); - ao_ms5607_convert(&sample, &value); - printf ("Pressure: %8u %8d\n", sample.pres, value.pres); - printf ("Temperature: %8u %8d\n", sample.temp, value.temp); + ao_data_get(&data); + ao_ms5607_convert(&data.ms5607_raw, &value); + printf ("Pressure: %8u %8d\n", data.ms5607_raw.pres, value.pres); + printf ("Temperature: %8u %8d\n", data.ms5607_raw.temp, value.temp); printf ("Altitude: %ld\n", ao_pa_to_altitude(value.pres)); } @@ -258,7 +263,7 @@ ao_ms5607_init(void) ao_cmd_register(&ao_ms5607_cmds[0]); ao_spi_init_cs(AO_MS5607_CS_PORT, (1 << AO_MS5607_CS_PIN)); -// ao_add_task(&ao_ms5607_task, ao_ms5607, "ms5607"); + ao_add_task(&ao_ms5607_task, ao_ms5607, "ms5607"); /* Configure the MISO pin as an interrupt; when the * conversion is complete, the MS5607 will raise this