![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Breath
Fork of Breath by
MPL3115.h@1:86d9b36d9132, 2016-12-01 (annotated)
- Committer:
- jamesmsong
- Date:
- Thu Dec 01 03:04:38 2016 +0000
- Revision:
- 1:86d9b36d9132
Breath
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jamesmsong | 1:86d9b36d9132 | 1 | /* Copyright (c) 2015 NXP Semiconductors. MIT License |
jamesmsong | 1:86d9b36d9132 | 2 | * |
jamesmsong | 1:86d9b36d9132 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
jamesmsong | 1:86d9b36d9132 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
jamesmsong | 1:86d9b36d9132 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
jamesmsong | 1:86d9b36d9132 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
jamesmsong | 1:86d9b36d9132 | 7 | * Software is furnished to do so, subject to the following conditions: |
jamesmsong | 1:86d9b36d9132 | 8 | * |
jamesmsong | 1:86d9b36d9132 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
jamesmsong | 1:86d9b36d9132 | 10 | * substantial portions of the Software. |
jamesmsong | 1:86d9b36d9132 | 11 | * |
jamesmsong | 1:86d9b36d9132 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
jamesmsong | 1:86d9b36d9132 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
jamesmsong | 1:86d9b36d9132 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
jamesmsong | 1:86d9b36d9132 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
jamesmsong | 1:86d9b36d9132 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
jamesmsong | 1:86d9b36d9132 | 17 | */ |
jamesmsong | 1:86d9b36d9132 | 18 | |
jamesmsong | 1:86d9b36d9132 | 19 | #ifndef MPL3115_H |
jamesmsong | 1:86d9b36d9132 | 20 | #define MPL3115_H |
jamesmsong | 1:86d9b36d9132 | 21 | #include "mbed.h" |
jamesmsong | 1:86d9b36d9132 | 22 | |
jamesmsong | 1:86d9b36d9132 | 23 | #define MPL3115_I2C_ADDRESS (0x60<<1) |
jamesmsong | 1:86d9b36d9132 | 24 | |
jamesmsong | 1:86d9b36d9132 | 25 | #define MPL3115_STATUS 0x00 |
jamesmsong | 1:86d9b36d9132 | 26 | #define MPL3115_WHO_AM_I 0x0C |
jamesmsong | 1:86d9b36d9132 | 27 | #define MPL3115_CTRL_REG1 0x26 |
jamesmsong | 1:86d9b36d9132 | 28 | #define MPL3115_CTRL_REG2 0x27 |
jamesmsong | 1:86d9b36d9132 | 29 | #define MPL3115_WHO_AM_I_VALUE 0xC4 |
jamesmsong | 1:86d9b36d9132 | 30 | |
jamesmsong | 1:86d9b36d9132 | 31 | class MPL3115 |
jamesmsong | 1:86d9b36d9132 | 32 | { |
jamesmsong | 1:86d9b36d9132 | 33 | public: |
jamesmsong | 1:86d9b36d9132 | 34 | |
jamesmsong | 1:86d9b36d9132 | 35 | MPL3115(PinName sda, PinName scl, int addr); |
jamesmsong | 1:86d9b36d9132 | 36 | |
jamesmsong | 1:86d9b36d9132 | 37 | void config(void); |
jamesmsong | 1:86d9b36d9132 | 38 | |
jamesmsong | 1:86d9b36d9132 | 39 | float getPressure(void); |
jamesmsong | 1:86d9b36d9132 | 40 | float getPressure(unsigned char reg); |
jamesmsong | 1:86d9b36d9132 | 41 | void readRegs(int addr, uint8_t * data, int len); |
jamesmsong | 1:86d9b36d9132 | 42 | |
jamesmsong | 1:86d9b36d9132 | 43 | private: |
jamesmsong | 1:86d9b36d9132 | 44 | I2C MPL3115_i2c; |
jamesmsong | 1:86d9b36d9132 | 45 | int m_addr; |
jamesmsong | 1:86d9b36d9132 | 46 | |
jamesmsong | 1:86d9b36d9132 | 47 | }; |
jamesmsong | 1:86d9b36d9132 | 48 | |
jamesmsong | 1:86d9b36d9132 | 49 | #endif |