mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-05 07:28:29 -04:00
uncrustify libraries/AP_Baro/AP_Baro_BMP085.cpp
This commit is contained in:
parent
b0003c020f
commit
5a99d6b697
@ -1,44 +1,44 @@
|
|||||||
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||||
/*
|
/*
|
||||||
APM_BMP085.cpp - Arduino Library for BMP085 absolute pressure sensor
|
* APM_BMP085.cpp - Arduino Library for BMP085 absolute pressure sensor
|
||||||
Code by Jordi Mu<EFBFBD>oz and Jose Julio. DIYDrones.com
|
* Code by Jordi Mu<EFBFBD>oz and Jose Julio. DIYDrones.com
|
||||||
|
*
|
||||||
This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
Sensor is conected to I2C port
|
* Sensor is conected to I2C port
|
||||||
Sensor End of Conversion (EOC) pin is PC7 (30)
|
* Sensor End of Conversion (EOC) pin is PC7 (30)
|
||||||
|
*
|
||||||
Variables:
|
* Variables:
|
||||||
RawTemp : Raw temperature data
|
* RawTemp : Raw temperature data
|
||||||
RawPress : Raw pressure data
|
* RawPress : Raw pressure data
|
||||||
|
*
|
||||||
Temp : Calculated temperature (in 0.1<EFBFBD>C units)
|
* Temp : Calculated temperature (in 0.1<EFBFBD>C units)
|
||||||
Press : Calculated pressure (in Pa units)
|
* Press : Calculated pressure (in Pa units)
|
||||||
|
*
|
||||||
Methods:
|
* Methods:
|
||||||
Init() : Initialization of I2C and read sensor calibration data
|
* Init() : Initialization of I2C and read sensor calibration data
|
||||||
Read() : Read sensor data and calculate Temperature and Pressure
|
* Read() : Read sensor data and calculate Temperature and Pressure
|
||||||
This function is optimized so the main host don<EFBFBD>t need to wait
|
* This function is optimized so the main host don<EFBFBD>t need to wait
|
||||||
You can call this function in your main loop
|
* You can call this function in your main loop
|
||||||
It returns a 1 if there are new data.
|
* It returns a 1 if there are new data.
|
||||||
|
*
|
||||||
Internal functions:
|
* Internal functions:
|
||||||
Command_ReadTemp(): Send commando to read temperature
|
* Command_ReadTemp(): Send commando to read temperature
|
||||||
Command_ReadPress(): Send commando to read Pressure
|
* Command_ReadPress(): Send commando to read Pressure
|
||||||
ReadTemp() : Read temp register
|
* ReadTemp() : Read temp register
|
||||||
ReadPress() : Read press register
|
* ReadPress() : Read press register
|
||||||
Calculate() : Calculate Temperature and Pressure in real units
|
* Calculate() : Calculate Temperature and Pressure in real units
|
||||||
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// AVR LibC Includes
|
// AVR LibC Includes
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
}
|
}
|
||||||
#if defined(ARDUINO) && ARDUINO >= 100
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
@ -58,7 +58,7 @@ extern "C" {
|
|||||||
// chip using a direct IO port
|
// chip using a direct IO port
|
||||||
// On APM2 prerelease hw, the data ready port is hooked up to PE7, which
|
// On APM2 prerelease hw, the data ready port is hooked up to PE7, which
|
||||||
// is not available to the arduino digitalRead function.
|
// is not available to the arduino digitalRead function.
|
||||||
#define BMP_DATA_READY() (_apm2_hardware?(PINE&0x80):digitalRead(BMP085_EOC))
|
#define BMP_DATA_READY() (_apm2_hardware ? (PINE&0x80) : digitalRead(BMP085_EOC))
|
||||||
|
|
||||||
// oversampling 3 gives highest resolution
|
// oversampling 3 gives highest resolution
|
||||||
#define OVERSAMPLING 3
|
#define OVERSAMPLING 3
|
||||||
@ -107,14 +107,14 @@ uint8_t AP_Baro_BMP085::read()
|
|||||||
{
|
{
|
||||||
uint8_t result = 0;
|
uint8_t result = 0;
|
||||||
|
|
||||||
if (BMP085_State == 1){
|
if (BMP085_State == 1) {
|
||||||
if (BMP_DATA_READY()){
|
if (BMP_DATA_READY()) {
|
||||||
BMP085_State = 2;
|
BMP085_State = 2;
|
||||||
ReadTemp(); // On state 1 we read temp
|
ReadTemp(); // On state 1 we read temp
|
||||||
Command_ReadPress();
|
Command_ReadPress();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (BMP_DATA_READY()){
|
if (BMP_DATA_READY()) {
|
||||||
BMP085_State = 1; // Start again from state = 1
|
BMP085_State = 1; // Start again from state = 1
|
||||||
ReadPress();
|
ReadPress();
|
||||||
Calculate();
|
Calculate();
|
||||||
|
Loading…
Reference in New Issue
Block a user