Port from Avnet's Internet Of Things full WiGo demo: SmartConfig - WebServer - Exosite - Android sensor Fusion App
Dependencies: NVIC_set_all_priorities mbed cc3000_hostdriver_mbedsocket TEMT6200 TSI Wi-Go_eCompass_Lib_V3 WiGo_BattCharger
MPL3115A2.h
00001 /* Copyright (c) 2010-2011 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef MPL3115A2_H 00020 #define MPL3115A2_H 00021 00022 #include "mbed.h" 00023 00024 // Oversampling value and minimum time between sample 00025 #define OVERSAMPLE_RATIO_1 0 // 6 ms 00026 #define OVERSAMPLE_RATIO_2 1 // 10 ms 00027 #define OVERSAMPLE_RATIO_4 2 // 18 ms 00028 #define OVERSAMPLE_RATIO_8 3 // 34 ms 00029 #define OVERSAMPLE_RATIO_16 4 // 66 ms 00030 #define OVERSAMPLE_RATIO_32 5 // 130 ms 00031 #define OVERSAMPLE_RATIO_64 6 // 258 ms 00032 #define OVERSAMPLE_RATIO_128 7 // 512 ms 00033 00034 /* Mode */ 00035 #define ALTIMETER_MODE 1 00036 #define BAROMETRIC_MODE 2 00037 00038 class MPL3115A2 00039 { 00040 public: 00041 /** 00042 * MPL3115A2 constructor 00043 * 00044 * @param sda SDA pin 00045 * @param sdl SCL pin 00046 * @param addr addr of the I2C peripheral 00047 */ 00048 MPL3115A2(PinName sda, PinName scl, int addr); 00049 00050 /** 00051 * Get the altimeter value in raw mode 00052 * 00053 * @param dt pointer to unsigned char array 00054 * @returns 1 if data are available, 0 if not. 00055 */ 00056 uint8_t getAltimeterRaw( unsigned char *dt); 00057 00058 /** 00059 * Get the temperature value in raw mode 00060 * 00061 * @param dt pointer to unsigned char array 00062 * @returns 1 if data are available, 0 if not. 00063 */ 00064 uint8_t getTemperatureRaw( unsigned char *dt); 00065 00066 /** 00067 * Return if there are date available 00068 * 00069 * @return 0 for no data available, bit0 set for Temp data available, bit1 set for Press/Alti data available 00070 * bit2 set for both Temp and Press/Alti data available 00071 */ 00072 uint8_t isDataAvailable( void); 00073 00074 private: 00075 I2C m_i2c; 00076 int m_addr; 00077 void readRegs(int addr, uint8_t * data, int len); 00078 void writeRegs(uint8_t * data, int len); 00079 }; 00080 00081 #endif
Generated on Thu Jul 14 2022 00:58:11 by 1.7.2