summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drivers/ao_ms5607.c18
-rw-r--r--src/micropeak/ao_pins.h3
2 files changed, 19 insertions, 2 deletions
diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c
index 55bea563..bd57400e 100644
--- a/src/drivers/ao_ms5607.c
+++ b/src/drivers/ao_ms5607.c
@@ -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"
diff --git a/src/micropeak/ao_pins.h b/src/micropeak/ao_pins.h
index cf5951df..64f4444f 100644
--- a/src/micropeak/ao_pins.h
+++ b/src/micropeak/ao_pins.h
@@ -41,9 +41,12 @@
#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