Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BMP085 by
Revision 2:dee533027e61, committed 2013-06-12
- Comitter:
- jose_claudiojr
- Date:
- Wed Jun 12 13:10:12 2013 +0000
- Parent:
- 1:80e4c62baf09
- Commit message:
- Bosh pressure sensor
Changed in this revision
--- a/BMP085.cpp Mon Dec 13 14:02:24 2010 +0000
+++ b/BMP085.cpp Wed Jun 12 13:10:12 2013 +0000
@@ -22,16 +22,8 @@
* @param p_scl port of I2C SCL
* @param p_oss parameter of OSS
*/
-BMP085::BMP085 (PinName p_sda, PinName p_scl, BMP085_oss p_oss) : i2c(p_sda, p_scl) {
- init(p_oss);
-}
-
-/**
- * @brief Initializes interface (public I2C)
- * @param p_i2c instance of I2C class
- * @param p_oss parameter of OSS
- */
-BMP085::BMP085 (I2C& p_i2c, BMP085_oss p_oss) : i2c(p_i2c) {
+BMP085::BMP085 (PinName sda, PinName scl, BMP085_oss p_oss): i2c(sda, scl)
+{
init(p_oss);
}
@@ -39,7 +31,8 @@
* @brief Get temperature
* @return temperature (`C)
*/
-float BMP085::get_temperature() {
+float BMP085::get_temperature()
+{
return temperature;
}
@@ -109,7 +102,8 @@
oss = p_oss;
}
-unsigned short BMP085::twi_readshort (int id, int addr) {
+unsigned short BMP085::twi_readshort (int id, int addr)
+{
unsigned short i;
i2c.start();
--- a/BMP085.h Mon Dec 13 14:02:24 2010 +0000
+++ b/BMP085.h Wed Jun 12 13:10:12 2013 +0000
@@ -1,23 +1,8 @@
-/*
- * mbed library to use a Bosch Sensortec BMP085 sensor
- * Copyright (c) 2010 Hiroshi Suga
- * Released under the MIT License: http://mbed.org/license/mit
- */
-
-/** @file BMP085.h
- * @brief mbed library to use a Bosch Sensortec BMP085 sensor
- * barometric pressure sensor BMP085 (Bosch Sensortec)
- * interface: I2C digital
- */
-
#ifndef BMP085_H
#define BMP085_H
#include "mbed.h"
-/**
- * @brief over sampling setting
- */
enum BMP085_oss {
BMP085_oss1 = 0, ///< ultra low power (1 time)
BMP085_oss2 = 1, ///< standard (2 times)
@@ -25,13 +10,10 @@
BMP085_oss8 = 3 ///< ultra high resolution (8 times)
};
-/**
- * @brief BMP085 class
- */
-class BMP085 : public Base {
+class BMP085
+{
public:
- BMP085(PinName p_sda, PinName p_scl, BMP085_oss p_oss = BMP085_oss1);
- BMP085(I2C& p_i2c, BMP085_oss p_oss = BMP085_oss1);
+ BMP085(PinName sda, PinName scl, BMP085_oss p_oss = BMP085_oss1);
float get_temperature();
float get_pressure();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jun 12 13:10:12 2013 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "BMP085.h"
+
+#include <math.h>
+
+#define SDA p9
+#define SCL p10
+#define PI 3.14159265
+
+Serial pc(USBTX, USBRX);
+//Serial pc(p28, p27);
+int main()
+{
+ float pres, temp;
+ pc.printf("Inicializing...\r\n");
+ BMP085 *bmp085 = new BMP085(SDA, SCL, BMP085_oss4);
+ printf("OK...\r\n");
+ wait(1);
+
+ while(1)
+ {
+
+ bmp085->update();
+ pres = bmp085->get_pressure();
+ temp = bmp085->get_temperature();
+
+
+ pc.printf("pressure: %f \t\ttemperature: %f \t\r\n", pres, temp);
+ wait_ms(200);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jun 12 13:10:12 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file
