X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fdrivers%2Fao_ms5607.c;h=ce0bcf4bcfb79e6a123e00a62c78d7d315c47f01;hb=e80fa6de4ccc5c4851eab9fb941f9282d2e3eb16;hp=fdd2c31e5992e4c96e1120d313bb13ba186978b7;hpb=2733d1b71bbac2c5ef4a2c3a1992ba448e981267;p=fw%2Faltos diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index fdd2c31e..ce0bcf4b 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -130,6 +130,7 @@ static uint32_t ao_ms5607_get_sample(uint8_t cmd) { uint8_t reply[3]; uint8_t read; + uint32_t loops; ao_ms5607_done = 0; @@ -141,10 +142,15 @@ ao_ms5607_get_sample(uint8_t cmd) { #if AO_MS5607_PRIVATE_PINS ao_spi_put(AO_MS5607_SPI_INDEX); #endif +// loops = 0; cli(); - while (!ao_ms5607_done) + while (!ao_ms5607_done) { +// loops++; ao_sleep((void *) &ao_ms5607_done); + } sei(); +// if (loops > 1) +// printf ("ms5607 loops %d\n", loops); #if AO_MS5607_PRIVATE_PINS stm_gpio_set(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, 1); #else @@ -170,13 +176,15 @@ ao_ms5607_sample(struct ao_ms5607_sample *sample) #include "ao_ms5607_convert.c" #if HAS_TASK +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(); @@ -202,14 +210,11 @@ ao_ms5607_info(void) static void ao_ms5607_dump(void) { - struct ao_ms5607_sample sample; 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_ms5607_convert(&ao_ms5607_current, &value); + printf ("Pressure: %8u %8d\n", ao_ms5607_current.pres, value.pres); + printf ("Temperature: %8u %8d\n", ao_ms5607_current.temp, value.temp); printf ("Altitude: %ld\n", ao_pa_to_altitude(value.pres)); }