Re-organised for two barometers

main-solar-only
Richard Meadows 2015-11-02 18:42:28 +00:00
rodzic 55de20a79c
commit 60e4aba272
8 zmienionych plików z 30 dodań i 55 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
/*
* BMP180 (also BMP085)
* Header for Barometer
* Copyright (C) 2014 Richard Meadows <richardeoin>
*
* 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.
*/
#ifndef BMP180_H
#define BMP180_H
#ifndef BAROMETER_H
#define BAROMETER_H
#include "samd20.h"
@ -37,6 +37,6 @@ struct barometer {
};
struct barometer* get_barometer(void);
void bmp180_init(void);
void barometer_init(void);
#endif /* BMP180_H */
#endif /* BAROMETER_H */

Wyświetl plik

@ -102,6 +102,12 @@
#define I2C_SERCOM_SCL_PIN PIN_PA01
#define I2C_SERCOM_SCL_PINMUX PINMUX_PA01D_SERCOM1_PAD1
/**
* Barometer
*/
#define BAROMETER_TYPE_BMP180 0
#define BAROMETER_TYPE_MS5607 1
/**
* Battery ADC
*/

Wyświetl plik

@ -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 */

Wyświetl plik

@ -26,9 +26,12 @@
#include <stdint.h>
#include "samd20.h"
#include "bmp180.h"
#include "sercom/i2c.h"
#include "hw_config.h"
#if BAROMETER_TYPE_BMP180
#include "barometer.h"
#include "sercom/i2c.h"
#define BMP180_ADDRESS 0xEE
#define BMP180_REG_ID 0xD0
@ -273,3 +276,5 @@ void bmp180_init(void)
/* Get the calibration parameters */
get_cal_param(&calibration);
}
#endif

Wyświetl plik

@ -29,7 +29,7 @@
#include "xosc.h"
#include "hw_config.h"
#include "analogue.h"
#include "bmp180.h"
#include "barometer.h"
#include "gps.h"
#include "ubx_messages.h"
#include "telemetry.h"

Wyświetl plik

@ -38,7 +38,7 @@
#include "data.h"
#include "memory.h"
#include "telemetry.h"
#include "bmp180.h"
#include "barometer.h"
#include "init.h"
/**

Wyświetl plik

@ -26,7 +26,11 @@
#include <stdint.h>
#include "samd20.h"
#include "ms5607.h"
#include "hw_config.h"
#if BAROMETER_TYPE_MS5607
#include "barometer.h"
#include "sercom/i2c.h"
#define MS5607_ADDRESS 0xEE
@ -160,7 +164,7 @@ void get_cal_param(struct calibration *c) {
uint32_t get_d1(void) {
/* Write command */
write_command(D1_COMMAND);
command(D1_COMMAND);
/* Wait?? */
@ -173,7 +177,7 @@ uint32_t get_d1(void) {
uint32_t get_d2(void) {
/* Write command */
write_command(D2_COMMAND);
command(D2_COMMAND);
/* Wait?? */
@ -238,3 +242,5 @@ void ms5607_init(void)
/* Get the calibration parameters */
get_cal_param(&calibration);
}
#endif

Wyświetl plik

@ -3,7 +3,7 @@
#endif
#include "samd20.h"
#include "bmp180.h"
#include "barometer.h"
/****************************//* pressure_temperature_tc *//****************************/
/**