altos/micropeak: Run MS5607 at max resolution for micropeak
authorKeith Packard <keithp@keithp.com>
Wed, 31 Oct 2012 02:44:45 +0000 (19:44 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 31 Oct 2012 04:31:27 +0000 (21:31 -0700)
We've got lots of time, so get the highest resolution baro data available.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_ms5607.c
src/micropeak/ao_pins.h

index 55bea563498701775f1580f28bc8e122dd92bfb0..bd57400e94690524170ae6ddaa203f3103eff0b2 100644 (file)
@@ -160,11 +160,25 @@ ao_ms5607_get_sample(uint8_t cmd) {
        return ((uint32_t) reply[0] << 16) | ((uint32_t) reply[1] << 8) | (uint32_t) reply[2];
 }
 
+#ifndef AO_MS5607_BARO_OVERSAMPLE
+#define AO_MS5607_BARO_OVERSAMPLE      2048
+#endif
+
+#ifndef AO_MS5607_TEMP_OVERSAMPLE
+#define AO_MS5607_TEMP_OVERSAMPLE      AO_MS5607_BARO_OVERSAMPLE
+#endif
+
+#define token_paster(x,y)      x ## y
+#define token_evaluator(x,y)   token_paster(x,y)
+
+#define AO_CONVERT_D1  token_evaluator(AO_MS5607_CONVERT_D1_, AO_MS5607_BARO_OVERSAMPLE)
+#define AO_CONVERT_D2  token_evaluator(AO_MS5607_CONVERT_D2_, AO_MS5607_TEMP_OVERSAMPLE)
+
 void
 ao_ms5607_sample(struct ao_ms5607_sample *sample)
 {
-       sample->pres = ao_ms5607_get_sample(AO_MS5607_CONVERT_D1_2048);
-       sample->temp = ao_ms5607_get_sample(AO_MS5607_CONVERT_D2_2048);
+       sample->pres = ao_ms5607_get_sample(AO_CONVERT_D1);
+       sample->temp = ao_ms5607_get_sample(AO_CONVERT_D2);
 }
 
 #include "ao_ms5607_convert.c"
index cf5951df5b90f42f0dbb598900728089a8c54693..64f4444fd0b008d73d824fd8b28816e560fc424d 100644 (file)
 #define AO_MS5607_CS_PORT      PORTB
 #define AO_MS5607_CS_PIN       3
 
+/* MS5607 */
 #define AO_MS5607_SPI_INDEX    0
 #define AO_MS5607_MISO_PORT    PORTB
 #define AO_MS5607_MISO_PIN     0
+#define AO_MS5607_BARO_OVERSAMPLE      4096
+#define AO_MS5607_TEMP_OVERSAMPLE      1024
 
 /* I2C */
 #define I2C_PORT               PORTB