working with custom I2CX lib, see http://developer.mbed.org/questions/5107/Arch-BLE-I2C-working/#answer5383 esp answer by Joris Aerts.

Dependencies:   BMP085 I2CX mbed

Committer:
grassel
Date:
Tue Nov 04 19:22:15 2014 +0000
Revision:
1:b5fc2fd3546b
Parent:
0:6598b0ef16ac
working with custom I2CX for Nordic BLE, see http://developer.mbed.org/questions/5107/Arch-BLE-I2C-working/#answer5383 and esp the answer by Joris Aerts

Who changed what in which revision?

UserRevisionLine numberNew contents of line
grassel 0:6598b0ef16ac 1
grassel 0:6598b0ef16ac 2 #include "mbed.h"
grassel 0:6598b0ef16ac 3 #include "I2CX.h"
grassel 0:6598b0ef16ac 4 #include "BMP085.h"
grassel 0:6598b0ef16ac 5
grassel 0:6598b0ef16ac 6 // this little program onlu works with the modified mbed-src,
grassel 0:6598b0ef16ac 7 // see https://developer.mbed.org/questions/5107/Arch-BLE-I2C-working/#answer5390
grassel 0:6598b0ef16ac 8
grassel 0:6598b0ef16ac 9 int main(void)
grassel 0:6598b0ef16ac 10 {
grassel 0:6598b0ef16ac 11 printf("Creating i2c interface ...\r\n");
grassel 0:6598b0ef16ac 12 I2CX ic(I2C_0, p29, p28); // I2CName peripheral, pin sda, pin slc)
grassel 0:6598b0ef16ac 13 printf("Creating barometer interface ...\r\n");
grassel 0:6598b0ef16ac 14 BMP085 barometer(ic, BMP085_oss1);
grassel 0:6598b0ef16ac 15
grassel 0:6598b0ef16ac 16 float p = 0.0f, t = 0.0f;
grassel 0:6598b0ef16ac 17
grassel 0:6598b0ef16ac 18 printf("Entering main loop ...\r\n");
grassel 0:6598b0ef16ac 19 while(1) {
grassel 0:6598b0ef16ac 20 barometer.update();
grassel 0:6598b0ef16ac 21 p = barometer.get_pressure();
grassel 0:6598b0ef16ac 22 t = barometer.get_temperature();
grassel 0:6598b0ef16ac 23 printf("Pressure: %6.2f Temperature(c): %6.2f Temperature(F): %6.2f\r\n", p, t, 32 + t * 1.8f);
grassel 0:6598b0ef16ac 24 wait(1.0f);
grassel 0:6598b0ef16ac 25 }
grassel 0:6598b0ef16ac 26 }