LPS331 library
See https://developer.mbed.org/users/yasuyuki/notebook/LPS331/
LPS331.h@0:ef4f624dc3ec, 2014-10-04 (annotated)
- Committer:
- yasuyuki
- Date:
- Sat Oct 04 12:02:25 2014 +0000
- Revision:
- 0:ef4f624dc3ec
- Child:
- 1:f70e671b008f
first release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yasuyuki | 0:ef4f624dc3ec | 1 | //********************** |
yasuyuki | 0:ef4f624dc3ec | 2 | // LPS331.h for mbed |
yasuyuki | 0:ef4f624dc3ec | 3 | // |
yasuyuki | 0:ef4f624dc3ec | 4 | // (C)Copyright 2014 All rights reserved by Y.Onodera |
yasuyuki | 0:ef4f624dc3ec | 5 | // http://einstlab.web.fc2.com |
yasuyuki | 0:ef4f624dc3ec | 6 | //********************** |
yasuyuki | 0:ef4f624dc3ec | 7 | |
yasuyuki | 0:ef4f624dc3ec | 8 | #ifndef LPS331_H_ |
yasuyuki | 0:ef4f624dc3ec | 9 | #define LPS331_H_ |
yasuyuki | 0:ef4f624dc3ec | 10 | |
yasuyuki | 0:ef4f624dc3ec | 11 | #define LPS331_ADDR 0xB8 |
yasuyuki | 0:ef4f624dc3ec | 12 | #define LPS331_REF_P_XL 0x08 |
yasuyuki | 0:ef4f624dc3ec | 13 | #define LPS331_REF_P_L 0x09 |
yasuyuki | 0:ef4f624dc3ec | 14 | #define LPS331_REF_P_H 0x0A |
yasuyuki | 0:ef4f624dc3ec | 15 | #define LPS331_WHO_AM_I 0x0F |
yasuyuki | 0:ef4f624dc3ec | 16 | #define LPS331_RES_CONF 0x10 |
yasuyuki | 0:ef4f624dc3ec | 17 | #define LPS331_CTRL_REG1 0x20 |
yasuyuki | 0:ef4f624dc3ec | 18 | #define LPS331_CTRL_REG2 0x21 |
yasuyuki | 0:ef4f624dc3ec | 19 | #define LPS331_CTRL_REG3 0x22 |
yasuyuki | 0:ef4f624dc3ec | 20 | #define LPS331_INT_CFG_REG 0x23 |
yasuyuki | 0:ef4f624dc3ec | 21 | #define LPS331_INT_SOURCE_REG 0x24 |
yasuyuki | 0:ef4f624dc3ec | 22 | #define LPS331_THS_P_LOW_REG 0x25 |
yasuyuki | 0:ef4f624dc3ec | 23 | #define LPS331_THS_P_HIGH_REG 0x26 |
yasuyuki | 0:ef4f624dc3ec | 24 | #define LPS331_STATUS_REG 0x27 |
yasuyuki | 0:ef4f624dc3ec | 25 | #define LPS331_PRESS_POUT_XL_REH 0x28 |
yasuyuki | 0:ef4f624dc3ec | 26 | #define LPS331_PRESS_OUT_L 0x29 |
yasuyuki | 0:ef4f624dc3ec | 27 | #define LPS331_PRESS_OUT_H 0x2A |
yasuyuki | 0:ef4f624dc3ec | 28 | #define LPS331_TEMP_OUT_L 0x2B |
yasuyuki | 0:ef4f624dc3ec | 29 | #define LPS331_TEMP_OUT_H 0x2C |
yasuyuki | 0:ef4f624dc3ec | 30 | #define LPS331_AMP_CTRL 0x2D |
yasuyuki | 0:ef4f624dc3ec | 31 | #define LPS331_DELTA_PRESS_XL 0x3C |
yasuyuki | 0:ef4f624dc3ec | 32 | #define LPS331_DELTA_PRESS_H 0x3D |
yasuyuki | 0:ef4f624dc3ec | 33 | #define LPS331_DELTA_PRESS_L 0x3E |
yasuyuki | 0:ef4f624dc3ec | 34 | |
yasuyuki | 0:ef4f624dc3ec | 35 | #include "mbed.h" |
yasuyuki | 0:ef4f624dc3ec | 36 | #include "typedef.h" |
yasuyuki | 0:ef4f624dc3ec | 37 | |
yasuyuki | 0:ef4f624dc3ec | 38 | class LPS331{ |
yasuyuki | 0:ef4f624dc3ec | 39 | public: |
yasuyuki | 0:ef4f624dc3ec | 40 | LPS331 (PinName sda, PinName scl); |
yasuyuki | 0:ef4f624dc3ec | 41 | LPS331 (I2C& p_i2c); |
yasuyuki | 0:ef4f624dc3ec | 42 | void init(); |
yasuyuki | 0:ef4f624dc3ec | 43 | |
yasuyuki | 0:ef4f624dc3ec | 44 | void put(unsigned char a, unsigned char b); |
yasuyuki | 0:ef4f624dc3ec | 45 | void get(unsigned char a); |
yasuyuki | 0:ef4f624dc3ec | 46 | long value(); |
yasuyuki | 0:ef4f624dc3ec | 47 | |
yasuyuki | 0:ef4f624dc3ec | 48 | protected: |
yasuyuki | 0:ef4f624dc3ec | 49 | |
yasuyuki | 0:ef4f624dc3ec | 50 | I2C _i2c; |
yasuyuki | 0:ef4f624dc3ec | 51 | |
yasuyuki | 0:ef4f624dc3ec | 52 | DWORD_VAL press; |
yasuyuki | 0:ef4f624dc3ec | 53 | char buf[2]; |
yasuyuki | 0:ef4f624dc3ec | 54 | |
yasuyuki | 0:ef4f624dc3ec | 55 | }; |
yasuyuki | 0:ef4f624dc3ec | 56 | |
yasuyuki | 0:ef4f624dc3ec | 57 | #endif /* LPS331_H_ */ |
yasuyuki | 0:ef4f624dc3ec | 58 | |
yasuyuki | 0:ef4f624dc3ec | 59 | |
yasuyuki | 0:ef4f624dc3ec | 60 |