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