kopia lustrzana https://github.com/bristol-seds/pico-tracker
Re-organised for two barometers
rodzic
55de20a79c
commit
60e4aba272
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* BMP180 (also BMP085)
|
* Header for Barometer
|
||||||
* Copyright (C) 2014 Richard Meadows <richardeoin>
|
* Copyright (C) 2014 Richard Meadows <richardeoin>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
@ -22,8 +22,8 @@
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BMP180_H
|
#ifndef BAROMETER_H
|
||||||
#define BMP180_H
|
#define BAROMETER_H
|
||||||
|
|
||||||
#include "samd20.h"
|
#include "samd20.h"
|
||||||
|
|
||||||
|
@ -37,6 +37,6 @@ struct barometer {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct barometer* get_barometer(void);
|
struct barometer* get_barometer(void);
|
||||||
void bmp180_init(void);
|
void barometer_init(void);
|
||||||
|
|
||||||
#endif /* BMP180_H */
|
#endif /* BAROMETER_H */
|
|
@ -102,6 +102,12 @@
|
||||||
#define I2C_SERCOM_SCL_PIN PIN_PA01
|
#define I2C_SERCOM_SCL_PIN PIN_PA01
|
||||||
#define I2C_SERCOM_SCL_PINMUX PINMUX_PA01D_SERCOM1_PAD1
|
#define I2C_SERCOM_SCL_PINMUX PINMUX_PA01D_SERCOM1_PAD1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barometer
|
||||||
|
*/
|
||||||
|
#define BAROMETER_TYPE_BMP180 0
|
||||||
|
#define BAROMETER_TYPE_MS5607 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Battery ADC
|
* Battery ADC
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* MS5607
|
|
||||||
* Copyright (C) 2015 Richard Meadows <richardeoin>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MS5607_H
|
|
||||||
#define MS5607_H
|
|
||||||
|
|
||||||
#include "samd20.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Barometer data structure
|
|
||||||
*/
|
|
||||||
struct barometer {
|
|
||||||
double temperature;
|
|
||||||
double pressure;
|
|
||||||
int valid; // 1 = valid, 0 = invalid
|
|
||||||
};
|
|
||||||
|
|
||||||
struct barometer* get_barometer(void);
|
|
||||||
void ms5607_init(void);
|
|
||||||
|
|
||||||
#endif /* MS5607_H */
|
|
|
@ -26,9 +26,12 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "samd20.h"
|
#include "samd20.h"
|
||||||
#include "bmp180.h"
|
#include "hw_config.h"
|
||||||
#include "sercom/i2c.h"
|
|
||||||
|
|
||||||
|
#if BAROMETER_TYPE_BMP180
|
||||||
|
|
||||||
|
#include "barometer.h"
|
||||||
|
#include "sercom/i2c.h"
|
||||||
|
|
||||||
#define BMP180_ADDRESS 0xEE
|
#define BMP180_ADDRESS 0xEE
|
||||||
#define BMP180_REG_ID 0xD0
|
#define BMP180_REG_ID 0xD0
|
||||||
|
@ -273,3 +276,5 @@ void bmp180_init(void)
|
||||||
/* Get the calibration parameters */
|
/* Get the calibration parameters */
|
||||||
get_cal_param(&calibration);
|
get_cal_param(&calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "xosc.h"
|
#include "xosc.h"
|
||||||
#include "hw_config.h"
|
#include "hw_config.h"
|
||||||
#include "analogue.h"
|
#include "analogue.h"
|
||||||
#include "bmp180.h"
|
#include "barometer.h"
|
||||||
#include "gps.h"
|
#include "gps.h"
|
||||||
#include "ubx_messages.h"
|
#include "ubx_messages.h"
|
||||||
#include "telemetry.h"
|
#include "telemetry.h"
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "telemetry.h"
|
#include "telemetry.h"
|
||||||
#include "bmp180.h"
|
#include "barometer.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,7 +26,11 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "samd20.h"
|
#include "samd20.h"
|
||||||
#include "ms5607.h"
|
#include "hw_config.h"
|
||||||
|
|
||||||
|
#if BAROMETER_TYPE_MS5607
|
||||||
|
|
||||||
|
#include "barometer.h"
|
||||||
#include "sercom/i2c.h"
|
#include "sercom/i2c.h"
|
||||||
|
|
||||||
#define MS5607_ADDRESS 0xEE
|
#define MS5607_ADDRESS 0xEE
|
||||||
|
@ -160,7 +164,7 @@ void get_cal_param(struct calibration *c) {
|
||||||
uint32_t get_d1(void) {
|
uint32_t get_d1(void) {
|
||||||
|
|
||||||
/* Write command */
|
/* Write command */
|
||||||
write_command(D1_COMMAND);
|
command(D1_COMMAND);
|
||||||
|
|
||||||
/* Wait?? */
|
/* Wait?? */
|
||||||
|
|
||||||
|
@ -173,7 +177,7 @@ uint32_t get_d1(void) {
|
||||||
uint32_t get_d2(void) {
|
uint32_t get_d2(void) {
|
||||||
|
|
||||||
/* Write command */
|
/* Write command */
|
||||||
write_command(D2_COMMAND);
|
command(D2_COMMAND);
|
||||||
|
|
||||||
/* Wait?? */
|
/* Wait?? */
|
||||||
|
|
||||||
|
@ -238,3 +242,5 @@ void ms5607_init(void)
|
||||||
/* Get the calibration parameters */
|
/* Get the calibration parameters */
|
||||||
get_cal_param(&calibration);
|
get_cal_param(&calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "samd20.h"
|
#include "samd20.h"
|
||||||
#include "bmp180.h"
|
#include "barometer.h"
|
||||||
|
|
||||||
/****************************//* pressure_temperature_tc *//****************************/
|
/****************************//* pressure_temperature_tc *//****************************/
|
||||||
/**
|
/**
|
||||||
|
|
Ładowanie…
Reference in New Issue