altos: profiling on STM32L
[fw/altos] / src / drivers / ao_ms5607.c
index fdd2c31e5992e4c96e1120d313bb13ba186978b7..ce0bcf4bcfb79e6a123e00a62c78d7d315c47f01 100644 (file)
@@ -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));
 }