1 /* 2 * Copyright (C) 2016 STMicroelectronics 3 * 4 * Author: Denis Ciocca <denis.ciocca@st.com> 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef __LSM6DSM_I2C_MASTER_LPS22HB__ 20 #define __LSM6DSM_I2C_MASTER_LPS22HB__ 21 22 #ifdef LSM6DSM_I2C_MASTER_LPS22HB 23 #ifndef LSM6DSM_I2C_MASTER_BAROMETER_ENABLED 24 #define LSM6DSM_I2C_MASTER_BAROMETER_ENABLED 1 25 #else /* LSM6DSM_I2C_MASTER_BAROMETER_ENABLED */ 26 #error "Another barometer is already selected! One baro per time can be used." 27 #endif /* LSM6DSM_I2C_MASTER_BAROMETER_ENABLED */ 28 #endif /* LSM6DSM_I2C_MASTER_LPS22HB */ 29 30 #define LPS22HB_PRESS_KSCALE 0.000244140625f /* PRESS scale @1260hPa in hPa/LSB */ 31 #define LPS22HB_TEMP_KSCALE 0.01f /* TEMP scale in *C/LSB */ 32 #define LPS22HB_I2C_ADDRESS (0x5d) /* SDO = 1 : 0x5d --- SDO = 0 : 0x5c */ 33 34 /* LPS22HB registers */ 35 #define LPS22HB_WAI_ADDR (0x0f) 36 #define LPS22HB_CTRL1_ADDR (0x10) 37 #define LPS22HB_CTRL2_ADDR (0x11) 38 #define LPS22HB_OUTDATA_ADDR (0x28) 39 40 #define LPS22HB_SW_RESET (0x04) 41 #define LPS22HB_POWER_ON_VALUE (0x00) 42 #define LPS22HB_POWER_OFF_VALUE (0x00) 43 #define LPS22HB_OUTDATA_LEN (0x05) 44 #define LPS22HB_OUTDATA_PRESS_BYTE 3 45 #define LPS22HB_OUTDATA_TEMP_BYTE 2 46 47 48 /* LPS22HB default base registers status */ 49 /* LPS22HB_CTRL1_BASE: control register 1 default settings */ 50 #define LPS22HB_CTRL1_BASE ((0 << 7) | /* (0) */ \ 51 (0 << 6) | /* ODR2 */ \ 52 (0 << 5) | /* ODR1 */ \ 53 (0 << 4) | /* ODR0 */ \ 54 (0 << 3) | /* EN_LPFP */ \ 55 (0 << 2) | /* LPF_CFG */ \ 56 (1 << 1) | /* BDU */ \ 57 (0 << 0)) /* SIM */ 58 59 /* LPS22HB_CTRL2_BASE: control register 2 default settings */ 60 #define LPS22HB_CTRL2_BASE ((0 << 7) | /* BOOT */ \ 61 (0 << 6) | /* FIFO_EN */ \ 62 (0 << 5) | /* STOP_ON_FTH */ \ 63 (1 << 4) | /* IF_ADD_INC */ \ 64 (0 << 3) | /* I2C_DIS */ \ 65 (0 << 2) | /* SWRESET */ \ 66 (0 << 1) | /* (0) */ \ 67 (0 << 0)) /* ONE_SHOT */ 68 69 #ifdef LSM6DSM_I2C_MASTER_LPS22HB 70 /* MUST BE SAME LENGTH OF LSM6DSMMagnRates */ 71 static uint8_t LPS22HBBaroRatesRegValue[] = { 72 0x20, /* Expected 3.25Hz, ODR = 10Hz */ 73 0x20, /* Expected 6.5Hz, ODR = 10Hz */ 74 0x30, /* Expected 12.5Hz, ODR = 25Hz */ 75 0x40, /* Expected 26Hz, ODR = 50Hz */ 76 0x50, /* Expected 52Hz, ODR = 75Hz */ 77 0x50, /* Expected 104Hz, ODR = 75Hz */ 78 }; 79 #endif /* LSM6DSM_I2C_MASTER_LPS22HB */ 80 81 #endif /* __LSM6DSM_I2C_MASTER_LPS22HB__ */ 82