1 /* 2 * Copyright (C) 2016-2017 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 29 #if !defined(LSM6DSM_LPS22HB_I2C_ADDRESS) 30 #error "LPS22HB i2c address macro not defined. Please check README file" 31 #endif /* LSM6DSM_LPS22HB_I2C_ADDRESS */ 32 33 #else /* LSM6DSM_I2C_MASTER_LPS22HB */ 34 #undef LSM6DSM_LPS22HB_I2C_ADDRESS 35 #define LSM6DSM_LPS22HB_I2C_ADDRESS 1 36 #endif /* LSM6DSM_I2C_MASTER_LPS22HB */ 37 38 #define LPS22HB_PRESS_KSCALE 0.000244140625f /* PRESS scale @1260hPa in hPa/LSB */ 39 #define LPS22HB_TEMP_KSCALE 0.01f /* TEMP scale in *C/LSB */ 40 #define LPS22HB_I2C_ADDRESS (LSM6DSM_LPS22HB_I2C_ADDRESS) 41 42 /* LPS22HB registers */ 43 #define LPS22HB_WAI_ADDR (0x0f) 44 #define LPS22HB_CTRL1_ADDR (0x10) 45 #define LPS22HB_CTRL2_ADDR (0x11) 46 #define LPS22HB_OUTDATA_ADDR (0x28) 47 48 #define LPS22HB_SW_RESET (0x04) 49 #define LPS22HB_POWER_ON_VALUE (0x00) 50 #define LPS22HB_POWER_OFF_VALUE (0x00) 51 #define LPS22HB_OUTDATA_LEN (0x05) 52 #define LPS22HB_OUTDATA_PRESS_BYTE 3 53 #define LPS22HB_OUTDATA_TEMP_BYTE 2 54 55 56 /* LPS22HB default base registers status */ 57 /* LPS22HB_CTRL1_BASE: control register 1 default settings */ 58 #define LPS22HB_CTRL1_BASE ((0 << 7) | /* (0) */ \ 59 (0 << 6) | /* ODR2 */ \ 60 (0 << 5) | /* ODR1 */ \ 61 (0 << 4) | /* ODR0 */ \ 62 (0 << 3) | /* EN_LPFP */ \ 63 (0 << 2) | /* LPF_CFG */ \ 64 (1 << 1) | /* BDU */ \ 65 (0 << 0)) /* SIM */ 66 67 /* LPS22HB_CTRL2_BASE: control register 2 default settings */ 68 #define LPS22HB_CTRL2_BASE ((0 << 7) | /* BOOT */ \ 69 (0 << 6) | /* FIFO_EN */ \ 70 (0 << 5) | /* STOP_ON_FTH */ \ 71 (1 << 4) | /* IF_ADD_INC */ \ 72 (0 << 3) | /* I2C_DIS */ \ 73 (0 << 2) | /* SWRESET */ \ 74 (0 << 1) | /* (0) */ \ 75 (0 << 0)) /* ONE_SHOT */ 76 77 #ifdef LSM6DSM_I2C_MASTER_LPS22HB 78 /* MUST BE SAME LENGTH OF LSM6DSMMagnRates */ 79 static uint8_t LPS22HBBaroRatesRegValue[] = { 80 0x20, /* Expected 0.8125Hz, ODR = 10Hz */ 81 0x20, /* Expected 1.625Hz, ODR = 10Hz */ 82 0x20, /* Expected 3.25Hz, ODR = 10Hz */ 83 0x20, /* Expected 6.5Hz, ODR = 10Hz */ 84 0x30, /* Expected 12.5Hz, ODR = 25Hz */ 85 0x40, /* Expected 26Hz, ODR = 50Hz */ 86 0x50, /* Expected 52Hz, ODR = 75Hz */ 87 0x50, /* Expected 104Hz, ODR = 75Hz */ 88 }; 89 #endif /* LSM6DSM_I2C_MASTER_LPS22HB */ 90 91 #endif /* __LSM6DSM_I2C_MASTER_LPS22HB__ */ 92