wayne roberts
/
CB-LORA-MR_utility
test sending sensor results over lora radio. Accelerometer and temp/pressure.
Embed:
(wiki syntax)
Show/hide line numbers
LPS22HH_Driver.c
00001 /* 00002 ****************************************************************************** 00003 * @file lps22hh_reg.c 00004 * @author MEMS Software Solution Team 00005 * @date 14-December-2017 00006 * @brief LPS22HH driver file 00007 ****************************************************************************** 00008 * @attention 00009 * 00010 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00011 * 00012 * Redistribution and use in source and binary forms, with or without modification, 00013 * are permitted provided that the following conditions are met: 00014 * 1. Redistributions of source code must retain the above copyright notice, 00015 * this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright notice, 00017 * this list of conditions and the following disclaimer in the documentation 00018 * and/or other materials provided with the distribution. 00019 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00020 * may be used to endorse or promote products derived from this software 00021 * without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00026 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00027 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00028 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00029 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 */ 00035 00036 #include "LPS22HH_Driver.h" 00037 00038 /** 00039 * @addtogroup lps22hh 00040 * @brief This file provides a set of functions needed to drive the 00041 * lps22hh enanced inertial module. 00042 * @{ 00043 */ 00044 00045 /** 00046 * @addtogroup interfaces_functions 00047 * @brief This section provide a set of functions used to read and write 00048 * a generic register of the device. 00049 * @{ 00050 */ 00051 00052 /** 00053 * @brief Read generic device register 00054 * 00055 * @param lps22hh_ctx_t* ctx: read / write interface definitions 00056 * @param uint8_t reg: register to read 00057 * @param uint8_t* data: pointer to buffer that store the data read 00058 * @param uint16_t len: number of consecutive register to read 00059 * 00060 */ 00061 int32_t lps22hh_read_reg(lps22hh_ctx_t *ctx, uint8_t reg, uint8_t *data, 00062 uint16_t len) 00063 { 00064 return ctx->read_reg(ctx->handle, reg, data, len); 00065 } 00066 00067 /** 00068 * @brief Write generic device register 00069 * 00070 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00071 * @param uint8_t reg: register to write 00072 * @param uint8_t* data: pointer to data to write in register reg 00073 * @param uint16_t len: number of consecutive register to write 00074 * 00075 */ 00076 int32_t lps22hh_write_reg(lps22hh_ctx_t *ctx, uint8_t reg, uint8_t *data, 00077 uint16_t len) 00078 { 00079 return ctx->write_reg(ctx->handle, reg, data, len); 00080 } 00081 00082 /** 00083 * @} 00084 */ 00085 00086 /** 00087 * @addtogroup data_generation_c 00088 * @brief This section groups all the functions concerning data generation. 00089 * @{ 00090 */ 00091 00092 /** 00093 * @brief autozero_rst: [set] Reset Autozero function. 00094 * 00095 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00096 * @param uint8_t val: change the values of reset_az in reg INTERRUPT_CFG 00097 * 00098 */ 00099 int32_t lps22hh_autozero_rst_set(lps22hh_ctx_t *ctx, uint8_t val) 00100 { 00101 lps22hh_reg_t reg; 00102 int32_t mm_error; 00103 00104 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00105 reg.interrupt_cfg.reset_az = val; 00106 mm_error = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00107 00108 return mm_error; 00109 } 00110 00111 /** 00112 * @brief autozero_rst: [get] Reset Autozero function. 00113 * 00114 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00115 * @param uint8_t: change the values of reset_az in reg INTERRUPT_CFG 00116 * 00117 */ 00118 int32_t lps22hh_autozero_rst_get(lps22hh_ctx_t *ctx, uint8_t *val) 00119 { 00120 lps22hh_reg_t reg; 00121 int32_t mm_error; 00122 00123 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00124 *val = reg.interrupt_cfg.reset_az; 00125 00126 return mm_error; 00127 } 00128 00129 /** 00130 * @brief autozero: [set] Enable Autozero function. 00131 * 00132 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00133 * @param uint8_t val: change the values of autozero in reg INTERRUPT_CFG 00134 * 00135 */ 00136 int32_t lps22hh_autozero_set(lps22hh_ctx_t *ctx, uint8_t val) 00137 { 00138 lps22hh_reg_t reg; 00139 int32_t mm_error; 00140 00141 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00142 reg.interrupt_cfg.autozero = val; 00143 mm_error = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00144 00145 return mm_error; 00146 } 00147 00148 /** 00149 * @brief autozero: [get] Enable Autozero function. 00150 * 00151 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00152 * @param uint8_t: change the values of autozero in reg INTERRUPT_CFG 00153 * 00154 */ 00155 int32_t lps22hh_autozero_get(lps22hh_ctx_t *ctx, uint8_t *val) 00156 { 00157 lps22hh_reg_t reg; 00158 int32_t mm_error; 00159 00160 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00161 *val = reg.interrupt_cfg.autozero; 00162 00163 return mm_error; 00164 } 00165 00166 /** 00167 * @brief pressure_snap_rst: [set] Reset AutoRifP function. 00168 * 00169 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00170 * @param uint8_t val: change the values of reset_arp in reg INTERRUPT_CFG 00171 * 00172 */ 00173 int32_t lps22hh_pressure_snap_rst_set(lps22hh_ctx_t *ctx, uint8_t val) 00174 { 00175 lps22hh_reg_t reg; 00176 int32_t mm_error; 00177 00178 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00179 reg.interrupt_cfg.reset_arp = val; 00180 mm_error = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00181 00182 return mm_error; 00183 } 00184 00185 /** 00186 * @brief pressure_snap_rst: [get] Reset AutoRifP function. 00187 * 00188 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00189 * @param uint8_t: change the values of reset_arp in reg INTERRUPT_CFG 00190 * 00191 */ 00192 int32_t lps22hh_pressure_snap_rst_get(lps22hh_ctx_t *ctx, uint8_t *val) 00193 { 00194 lps22hh_reg_t reg; 00195 int32_t mm_error; 00196 00197 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00198 *val = reg.interrupt_cfg.reset_arp; 00199 00200 return mm_error; 00201 } 00202 00203 /** 00204 * @brief pressure_snap: [set] Enable AutoRifP function. 00205 * 00206 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00207 * @param uint8_t val: change the values of autorifp in reg INTERRUPT_CFG 00208 * 00209 */ 00210 int32_t lps22hh_pressure_snap_set(lps22hh_ctx_t *ctx, uint8_t val) 00211 { 00212 lps22hh_reg_t reg; 00213 int32_t mm_error; 00214 00215 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00216 reg.interrupt_cfg.autorifp = val; 00217 mm_error = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00218 00219 return mm_error; 00220 } 00221 00222 /** 00223 * @brief pressure_snap: [get] Enable AutoRifP function. 00224 * 00225 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00226 * @param uint8_t: change the values of autorifp in reg INTERRUPT_CFG 00227 * 00228 */ 00229 int32_t lps22hh_pressure_snap_get(lps22hh_ctx_t *ctx, uint8_t *val) 00230 { 00231 lps22hh_reg_t reg; 00232 int32_t mm_error; 00233 00234 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00235 *val = reg.interrupt_cfg.autorifp; 00236 00237 return mm_error; 00238 } 00239 00240 /** 00241 * @brief block_data_update: [set] Blockdataupdate. 00242 * 00243 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00244 * @param uint8_t val: change the values of bdu in reg CTRL_REG1 00245 * 00246 */ 00247 int32_t lps22hh_block_data_update_set(lps22hh_ctx_t *ctx, uint8_t val) 00248 { 00249 lps22hh_reg_t reg; 00250 int32_t mm_error; 00251 00252 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00253 reg.ctrl_reg1.bdu = val; 00254 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00255 00256 return mm_error; 00257 } 00258 00259 /** 00260 * @brief block_data_update: [get] Blockdataupdate. 00261 * 00262 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00263 * @param uint8_t: change the values of bdu in reg CTRL_REG1 00264 * 00265 */ 00266 int32_t lps22hh_block_data_update_get(lps22hh_ctx_t *ctx, uint8_t *val) 00267 { 00268 lps22hh_reg_t reg; 00269 int32_t mm_error; 00270 00271 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00272 *val = reg.ctrl_reg1.bdu; 00273 00274 return mm_error; 00275 } 00276 00277 /** 00278 * @brief data_rate: [set] Output data rate selection. 00279 * 00280 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00281 * @param lps22hh_odr_t: change the values of odr in reg CTRL_REG1 00282 * 00283 */ 00284 int32_t lps22hh_data_rate_set(lps22hh_ctx_t *ctx, lps22hh_odr_t val) 00285 { 00286 lps22hh_reg_t reg[2]; 00287 int32_t mm_error; 00288 00289 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®[0].byte, 2); 00290 reg[0].ctrl_reg1.odr = val & 0x03; 00291 reg[1].ctrl_reg2.low_noise_en = (val & 0x10) >> 4; 00292 reg[1].ctrl_reg2.one_shot = (val & 0x08) >> 3; 00293 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, ®[0].byte, 2); 00294 00295 return mm_error; 00296 } 00297 00298 /** 00299 * @brief data_rate: [get] Output data rate selection. 00300 * 00301 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00302 * @param lps22hh_odr_t: Get the values of odr in reg CTRL_REG1 00303 * 00304 */ 00305 int32_t lps22hh_data_rate_get(lps22hh_ctx_t *ctx, lps22hh_odr_t *val) 00306 { 00307 lps22hh_reg_t reg[2]; 00308 int32_t mm_error; 00309 00310 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®[0].byte, 2); 00311 *val = (lps22hh_odr_t)((reg[1].ctrl_reg2.low_noise_en << 4) + 00312 (reg[1].ctrl_reg2.one_shot << 3) + reg[0].ctrl_reg1.odr); 00313 00314 return mm_error; 00315 } 00316 00317 /** 00318 * @brief pressure_ref: [set] The Reference pressure value is a 16-bit data 00319 * expressed as 2’s complement. The value is used 00320 * when AUTOZERO or AUTORIFP function is enabled. 00321 * 00322 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00323 * @param uint8_t * : buffer that contains data to write 00324 * 00325 */ 00326 int32_t lps22hh_pressure_ref_set(lps22hh_ctx_t *ctx, uint8_t *buff) 00327 { 00328 return lps22hh_write_reg(ctx, LPS22HH_REF_P_XL, buff, 2); 00329 } 00330 00331 /** 00332 * @brief pressure_ref: [get] The Reference pressure value is a 16-bit 00333 * data expressed as 2’s complement. 00334 * The value is used when AUTOZERO or AUTORIFP 00335 * function is enabled. 00336 * 00337 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00338 * @param uint8_t * : buffer that stores data read 00339 * 00340 */ 00341 int32_t lps22hh_pressure_ref_get(lps22hh_ctx_t *ctx, uint8_t *buff) 00342 { 00343 return lps22hh_read_reg(ctx, LPS22HH_REF_P_XL, buff, 2); 00344 } 00345 00346 /** 00347 * @brief pressure_offset: [set] The pressure offset value is 16-bit data 00348 * that can be used to implement one-point 00349 * calibration (OPC) after soldering. 00350 * 00351 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00352 * @param uint8_t * : buffer that contains data to write 00353 * 00354 */ 00355 int32_t lps22hh_pressure_offset_set(lps22hh_ctx_t *ctx, uint8_t *buff) 00356 { 00357 return lps22hh_write_reg(ctx, LPS22HH_RPDS_L, buff, 2); 00358 } 00359 00360 /** 00361 * @brief pressure_offset: [get] The pressure offset value is 16-bit 00362 * data that can be used to implement 00363 * one-point calibration (OPC) after 00364 * soldering. 00365 * 00366 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00367 * @param uint8_t * : buffer that stores data read 00368 * 00369 */ 00370 int32_t lps22hh_pressure_offset_get(lps22hh_ctx_t *ctx, uint8_t *buff) 00371 { 00372 return lps22hh_read_reg(ctx, LPS22HH_RPDS_L, buff, 2); 00373 } 00374 00375 /** 00376 * @brief all_sources: [get] Read all the interrupt/status flag of 00377 * the device. 00378 * 00379 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00380 * @param lps22hh_all_sources: registers STATUS,FIFO_STATUS2,INT_SOURCE 00381 * 00382 */ 00383 int32_t lps22hh_all_sources_get(lps22hh_ctx_t *ctx, lps22hh_all_sources_t *val) 00384 { 00385 lps22hh_reg_t reg[3]; 00386 int32_t mm_error; 00387 00388 mm_error = lps22hh_read_reg(ctx, LPS22HH_INT_SOURCE, ®[0].byte, 1); 00389 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, ®[1].byte, 2); 00390 00391 val->int_source = reg[0].int_source; 00392 val->fifo_status2 = reg[1].fifo_status2; 00393 val->status = reg[2].status; 00394 00395 return mm_error; 00396 } 00397 00398 /** 00399 * @brief status_reg: [get] The STATUS_REG register is read by 00400 * the primary interface 00401 * 00402 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00403 * @param lps22hh_: union of registers from STATUS to STATUS_REG 00404 * 00405 */ 00406 int32_t lps22hh_status_reg_get(lps22hh_ctx_t *ctx, lps22hh_status_t *val) 00407 { 00408 return lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t *) val, 1); 00409 } 00410 00411 /** 00412 * @brief press_flag_data_ready: [get] Pressure new data available. 00413 * 00414 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00415 * @param uint8_t: change the values of p_da in reg STATUS 00416 * 00417 */ 00418 int32_t lps22hh_press_flag_data_ready_get(lps22hh_ctx_t *ctx, uint8_t *val) 00419 { 00420 lps22hh_reg_t reg; 00421 int32_t mm_error; 00422 00423 mm_error = lps22hh_read_reg(ctx, LPS22HH_STATUS, ®.byte, 1); 00424 *val = reg.status.p_da; 00425 00426 return mm_error; 00427 } 00428 00429 /** 00430 * @brief temp_flag_data_ready: [get] Temperature data available. 00431 * 00432 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00433 * @param uint8_t: change the values of t_da in reg STATUS 00434 * 00435 */ 00436 int32_t lps22hh_temp_flag_data_ready_get(lps22hh_ctx_t *ctx, uint8_t *val) 00437 { 00438 lps22hh_reg_t reg; 00439 int32_t mm_error; 00440 00441 mm_error = lps22hh_read_reg(ctx, LPS22HH_STATUS, ®.byte, 1); 00442 *val = reg.status.t_da; 00443 00444 return mm_error; 00445 } 00446 00447 /** 00448 * @} 00449 */ 00450 00451 /** 00452 * @addtogroup data_output 00453 * @brief This section groups all the data output functions. 00454 * @{ 00455 */ 00456 00457 /** 00458 * @brief pressure_raw: [get] Pressure output value. 00459 * 00460 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00461 * @param uint8_t * : buffer that stores data read 00462 * 00463 */ 00464 int32_t lps22hh_pressure_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff) 00465 { 00466 return lps22hh_read_reg(ctx, LPS22HH_PRESSURE_OUT_XL, buff, 3); 00467 } 00468 00469 /** 00470 * @brief temperature_raw: [get] Temperature output value. 00471 * 00472 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00473 * @param uint8_t * : buffer that stores data read 00474 * 00475 */ 00476 int32_t lps22hh_temperature_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff) 00477 { 00478 return lps22hh_read_reg(ctx, LPS22HH_TEMP_OUT_L, buff, 2); 00479 } 00480 00481 /** 00482 * @brief fifo_pressure_raw: [get] Pressure output from FIFO value. 00483 * 00484 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00485 * @param uint8_t * : buffer that stores data read 00486 * 00487 */ 00488 int32_t lps22hh_fifo_pressure_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff) 00489 { 00490 return lps22hh_read_reg(ctx, LPS22HH_FIFO_DATA_OUT_PRESS_XL, buff, 3); 00491 } 00492 00493 /** 00494 * @brief fifo_temperature_raw: [get] Temperature output from FIFO value. 00495 * 00496 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00497 * @param uint8_t * : buffer that stores data read 00498 * 00499 */ 00500 int32_t lps22hh_fifo_temperature_raw_get(lps22hh_ctx_t *ctx, uint8_t *buff) 00501 { 00502 return lps22hh_read_reg(ctx, LPS22HH_FIFO_DATA_OUT_TEMP_L, buff, 2); 00503 } 00504 00505 /** 00506 * @} 00507 */ 00508 00509 /** 00510 * @addtogroup common 00511 * @brief This section groups common usefull functions. 00512 * @{ 00513 */ 00514 00515 /** 00516 * @brief device_id: [get] DeviceWhoamI 00517 * 00518 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00519 * @param uint8_t * : buffer that stores data read 00520 * 00521 */ 00522 int32_t lps22hh_device_id_get(lps22hh_ctx_t *ctx, uint8_t *buff) 00523 { 00524 return lps22hh_read_reg(ctx, LPS22HH_WHO_AM_I, buff, 1); 00525 } 00526 00527 /** 00528 * @brief reset: [set] Software reset. Restore the default values 00529 * in user registers. 00530 * 00531 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00532 * @param uint8_t val: change the values of swreset in reg CTRL_REG2 00533 * 00534 */ 00535 int32_t lps22hh_reset_set(lps22hh_ctx_t *ctx, uint8_t val) 00536 { 00537 lps22hh_reg_t reg; 00538 int32_t mm_error; 00539 00540 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00541 reg.ctrl_reg2.swreset = val; 00542 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00543 00544 return mm_error; 00545 } 00546 00547 /** 00548 * @brief reset: [get] Software reset. Restore the default values 00549 * in user registers. 00550 * 00551 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00552 * @param uint8_t: change the values of swreset in reg CTRL_REG2 00553 * 00554 */ 00555 int32_t lps22hh_reset_get(lps22hh_ctx_t *ctx, uint8_t *val) 00556 { 00557 lps22hh_reg_t reg; 00558 int32_t mm_error; 00559 00560 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00561 *val = reg.ctrl_reg2.swreset; 00562 00563 return mm_error; 00564 } 00565 00566 /** 00567 * @brief auto_increment: [set] Register address automatically 00568 * incremented during a multiple byte access 00569 * with a serial interface. 00570 * 00571 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00572 * @param uint8_t val: change the values of if_add_inc in reg CTRL_REG2 00573 * 00574 */ 00575 int32_t lps22hh_auto_increment_set(lps22hh_ctx_t *ctx, uint8_t val) 00576 { 00577 lps22hh_reg_t reg; 00578 int32_t mm_error; 00579 00580 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00581 reg.ctrl_reg2.if_add_inc = val; 00582 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00583 00584 return mm_error; 00585 } 00586 00587 /** 00588 * @brief auto_increment: [get] Register address automatically 00589 * incremented during a multiple byte 00590 * access with a serial interface. 00591 * 00592 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00593 * @param uint8_t: change the values of if_add_inc in reg CTRL_REG2 00594 * 00595 */ 00596 int32_t lps22hh_auto_increment_get(lps22hh_ctx_t *ctx, uint8_t *val) 00597 { 00598 lps22hh_reg_t reg; 00599 int32_t mm_error; 00600 00601 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00602 *val = reg.ctrl_reg2.if_add_inc; 00603 00604 return mm_error; 00605 } 00606 00607 /** 00608 * @brief boot: [set] Reboot memory content. Reload the calibration 00609 * parameters. 00610 * 00611 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00612 * @param uint8_t val: change the values of boot in reg CTRL_REG2 00613 * 00614 */ 00615 int32_t lps22hh_boot_set(lps22hh_ctx_t *ctx, uint8_t val) 00616 { 00617 lps22hh_reg_t reg; 00618 int32_t mm_error; 00619 00620 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00621 reg.ctrl_reg2.boot = val; 00622 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00623 00624 return mm_error; 00625 } 00626 00627 /** 00628 * @brief boot: [get] Reboot memory content. Reload the calibration 00629 * parameters. 00630 * 00631 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00632 * @param uint8_t: change the values of boot in reg CTRL_REG2 00633 * 00634 */ 00635 int32_t lps22hh_boot_get(lps22hh_ctx_t *ctx, uint8_t *val) 00636 { 00637 lps22hh_reg_t reg; 00638 int32_t mm_error; 00639 00640 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00641 *val = reg.ctrl_reg2.boot; 00642 00643 return mm_error; 00644 } 00645 00646 /** 00647 * @} 00648 */ 00649 00650 /** 00651 * @addtogroup filters 00652 * @brief This section group all the functions concerning the 00653 * filters configuration. 00654 * @{ 00655 */ 00656 00657 /** 00658 * @brief lp_bandwidth: [set] Low-pass bandwidth selection. 00659 * 00660 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00661 * @param lps22hh_lpfp_cfg_t: change the values of lpfp_cfg in 00662 * reg CTRL_REG1 00663 * 00664 */ 00665 int32_t lps22hh_lp_bandwidth_set(lps22hh_ctx_t *ctx, lps22hh_lpfp_cfg_t val) 00666 { 00667 lps22hh_reg_t reg; 00668 int32_t mm_error; 00669 00670 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00671 reg.ctrl_reg1.lpfp_cfg = val; 00672 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00673 00674 return mm_error; 00675 } 00676 00677 /** 00678 * @brief lp_bandwidth: [get] Low-pass bandwidth selection. 00679 * 00680 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00681 * @param lps22hh_lpfp_cfg_t: Get the values of lpfp_cfg in reg CTRL_REG1 00682 * 00683 */ 00684 int32_t lps22hh_lp_bandwidth_get(lps22hh_ctx_t *ctx, lps22hh_lpfp_cfg_t *val) 00685 { 00686 lps22hh_reg_t reg; 00687 int32_t mm_error; 00688 00689 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00690 *val = (lps22hh_lpfp_cfg_t) reg.ctrl_reg1.lpfp_cfg; 00691 00692 return mm_error; 00693 } 00694 00695 /** 00696 * @} 00697 */ 00698 00699 /** 00700 * @addtogroup serial_interface 00701 * @brief This section groups all the functions concerning serial 00702 * interface management 00703 * @{ 00704 */ 00705 00706 /** 00707 * @brief i2c_interface: [set] Enable/Disable I2C interface. 00708 * 00709 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00710 * @param lps22hh_i2c_disable_t: change the values of i2c_disable in 00711 * reg IF_CTRL 00712 * 00713 */ 00714 int32_t lps22hh_i2c_interface_set(lps22hh_ctx_t *ctx, 00715 lps22hh_i2c_disable_t val) 00716 { 00717 lps22hh_reg_t reg; 00718 int32_t mm_error; 00719 00720 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00721 reg.if_ctrl.i2c_disable = val; 00722 mm_error = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00723 00724 return mm_error; 00725 } 00726 00727 /** 00728 * @brief i2c_interface: [get] Enable/Disable I2C interface. 00729 * 00730 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00731 * @param lps22hh_i2c_disable_t: Get the values of i2c_disable in reg 00732 * IF_CTRL 00733 * 00734 */ 00735 int32_t lps22hh_i2c_interface_get(lps22hh_ctx_t *ctx, 00736 lps22hh_i2c_disable_t *val) 00737 { 00738 lps22hh_reg_t reg; 00739 int32_t mm_error; 00740 00741 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00742 *val = (lps22hh_i2c_disable_t) reg.if_ctrl.i2c_disable; 00743 00744 return mm_error; 00745 } 00746 00747 /** 00748 * @brief i3c_interface: [set] I3C Enable/Disable communication protocol 00749 * 00750 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00751 * @param uint8_t lps22hh_i3c_disable_t: change the values of int_en_i3c in 00752 * reg IF_CTRL 00753 * 00754 */ 00755 int32_t lps22hh_i3c_interface_set(lps22hh_ctx_t *ctx, 00756 lps22hh_i3c_disable_t val) 00757 { 00758 lps22hh_reg_t reg; 00759 int32_t mm_error; 00760 00761 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00762 reg.if_ctrl.i3c_disable = (val & 0x01); 00763 reg.if_ctrl.int_en_i3c = (val & 0x10) >> 4; 00764 mm_error = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00765 00766 return mm_error; 00767 } 00768 00769 /** 00770 * @brief i3c_interface: [get] I3C Enable/Disable communication protocol 00771 * 00772 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00773 * @param lps22hh_i3c_disable_t: change the values of int_en_i3c in reg 00774 * IF_CTRL 00775 * 00776 */ 00777 int32_t lps22hh_i3c_interface_get(lps22hh_ctx_t *ctx, 00778 lps22hh_i3c_disable_t *val) 00779 { 00780 lps22hh_reg_t reg; 00781 int32_t mm_error; 00782 00783 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00784 *val = (lps22hh_i3c_disable_t)((reg.if_ctrl.int_en_i3c << 4) + 00785 reg.if_ctrl.int_en_i3c); 00786 00787 return mm_error; 00788 } 00789 00790 /** 00791 * @brief sdo_sa0_mode: [set] Enable/Disable pull-up on SDO pin. 00792 * 00793 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00794 * @param lps22hh_sdo_pu_en_t: change the values of sdo_pu_en in reg 00795 * IF_CTRL 00796 * 00797 */ 00798 int32_t lps22hh_sdo_sa0_mode_set(lps22hh_ctx_t *ctx, lps22hh_pu_en_t val) 00799 { 00800 lps22hh_reg_t reg; 00801 int32_t mm_error; 00802 00803 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00804 reg.if_ctrl.sdo_pu_en = val; 00805 mm_error = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00806 00807 return mm_error; 00808 } 00809 00810 /** 00811 * @brief sdo_sa0_mode: [get] Enable/Disable pull-up on SDO pin. 00812 * 00813 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00814 * @param lps22hh_sdo_pu_en_t: Get the values of sdo_pu_en in reg IF_CTRL 00815 * 00816 */ 00817 int32_t lps22hh_sdo_sa0_mode_get(lps22hh_ctx_t *ctx, lps22hh_pu_en_t *val) 00818 { 00819 lps22hh_reg_t reg; 00820 int32_t mm_error; 00821 00822 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00823 *val = (lps22hh_pu_en_t) reg.if_ctrl.sdo_pu_en; 00824 00825 return mm_error; 00826 } 00827 00828 /** 00829 * @brief sda_mode: [set] Connect/Disconnect SDO/SA0 internal pull-up. 00830 * 00831 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00832 * @param lps22hh_sda_pu_en_t: change the values of sda_pu_en in reg 00833 * IF_CTRL 00834 * 00835 */ 00836 int32_t lps22hh_sda_mode_set(lps22hh_ctx_t *ctx, lps22hh_pu_en_t val) 00837 { 00838 lps22hh_reg_t reg; 00839 int32_t mm_error; 00840 00841 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00842 reg.if_ctrl.sda_pu_en = val; 00843 mm_error = lps22hh_write_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00844 00845 return mm_error; 00846 } 00847 00848 /** 00849 * @brief sda_mode: [get] Connect/Disconnect SDO/SA0 internal pull-up. 00850 * 00851 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00852 * @param lps22hh_sda_pu_en_t: Get the values of sda_pu_en in reg IF_CTRL 00853 * 00854 */ 00855 int32_t lps22hh_sda_mode_get(lps22hh_ctx_t *ctx, lps22hh_pu_en_t *val) 00856 { 00857 lps22hh_reg_t reg; 00858 int32_t mm_error; 00859 00860 mm_error = lps22hh_read_reg(ctx, LPS22HH_IF_CTRL, ®.byte, 1); 00861 *val = (lps22hh_pu_en_t) reg.if_ctrl.sda_pu_en; 00862 00863 return mm_error; 00864 } 00865 00866 /** 00867 * @brief spi_mode: [set] SPI Serial Interface Mode selection. 00868 * 00869 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00870 * @param lps22hh_sim_t: change the values of sim in reg CTRL_REG1 00871 * 00872 */ 00873 int32_t lps22hh_spi_mode_set(lps22hh_ctx_t *ctx, lps22hh_sim_t val) 00874 { 00875 lps22hh_reg_t reg; 00876 int32_t mm_error; 00877 00878 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00879 reg.ctrl_reg1.sim = val; 00880 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00881 00882 return mm_error; 00883 } 00884 00885 /** 00886 * @brief spi_mode: [get] SPI Serial Interface Mode selection. 00887 * 00888 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00889 * @param lps22hh_sim_t: Get the values of sim in reg CTRL_REG1 00890 * 00891 */ 00892 int32_t lps22hh_spi_mode_get(lps22hh_ctx_t *ctx, lps22hh_sim_t *val) 00893 { 00894 lps22hh_reg_t reg; 00895 int32_t mm_error; 00896 00897 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG1, ®.byte, 1); 00898 *val = (lps22hh_sim_t) reg.ctrl_reg1.sim; 00899 00900 return mm_error; 00901 } 00902 00903 /** 00904 * @} 00905 */ 00906 00907 /** 00908 * @addtogroup interrupt_pins 00909 * @brief This section groups all the functions that manage interrupt pins. 00910 * @{ 00911 */ 00912 00913 /** 00914 * @brief int_notification: [set] Latch interrupt request to the 00915 * INT_SOURCE (24h) register. 00916 * 00917 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00918 * @param lps22hh_lir_t: change the values of lir in reg INTERRUPT_CFG 00919 * 00920 */ 00921 int32_t lps22hh_int_notification_set(lps22hh_ctx_t *ctx, lps22hh_lir_t val) 00922 { 00923 lps22hh_reg_t reg; 00924 int32_t mm_error; 00925 00926 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00927 reg.interrupt_cfg.lir = val; 00928 mm_error = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00929 00930 return mm_error; 00931 } 00932 00933 /** 00934 * @brief int_notification: [get] Latch interrupt request to the 00935 * INT_SOURCE (24h) register. 00936 * 00937 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00938 * @param lps22hh_lir_t: Get the values of lir in reg INTERRUPT_CFG 00939 * 00940 */ 00941 int32_t lps22hh_int_notification_get(lps22hh_ctx_t *ctx, lps22hh_lir_t *val) 00942 { 00943 lps22hh_reg_t reg; 00944 int32_t mm_error; 00945 00946 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 00947 *val = (lps22hh_lir_t) reg.interrupt_cfg.lir; 00948 00949 return mm_error; 00950 } 00951 00952 /** 00953 * @brief pin_mode: [set] Push-pull/open drain selection on interrupt pads. 00954 * 00955 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00956 * @param lps22hh_pp_od_t: change the values of pp_od in reg CTRL_REG2 00957 * 00958 */ 00959 int32_t lps22hh_pin_mode_set(lps22hh_ctx_t *ctx, lps22hh_pp_od_t val) 00960 { 00961 lps22hh_reg_t reg; 00962 int32_t mm_error; 00963 00964 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00965 reg.ctrl_reg2.pp_od = val; 00966 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00967 00968 return mm_error; 00969 } 00970 00971 /** 00972 * @brief pin_mode: [get] Push-pull/open drain selection on interrupt pads. 00973 * 00974 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00975 * @param lps22hh_pp_od_t: Get the values of pp_od in reg CTRL_REG2 00976 * 00977 */ 00978 int32_t lps22hh_pin_mode_get(lps22hh_ctx_t *ctx, lps22hh_pp_od_t *val) 00979 { 00980 lps22hh_reg_t reg; 00981 int32_t mm_error; 00982 00983 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 00984 *val = (lps22hh_pp_od_t) reg.ctrl_reg2.pp_od; 00985 00986 return mm_error; 00987 } 00988 00989 /** 00990 * @brief pin_polarity: [set] Interrupt active-high/low. 00991 * 00992 * @param lps22hh_ctx_t *ctx: read / write interface definitions 00993 * @param lps22hh_int_h_l_t: change the values of int_h_l in reg CTRL_REG2 00994 * 00995 */ 00996 int32_t lps22hh_pin_polarity_set(lps22hh_ctx_t *ctx, lps22hh_int_h_l_t val) 00997 { 00998 lps22hh_reg_t reg; 00999 int32_t mm_error; 01000 01001 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 01002 reg.ctrl_reg2.int_h_l = val; 01003 mm_error = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 01004 01005 return mm_error; 01006 } 01007 01008 /** 01009 * @brief pin_polarity: [get] Interrupt active-high/low. 01010 * 01011 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01012 * @param lps22hh_int_h_l_t: Get the values of int_h_l in reg CTRL_REG2 01013 * 01014 */ 01015 int32_t lps22hh_pin_polarity_get(lps22hh_ctx_t *ctx, lps22hh_int_h_l_t *val) 01016 { 01017 lps22hh_reg_t reg; 01018 int32_t mm_error; 01019 01020 mm_error = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, ®.byte, 1); 01021 *val = (lps22hh_int_h_l_t) reg.ctrl_reg2.int_h_l; 01022 01023 return mm_error; 01024 } 01025 01026 /** 01027 * @brief pin_int_route: [set] Select the signal that need to route 01028 * on int pad 01029 * 01030 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01031 * @param lps22hh_: registers CTRL_REG3 01032 * 01033 */ 01034 int32_t lps22hh_pin_int_route_set(lps22hh_ctx_t *ctx, 01035 lps22hh_ctrl_reg3_t *val) 01036 { 01037 return lps22hh_write_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *) val, 1); 01038 } 01039 01040 /** 01041 * @brief pin_int_route: [get] Select the signal that need to route 01042 * on int pad 01043 * 01044 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01045 * @param lps22hh_: registers CTRL_REG3 01046 * 01047 */ 01048 int32_t lps22hh_pin_int_route_get(lps22hh_ctx_t *ctx, 01049 lps22hh_ctrl_reg3_t *val) 01050 { 01051 return lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *) val, 1); 01052 } 01053 01054 /** 01055 * @} 01056 */ 01057 01058 /** 01059 * @addtogroup interrupt_on_threshold 01060 * @brief This section groups all the functions that manage the interrupt 01061 * on threshold event generation. 01062 * @{ 01063 */ 01064 01065 /** 01066 * @brief int_on_threshold: [set] Enable interrupt generation on 01067 * pressure low/high event. 01068 * 01069 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01070 * @param lps22hh_pe_t: change the values of pe in reg INTERRUPT_CFG 01071 * 01072 */ 01073 int32_t lps22hh_int_on_threshold_set(lps22hh_ctx_t *ctx, lps22hh_pe_t val) 01074 { 01075 lps22hh_reg_t reg; 01076 int32_t mm_error; 01077 01078 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 01079 reg.interrupt_cfg.pe = val; 01080 01081 if (val) 01082 { 01083 reg.interrupt_cfg.diff_en = 1; 01084 } 01085 else 01086 { 01087 reg.interrupt_cfg.diff_en = 0; 01088 } 01089 01090 mm_error = lps22hh_write_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 01091 01092 return mm_error; 01093 } 01094 01095 /** 01096 * @brief int_on_threshold: [get] Enable interrupt generation on 01097 * pressure low/high event. 01098 * 01099 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01100 * @param lps22hh_pe_t: Get the values of pe in reg INTERRUPT_CFG 01101 * 01102 */ 01103 int32_t lps22hh_int_on_threshold_get(lps22hh_ctx_t *ctx, lps22hh_pe_t *val) 01104 { 01105 lps22hh_reg_t reg; 01106 int32_t mm_error; 01107 01108 mm_error = lps22hh_read_reg(ctx, LPS22HH_INTERRUPT_CFG, ®.byte, 1); 01109 *val = (lps22hh_pe_t) reg.interrupt_cfg.pe; 01110 01111 return mm_error; 01112 } 01113 01114 /** 01115 * @brief int_treshold: [set] User-defined threshold value for 01116 * pressure interrupt event. 01117 * 01118 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01119 * @param uint8_t * : buffer that contains data to write 01120 * 01121 */ 01122 int32_t lps22hh_int_treshold_set(lps22hh_ctx_t *ctx, uint8_t *buff) 01123 { 01124 return lps22hh_write_reg(ctx, LPS22HH_THS_P_L, buff, 2); 01125 } 01126 01127 /** 01128 * @brief int_treshold: [get] User-defined threshold value for 01129 * pressure interrupt event. 01130 * 01131 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01132 * @param uint8_t * : buffer that stores data read 01133 * 01134 */ 01135 int32_t lps22hh_int_treshold_get(lps22hh_ctx_t *ctx, uint8_t *buff) 01136 { 01137 return lps22hh_read_reg(ctx, LPS22HH_THS_P_L, buff, 2); 01138 } 01139 01140 /** 01141 * @} 01142 */ 01143 01144 /** 01145 * @addtogroup fifo 01146 * @brief This section group all the functions concerning the fifo usage. 01147 * @{ 01148 */ 01149 01150 /** 01151 * @brief fifo_mode: [set] 01152 * 01153 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01154 * @param lps22hh_f_mode_t: change the values of f_mode in reg FIFO_CTRL 01155 * 01156 */ 01157 int32_t lps22hh_fifo_mode_set(lps22hh_ctx_t *ctx, lps22hh_f_mode_t val) 01158 { 01159 lps22hh_reg_t reg; 01160 int32_t mm_error; 01161 01162 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, ®.byte, 1); 01163 reg.fifo_ctrl.f_mode = val; 01164 mm_error = lps22hh_write_reg(ctx, LPS22HH_FIFO_CTRL, ®.byte, 1); 01165 01166 return mm_error; 01167 } 01168 01169 /** 01170 * @brief fifo_mode: [get] 01171 * 01172 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01173 * @param lps22hh_f_mode_t: Get the values of f_mode in reg FIFO_CTRL 01174 * 01175 */ 01176 int32_t lps22hh_fifo_mode_get(lps22hh_ctx_t *ctx, lps22hh_f_mode_t *val) 01177 { 01178 lps22hh_reg_t reg; 01179 int32_t mm_error; 01180 01181 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, ®.byte, 1); 01182 *val = (lps22hh_f_mode_t) reg.fifo_ctrl.f_mode; 01183 01184 return mm_error; 01185 } 01186 01187 /** 01188 * @brief fifo_stop_on_wtm: [set] Sensing chain FIFO stop values 01189 * memorization at threshold level. 01190 * 01191 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01192 * @param uint8_t val: change the values of stop_on_fth in reg FIFO_CTRL 01193 * 01194 */ 01195 int32_t lps22hh_fifo_stop_on_wtm_set(lps22hh_ctx_t *ctx, uint8_t val) 01196 { 01197 lps22hh_reg_t reg; 01198 int32_t mm_error; 01199 01200 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, ®.byte, 1); 01201 reg.fifo_ctrl.stop_on_fth = val; 01202 mm_error = lps22hh_write_reg(ctx, LPS22HH_FIFO_CTRL, ®.byte, 1); 01203 01204 return mm_error; 01205 } 01206 01207 /** 01208 * @brief fifo_stop_on_wtm: [get] Sensing chain FIFO stop values 01209 * memorization at threshold level. 01210 * 01211 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01212 * @param uint8_t: change the values of stop_on_fth in reg FIFO_CTRL 01213 * 01214 */ 01215 int32_t lps22hh_fifo_stop_on_wtm_get(lps22hh_ctx_t *ctx, uint8_t *val) 01216 { 01217 lps22hh_reg_t reg; 01218 int32_t mm_error; 01219 01220 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_CTRL, ®.byte, 1); 01221 *val = reg.fifo_ctrl.stop_on_fth; 01222 01223 return mm_error; 01224 } 01225 01226 /** 01227 * @brief fifo_watermark: [set] FIFO watermark level selection. 01228 * 01229 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01230 * @param uint8_t val: change the values of wtm in reg FIFO_WTM 01231 * 01232 */ 01233 int32_t lps22hh_fifo_watermark_set(lps22hh_ctx_t *ctx, uint8_t val) 01234 { 01235 lps22hh_reg_t reg; 01236 int32_t mm_error; 01237 01238 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_WTM, ®.byte, 1); 01239 reg.fifo_wtm.wtm = val; 01240 mm_error = lps22hh_write_reg(ctx, LPS22HH_FIFO_WTM, ®.byte, 1); 01241 01242 return mm_error; 01243 } 01244 01245 /** 01246 * @brief fifo_watermark: [get] FIFO watermark level selection. 01247 * 01248 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01249 * @param uint8_t: change the values of wtm in reg FIFO_WTM 01250 * 01251 */ 01252 int32_t lps22hh_fifo_watermark_get(lps22hh_ctx_t *ctx, uint8_t *val) 01253 { 01254 lps22hh_reg_t reg; 01255 int32_t mm_error; 01256 01257 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_WTM, ®.byte, 1); 01258 *val = reg.fifo_wtm.wtm; 01259 01260 return mm_error; 01261 } 01262 01263 /** 01264 * @brief fifo_data_level: [get] FIFO stored data level. 01265 * 01266 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01267 * @param uint8_t * : buffer that stores data read 01268 * 01269 */ 01270 int32_t lps22hh_fifo_data_level_get(lps22hh_ctx_t *ctx, uint8_t *buff) 01271 { 01272 return lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS1, buff, 1); 01273 } 01274 01275 /** 01276 * @brief fifo_src: [get] Read all the FIFO status flag of the device. 01277 * 01278 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01279 * @param lps22hh_: union of registers from FIFO_STATUS2 to 01280 * 01281 */ 01282 int32_t lps22hh_fifo_src_get(lps22hh_ctx_t *ctx, lps22hh_fifo_status2_t *val) 01283 { 01284 return lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t *) val, 1); 01285 } 01286 01287 /** 01288 * @brief fifo_full_flag: [get] Smart FIFO full status. 01289 * 01290 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01291 * @param uint8_t: change the values of f_full in reg FIFO_STATUS2 01292 * 01293 */ 01294 int32_t lps22hh_fifo_full_flag_get(lps22hh_ctx_t *ctx, uint8_t *val) 01295 { 01296 lps22hh_reg_t reg; 01297 int32_t mm_error; 01298 01299 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, ®.byte, 1); 01300 *val = reg.fifo_status2.f_full; 01301 01302 return mm_error; 01303 } 01304 01305 /** 01306 * @brief fifo_ovr_flag: [get] FIFO overrun status. 01307 * 01308 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01309 * @param uint8_t: change the values of ovr in reg FIFO_STATUS2 01310 * 01311 */ 01312 int32_t lps22hh_fifo_ovr_flag_get(lps22hh_ctx_t *ctx, uint8_t *val) 01313 { 01314 lps22hh_reg_t reg; 01315 int32_t mm_error; 01316 01317 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, ®.byte, 1); 01318 *val = reg.fifo_status2.ovr; 01319 01320 return mm_error; 01321 } 01322 01323 /** 01324 * @brief fifo_wtm_flag: [get] FIFO watermark status. 01325 * 01326 * @param lps22hh_ctx_t *ctx: read / write interface definitions 01327 * @param uint8_t: change the values of fth_fifo in reg FIFO_STATUS2 01328 * 01329 */ 01330 int32_t lps22hh_fifo_wtm_flag_get(lps22hh_ctx_t *ctx, uint8_t *val) 01331 { 01332 lps22hh_reg_t reg; 01333 int32_t mm_error; 01334 01335 mm_error = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, ®.byte, 1); 01336 *val = reg.fifo_status2.fth_fifo; 01337 01338 return mm_error; 01339 } 01340 01341 /** 01342 * @} 01343 */ 01344 01345 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 16:29:49 by 1.7.2