yashirou shimogamo / Mbed 2 deprecated BIRD2019

Dependencies:   mbed mbed-rtos SPI_MX25R

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Atmpress.h Source File

Atmpress.h

00001 #ifndef BIRD_SENSOR_ATMPRESS_H_
00002 #define BIRD_SENSOR_ATMPRESS_H_
00003 #include "mbed.h"
00004 #include "Global.h"
00005 
00006 #define LPS331_ADDRESS        0xB8
00007 
00008 #define LPS331_WHO_AM_I       0x0F
00009 
00010 #define LPS331_PRESS_OUT_XL   0x28
00011 #define LPS331_PRESS_OUT_L    0x29
00012 #define LPS331_PRESS_OUT_H    0x2A
00013 
00014 #define LPS331_TEMP_OUT_L     0x2B
00015 #define LPS331_TEMP_OUT_H     0x2C
00016 
00017 #define LPS331_CTRL_REG1      0x20
00018 #define LPS331_CTRL_REG2      0x21
00019 #define LPS331_CTRL_REG3      0x22
00020 
00021 
00022 class Atmpress {
00023     protected :
00024     I2C i2c;
00025     Timeout timeout;
00026     char readbyte(char cmd);
00027     int32_t addbyte(char xl, char l, char h);
00028     uint16_t addbyte(char l, char h);
00029     double calcpressure(int32_t raw);
00030     double calctemperature(uint16_t raw);
00031     
00032     public : 
00033     Atmpress(PinName sda, PinName scl);
00034     void init();
00035     double getpressure();
00036     double gettemperature();
00037     void update();
00038     
00039 };
00040 
00041 #endif