Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
"LSM6DSO32 IMU Driver"

This file provides a set of functions needed to drive the lsm6dso32 enhanced inertial module. More...

Collaboration diagram for "LSM6DSO32 IMU Driver":

Modules

 LSM6DSO32_Interfaces_Functions
 This section provide a set of functions used to read and write a generic register of the device. MANDATORY: return 0 -> no Error.
 
 LSM6DSO32_Sensitivity
 These functions convert raw-data into engineering units.
 
 LSM6DSO32_Data_Generation
 This section groups all the functions concerning data generation.
 
 LSM6DSO32_common
 This section groups common useful functions.
 
 LSM6DSO32_filters
 This section group all the functions concerning the filters configuration.
 
 LSM6DSO32_interrupt_pins
 This section groups all the functions that manage interrupt pins.
 
 LSM6DSO32_Wake_Up_event
 This section groups all the functions that manage the Wake Up event generation.
 
 Activity/Inactivity_detection
 This section groups all the functions concerning activity/inactivity detection.
 
 LSM6DSO32_tap_generator
 This section groups all the functions that manage the tap and double tap event generation.
 
 LSM6DSO32_DEN_functionality
 This section groups all the functions concerning DEN functionality.
 
 LSM6DSO32_Pedometer
 This section groups all the functions that manage pedometer.
 
 LSM6DSO32_significant_motion
 This section groups all the functions that manage the significant motion detection.
 
 LSM6DSO32_Sensor_hub
 This section groups all the functions that manage the sensor hub.
 

Enumerations

enum  OFFSET_TYPE { HWOFFSET = 0 , SWOFFSET = 1 , RESET_HWOFFSET = 2 }
 Specifies the type of offset compensation to be used. More...
 

Functions

int32_t lsm6dso32_xl_full_scale_set (stmdev_ctx_t *ctx, lsm6dso32_fs_xl_t val)
 Accelerometer full-scale selection.[set].
 
int32_t lsm6dso32_xl_full_scale_get (stmdev_ctx_t *ctx, lsm6dso32_fs_xl_t *val)
 Accelerometer full-scale selection.[get].
 
int32_t lsm6dso32_xl_data_rate_set (stmdev_ctx_t *ctx, lsm6dso32_odr_xl_t val)
 Accelerometer UI data rate and power mode selection.[set].
 
int32_t lsm6dso32_xl_data_rate_get (stmdev_ctx_t *ctx, lsm6dso32_odr_xl_t *val)
 Accelerometer UI data rate selection.[get].
 
int32_t lsm6dso32_gy_full_scale_set (stmdev_ctx_t *ctx, lsm6dso32_fs_g_t val)
 Gyroscope UI chain full-scale selection.[set].
 
int32_t lsm6dso32_gy_full_scale_get (stmdev_ctx_t *ctx, lsm6dso32_fs_g_t *val)
 Gyroscope UI chain full-scale selection.[get].
 
int32_t lsm6dso32_gy_data_rate_set (stmdev_ctx_t *ctx, lsm6dso32_odr_g_t val)
 Gyroscope UI data rate selection.[set].
 
int32_t lsm6dso32_gy_data_rate_get (stmdev_ctx_t *ctx, lsm6dso32_odr_g_t *val)
 Gyroscope UI data rate selection.[get].
 
int32_t lsm6dso32_block_data_update_set (stmdev_ctx_t *ctx, uint8_t val)
 Block data update.[set].
 
int32_t lsm6dso32_block_data_update_get (stmdev_ctx_t *ctx, uint8_t *val)
 Block data update.[get].
 
int32_t lsm6dso32_xl_offset_weight_set (stmdev_ctx_t *ctx, lsm6dso32_usr_off_w_t val)
 Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).[set].
 
int32_t lsm6dso32_xl_offset_weight_get (stmdev_ctx_t *ctx, lsm6dso32_usr_off_w_t *val)
 Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).[get].
 
int32_t lsm6dso32_all_sources_get (stmdev_ctx_t *ctx, lsm6dso32_all_sources_t *val)
 Read all the interrupt flag of the device.[get].
 
int32_t lsm6dso32_status_reg_get (stmdev_ctx_t *ctx, lsm6dso32_status_reg_t *val)
 The STATUS_REG register is read by the primary interface.[get].
 
int32_t lsm6dso32_xl_flag_data_ready_get (stmdev_ctx_t *ctx, uint8_t *val)
 Accelerometer new data available.[get].
 
int32_t lsm6dso32_gy_flag_data_ready_get (stmdev_ctx_t *ctx, uint8_t *val)
 Gyroscope new data available.[get].
 
int32_t lsm6dso32_temp_flag_data_ready_get (stmdev_ctx_t *ctx, uint8_t *val)
 Temperature new data available.[get].
 
int32_t lsm6dso32_xl_usr_offset_x_set (stmdev_ctx_t *ctx, uint8_t *buff)
 Accelerometer X-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[set].
 
int32_t lsm6dso32_xl_usr_offset_x_get (stmdev_ctx_t *ctx, uint8_t *buff)
 Accelerometer X-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[get].
 
int32_t lsm6dso32_xl_usr_offset_y_set (stmdev_ctx_t *ctx, uint8_t *buff)
 Accelerometer Y-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[set].
 
int32_t lsm6dso32_xl_usr_offset_y_get (stmdev_ctx_t *ctx, uint8_t *buff)
 Accelerometer Y-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[get].
 
int32_t lsm6dso32_xl_usr_offset_z_set (stmdev_ctx_t *ctx, uint8_t *buff)
 Accelerometer Z-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[set].
 
int32_t lsm6dso32_xl_usr_offset_z_get (stmdev_ctx_t *ctx, uint8_t *buff)
 Accelerometer Z-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[get].
 
int32_t lsm6dso32_xl_usr_offset_set (stmdev_ctx_t *ctx, uint8_t val)
 Enables user offset on out.[set].
 
int32_t lsm6dso32_xl_usr_offset_get (stmdev_ctx_t *ctx, uint8_t *val)
 User offset on out flag.[get].
 
int32_t lsm6dso32_sdo_sa0_mode_set (stmdev_ctx_t *ctx, lsm6dso32_sdo_pu_en_t val)
 Connect/Disconnect SDO/SA0 internal pull-up.[set].
 
int32_t lsm6dso32_sdo_sa0_mode_get (stmdev_ctx_t *ctx, lsm6dso32_sdo_pu_en_t *val)
 Connect/Disconnect SDO/SA0 internal pull-up.[get].
 
int32_t lsm6dso32_spi_mode_set (stmdev_ctx_t *ctx, lsm6dso32_sim_t val)
 SPI Serial Interface Mode selection.[set].
 
int32_t lsm6dso32_spi_mode_get (stmdev_ctx_t *ctx, lsm6dso32_sim_t *val)
 SPI Serial Interface Mode selection.[get].
 
int32_t lsm6dso32_i2c_interface_set (stmdev_ctx_t *ctx, lsm6dso32_i2c_disable_t val)
 Disable / Enable I2C interface.[set].
 
int32_t lsm6dso32_i2c_interface_get (stmdev_ctx_t *ctx, lsm6dso32_i2c_disable_t *val)
 Disable / Enable I2C interface.[get].
 
int32_t lsm6dso32_i3c_disable_set (stmdev_ctx_t *ctx, lsm6dso32_i3c_disable_t val)
 I3C Enable/Disable communication protocol[.set].
 
int32_t lsm6dso32_i3c_disable_get (stmdev_ctx_t *ctx, lsm6dso32_i3c_disable_t *val)
 I3C Enable/Disable communication protocol.[get].
 
int32_t imuP_write (void *handle, uint8_t reg_addr, const uint8_t *buf, uint16_t len)
 SPI write function for the primary IMU (LSM6DSO32).
 
int32_t imuP_read (void *handle, uint8_t reg_addr, uint8_t *buf, uint16_t len)
 SPI read function for the primary IMU (LSM6DSO32).
 
int32_t imuB_write (void *handle, uint8_t reg_addr, const uint8_t *buf, uint16_t len)
 SPI write function for the backup IMU (LSM6DSO32).
 
int32_t imuB_read (void *handle, uint8_t reg_addr, uint8_t *buf, uint16_t len)
 SPI read function for the backup IMU (LSM6DSO32).
 
int8_t init_imup (stmdev_ctx_t *imu, lsm6dso32_fs_xl_t acc_full_scale, lsm6dso32_fs_g_t gyro_full_scale, lsm6dso32_odr_xl_t acc_output_data_rate, lsm6dso32_odr_g_t gyro_output_data_rate)
 Initializes the primary IMU (LSM6DSO32).
 
int8_t init_imuB (stmdev_ctx_t *imu, lsm6dso32_fs_xl_t acc_full_scale, lsm6dso32_fs_g_t gyro_full_scale, lsm6dso32_odr_xl_t acc_output_data_rate, lsm6dso32_odr_g_t gyro_output_data_rate)
 Initializes the backup IMU (LSM6DSO32).
 
int8_t calibrateIMU (stmdev_ctx_t *imu, uint16_t iterationNum, OFFSET_TYPE type)
 Calibrates the IMU by calculating sensor offsets.
 
int32_t imuP_read_2 (void *handle, uint8_t reg_addr, uint8_t *buf, uint16_t len)
 SPI read function for the primary IMU (LSM6DSO32).
 

Detailed Description

This file provides a set of functions needed to drive the lsm6dso32 enhanced inertial module.

This section groups all the functions concerning main serial interface management (not auxiliary)

Enumeration Type Documentation

◆ OFFSET_TYPE

Specifies the type of offset compensation to be used.

This enumeration is used to distinguish between hardware-based, software-based, or resetting the hardware offset.

Enumerator
HWOFFSET 

Use the hardware's internal offset registers.

SWOFFSET 

Apply a software-based offset after reading the data.

RESET_HWOFFSET 

Reset the hardware offset registers to their default values.

Definition at line 60 of file utilities.h.

60 {
61 HWOFFSET = 0,
62 SWOFFSET = 1,
OFFSET_TYPE
Specifies the type of offset compensation to be used.
Definition utilities.h:60
@ SWOFFSET
Apply a software-based offset after reading the data.
Definition utilities.h:62
@ HWOFFSET
Use the hardware's internal offset registers.
Definition utilities.h:61
@ RESET_HWOFFSET
Reset the hardware offset registers to their default values.
Definition utilities.h:63

Function Documentation

◆ calibrateIMU()

int8_t calibrateIMU ( stmdev_ctx_t imu,
uint16_t  iterationNum,
OFFSET_TYPE  type 
)

Calibrates the IMU by calculating sensor offsets.

Reads the accelerometer and gyroscope for a specified number of iterations while the device is stationary to determine the bias/offset. It then writes these offsets to the IMU's hardware registers to be automatically subtracted from future measurements.

Parameters
[in,out]imuPointer to the stmdev_ctx_t driver context.
[in]iterationNumThe number of samples to average for calibration.
[in]typeThe type of calibration to perform (e.g., HWOFFSET).
Returns
int8_t 0 on success.
Note
The device must be perfectly still during calibration. For the accelerometer, the Z-axis should be pointing up, against gravity, to properly calibrate the 1g offset.

Definition at line 366 of file utilities.c.

366 {
367
368 float_t mean_acceleration_mg[3] = {0};
369 float_t mean_angular_rate_mdps[3] = {0};
370 float_t mean_temperature_degC = 0.0;
371 float_t acceleration_mg[3] = {0};
372 float_t angular_rate_mdps[3] = {0};
373 float_t temperature_degC = 0.0;
374 int16_t data_raw_acceleration[3] = {0};
375 int16_t data_raw_angular_rate[3] = {0};
376 int16_t data_raw_temperature = 0.0;
377
378 lsm6dso32_acceleration_raw_get(imu, data_raw_acceleration);
379 lsm6dso32_angular_rate_raw_get(imu, data_raw_angular_rate);
380 lsm6dso32_temperature_raw_get(imu, &data_raw_temperature);
381
382 acceleration_mg[0] = lsm6dso32_from_fs16_to_mg(data_raw_acceleration[0]);
383 acceleration_mg[1] = lsm6dso32_from_fs16_to_mg(data_raw_acceleration[1]);
384 acceleration_mg[2] = lsm6dso32_from_fs16_to_mg(data_raw_acceleration[2]);
385
386 angular_rate_mdps[0] = lsm6dso32_from_fs2000_to_mdps(data_raw_angular_rate[0]);
387 angular_rate_mdps[1] = lsm6dso32_from_fs2000_to_mdps(data_raw_angular_rate[1]);
388 angular_rate_mdps[2] = lsm6dso32_from_fs2000_to_mdps(data_raw_angular_rate[2]);
389
390 temperature_degC = lsm6dso32_from_lsb_to_celsius(data_raw_temperature);
391
392 mean_acceleration_mg[0] += acceleration_mg[0];
393 mean_acceleration_mg[1] += acceleration_mg[1];
394 mean_acceleration_mg[2] += acceleration_mg[2];
395
396 mean_angular_rate_mdps[0] += angular_rate_mdps[0];
397 mean_angular_rate_mdps[1] += angular_rate_mdps[1];
398 mean_angular_rate_mdps[2] += angular_rate_mdps[2];
399
400 mean_temperature_degC += temperature_degC;
401
402 for (int i = 0; i < iterationNum; i++) {
403 lsm6dso32_reg_t reg;
404 /* Read output only if new data is available */
406
407 if (reg.status_reg.xlda) {
408 /* Read acceleration data */
409 memset(data_raw_acceleration, 0x00, 3 * sizeof(int16_t));
410 lsm6dso32_acceleration_raw_get(imu, data_raw_acceleration);
411 acceleration_mg[0] = lsm6dso32_from_fs16_to_mg(data_raw_acceleration[0]);
412 acceleration_mg[1] = lsm6dso32_from_fs16_to_mg(data_raw_acceleration[1]);
413 acceleration_mg[2] = lsm6dso32_from_fs16_to_mg(data_raw_acceleration[2]);
414 mean_acceleration_mg[0] += acceleration_mg[0];
415 mean_acceleration_mg[0] /= 2;
416 mean_acceleration_mg[1] += acceleration_mg[1];
417 mean_acceleration_mg[1] /= 2;
418 mean_acceleration_mg[2] += acceleration_mg[2];
419 mean_acceleration_mg[2] /= 2;
420 }
421
422 if (reg.status_reg.gda) {
423 /* Read angular rate field data */
424 memset(data_raw_angular_rate, 0x00, 3 * sizeof(int16_t));
425 lsm6dso32_angular_rate_raw_get(imu, data_raw_angular_rate);
426 angular_rate_mdps[0] = lsm6dso32_from_fs2000_to_mdps(data_raw_angular_rate[0]);
427 angular_rate_mdps[1] = lsm6dso32_from_fs2000_to_mdps(data_raw_angular_rate[1]);
428 angular_rate_mdps[2] = lsm6dso32_from_fs2000_to_mdps(data_raw_angular_rate[2]);
429 mean_angular_rate_mdps[0] += angular_rate_mdps[0];
430 mean_angular_rate_mdps[0] /= 2;
431 mean_angular_rate_mdps[1] += angular_rate_mdps[1];
432 mean_angular_rate_mdps[1] /= 2;
433 mean_angular_rate_mdps[2] += angular_rate_mdps[2];
434 mean_angular_rate_mdps[2] /= 2;
435 }
436
437 if (reg.status_reg.tda) {
438 /* Read temperature data */
439 memset(&data_raw_temperature, 0x00, sizeof(int16_t));
440 lsm6dso32_temperature_raw_get(imu, &data_raw_temperature);
441 temperature_degC = lsm6dso32_from_lsb_to_celsius(data_raw_temperature);
442 mean_temperature_degC += temperature_degC;
443 mean_temperature_degC /= 2;
444 }
445 }
446
447 switch(type) {
448// case SWOFFSET:
449// /* FIXME handle a possible sw offset type, store offset values somewhere and use
450// * them to calibrate measurements. */
451//
452// acceleration_mg_swoffset[0] = mean_acceleration_mg[0];
453// acceleration_mg_swoffset[1] = mean_acceleration_mg[1];
454// acceleration_mg_swoffset[2] = mean_acceleration_mg[2];
455//
456// angular_rate_mdps_swoffset[0] = mean_angular_rate_mdps[0];
457// angular_rate_mdps_swoffset[1] = mean_angular_rate_mdps[1];
458// angular_rate_mdps_swoffset[2] = mean_angular_rate_mdps[2];
459//
460// break;
461 case HWOFFSET:
462
463 // add code to set a possible hardware offset in the IMU, if needed
464
465 /*
466 LSM6DSO32_X_OFS_USR
467 LSM6DSO32_Y_OFS_USR
468 LSM6DSO32_Z_OFS_USR
469
470 are the registers used to set an hardware offset to accelerometer measurements
471
472 To enable offset USR_OFF_ON_OUT bit of the CTRL7_G register must be set.
473
474 The value of the offset is expressed on 8 bits 2's complement.
475
476 The weight [g/LSB] to be applied to the offset register values is independent
477 of the accelerometer selected full scale
478 and can be configured using the USR_OFF_W bit of the CTRL6_C register:
479 • 2^-10 g/LSB if the USR_OFF_W bit is set to 0
480 • 2^-6 g/LSB if the USR_OFF_W bit is set to 1
481 */
482
483 /*
484 * 1. offset is computed using the finest weight
485 * 2. we check whether the offset can be represented on 8 bits 2's complement
486 * 3.1. If yes, the weight is set
487 * 3.2. Otherwise, the coarser weight is used and the offsets are recomputed
488 * 4. the value of the offset is stored in imu's registers
489 */
490
491 float mean_acceleration_x = mean_acceleration_mg[0] / 2;
492 float mean_acceleration_y = mean_acceleration_mg[1] / 2;
493 float mean_acceleration_z = mean_acceleration_mg[2] / 2;
494
495 float mean_acceleration = sqrtf(
496 mean_acceleration_mg[0]*mean_acceleration_mg[0] +
497 mean_acceleration_mg[1]*mean_acceleration_mg[1] +
498 mean_acceleration_mg[2]*mean_acceleration_mg[2]
499 );
500
501 float mean_acc_direction_x = mean_acceleration_x / mean_acceleration;
502 float mean_acc_direction_y = mean_acceleration_y / mean_acceleration;
503 float mean_acc_direction_z = mean_acceleration_z / mean_acceleration;
504
505 float gravity = 1000;
506
507 mean_acceleration_x -= mean_acc_direction_x*gravity;
508 mean_acceleration_y -= mean_acc_direction_y*gravity;
509 mean_acceleration_z -= mean_acc_direction_z*gravity;
510
511 int16_t offsetValX = (int16_t)mean_acceleration_x;
512 int16_t offsetValY = (int16_t)mean_acceleration_y;
513 int16_t offsetValZ = (int16_t)mean_acceleration_z;
514
515 if (offsetValX > -128 && offsetValX < 128 && offsetValY > -128 && offsetValY < 128
516 && offsetValZ > -128 && offsetValZ < 128) {
517
519 } else {
520 /* the right shift by 4 operation is done to perform the division by 16 */
522 offsetValX /= 16;
523 offsetValY /= 16;
524 offsetValZ /= 16;
525 }
526
527 // int32_t lsm6dso32_xl_offset_weight_get(stmdev_ctx_t *ctx, lsm6dso32_usr_off_w_t *val);
528 // int32_t lsm6dso32_xl_usr_offset_x_get(stmdev_ctx_t *ctx, uint8_t *buff);
529 // int32_t lsm6dso32_xl_usr_offset_y_get(stmdev_ctx_t *ctx, uint8_t *buff);
530 // int32_t lsm6dso32_xl_usr_offset_z_get(stmdev_ctx_t *ctx, uint8_t *buff);
531 // int32_t lsm6dso32_xl_usr_offset_get(stmdev_ctx_t *ctx, uint8_t *val);
532
533 lsm6dso32_xl_usr_offset_x_set(imu, (uint8_t *) &offsetValX);
534 lsm6dso32_xl_usr_offset_y_set(imu, (uint8_t *) &offsetValY);
535 lsm6dso32_xl_usr_offset_z_set(imu, (uint8_t *) &offsetValZ);
536
537 /* this function call enables the offset previously set */
539
540 break;
541
542 case RESET_HWOFFSET:
543
547
549
550 break;
551
552 default:
553
554 break;
555 }
556
557
558
559 return 0;
560}
int32_t lsm6dso32_angular_rate_raw_get(stmdev_ctx_t *ctx, int16_t *val)
Angular rate sensor. The value is expressed as a 16-bit word in two’s complement.[get].
int32_t lsm6dso32_temperature_raw_get(stmdev_ctx_t *ctx, int16_t *val)
Temperature data output register (r). L and H registers together express a 16-bit word in two’s compl...
int32_t lsm6dso32_acceleration_raw_get(stmdev_ctx_t *ctx, int16_t *val)
Linear acceleration output register. The value is expressed as a 16-bit word in two’s complement....
float_t lsm6dso32_from_lsb_to_celsius(int16_t lsb)
float_t lsm6dso32_from_fs16_to_mg(int16_t lsb)
float_t lsm6dso32_from_fs2000_to_mdps(int16_t lsb)
int32_t lsm6dso32_xl_offset_weight_set(stmdev_ctx_t *ctx, lsm6dso32_usr_off_w_t val)
Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h)....
int32_t lsm6dso32_xl_usr_offset_z_set(stmdev_ctx_t *ctx, uint8_t *buff)
Accelerometer Z-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_...
int32_t lsm6dso32_xl_usr_offset_y_set(stmdev_ctx_t *ctx, uint8_t *buff)
Accelerometer Y-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_...
int32_t lsm6dso32_xl_usr_offset_x_set(stmdev_ctx_t *ctx, uint8_t *buff)
Accelerometer X-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_...
int32_t lsm6dso32_status_reg_get(stmdev_ctx_t *ctx, lsm6dso32_status_reg_t *val)
The STATUS_REG register is read by the primary interface.[get].
int32_t lsm6dso32_xl_usr_offset_set(stmdev_ctx_t *ctx, uint8_t val)
Enables user offset on out.[set].
@ LSM6DSO32_LSb_16mg
@ LSM6DSO32_LSb_1mg
lsm6dso32_status_reg_t status_reg

References lsm6dso32_status_reg_t::gda, HWOFFSET, lsm6dso32_acceleration_raw_get(), lsm6dso32_angular_rate_raw_get(), lsm6dso32_from_fs16_to_mg(), lsm6dso32_from_fs2000_to_mdps(), lsm6dso32_from_lsb_to_celsius(), LSM6DSO32_LSb_16mg, LSM6DSO32_LSb_1mg, lsm6dso32_status_reg_get(), lsm6dso32_temperature_raw_get(), lsm6dso32_xl_offset_weight_set(), lsm6dso32_xl_usr_offset_set(), lsm6dso32_xl_usr_offset_x_set(), lsm6dso32_xl_usr_offset_y_set(), lsm6dso32_xl_usr_offset_z_set(), RESET_HWOFFSET, lsm6dso32_reg_t::status_reg, lsm6dso32_status_reg_t::tda, and lsm6dso32_status_reg_t::xlda.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ imuB_read()

int32_t imuB_read ( void *  handle,
uint8_t  reg_addr,
uint8_t *  buf,
uint16_t  len 
)

SPI read function for the backup IMU (LSM6DSO32).

This function is designed to be passed as a function pointer to the STMicroelectronics IMU driver library. It handles SPI bus transactions.

Parameters
[in]handleUnused handle pointer, for driver compatibility.
[in]reg_addrThe 7-bit register address to read from. The read bit is set automatically.
[out]bufPointer to the buffer where read data will be stored.
[in]lenThe number of bytes to read.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 582 of file utilities.c.

582 {
583
584 int32_t result = HAL_ERROR;
585
586 reg_addr |= 0x80;
587
588 BMP390_CS_HIGH;
589 MAG_CS_HIGH;
590 IMU_CS_LOW;
591
592 if (HAL_SPI_Transmit(&hspi3, &reg_addr, 1, 100) == HAL_OK) {
593 if (HAL_SPI_Receive(&hspi3, buf, len, 100) == HAL_OK) {
594 result = HAL_OK;
595 }
596 }
597
598 IMU_CS_HIGH;
599
600 return result;
601}
SPI_HandleTypeDef hspi3
Definition main.c:63
@ HAL_ERROR
@ HAL_OK

References HAL_ERROR, HAL_OK, and hspi3.

Referenced by init_imuB().

Here is the caller graph for this function:

◆ imuB_write()

int32_t imuB_write ( void *  handle,
uint8_t  reg_addr,
const uint8_t *  buf,
uint16_t  len 
)

SPI write function for the backup IMU (LSM6DSO32).

This function is designed to be passed as a function pointer to the STMicroelectronics IMU driver library. It handles SPI bus transactions.

Parameters
[in]handleUnused handle pointer, for driver compatibility.
[in]reg_addrThe 7-bit register address to write to.
[in]bufPointer to the data buffer to be written.
[in]lenThe number of bytes to write.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 563 of file utilities.c.

563 {
564
565 int32_t result = HAL_ERROR;
566
567 BMP390_CS_HIGH;
568 MAG_CS_HIGH;
569 IMU_CS_LOW;
570
571 if (HAL_SPI_Transmit(&hspi3, &reg_addr, 1, 100) == HAL_OK) {
572 if (HAL_SPI_Transmit(&hspi3, (uint8_t *)buf, len, 100) == HAL_OK) {
573 result = HAL_OK;
574 }
575 }
576
577 IMU_CS_HIGH;
578
579 return result;
580}

References HAL_ERROR, HAL_OK, and hspi3.

Referenced by init_imuB().

Here is the caller graph for this function:

◆ imuP_read()

int32_t imuP_read ( void *  handle,
uint8_t  reg_addr,
uint8_t *  buf,
uint16_t  len 
)

SPI read function for the primary IMU (LSM6DSO32).

This function is designed to be passed as a function pointer to the STMicroelectronics IMU driver library. It handles SPI bus transactions.

Parameters
[in]handleUnused handle pointer, for driver compatibility.
[in]reg_addrThe 7-bit register address to read from. The read bit is set automatically.
[out]bufPointer to the buffer where read data will be stored.
[in]lenThe number of bytes to read.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 52 of file utilities.c.

52 {
53
54 int32_t result = HAL_ERROR;
55
56 reg_addr |= 0x80;
57 BMP390_CS_HIGH;
58 MAG_CS_HIGH;
59 IMU_CS_LOW;
60
61 if (HAL_SPI_Transmit(&hspi2, &reg_addr, 1, 100) == HAL_OK) {
62 if (HAL_SPI_Receive(&hspi2, buf, len, 100) == HAL_OK) {
63 result = HAL_OK;
64 }
65 }
66
67 IMU_CS_HIGH;
68
69 return result;
70}
SPI_HandleTypeDef hspi2
Definition main.c:62

References HAL_ERROR, HAL_OK, and hspi2.

Referenced by init_imup().

Here is the caller graph for this function:

◆ imuP_read_2()

int32_t imuP_read_2 ( void *  handle,
uint8_t  reg_addr,
uint8_t *  buf,
uint16_t  len 
)

SPI read function for the primary IMU (LSM6DSO32).

This function is designed to be passed as a function pointer to the STMicroelectronics IMU driver library. It handles SPI bus transactions. It does the same thing as imuP_read but using a different Hal function

Parameters
[in]handleUnused handle pointer, for driver compatibility.
[in]reg_addrThe 7-bit register address to read from. The read bit is set automatically.
[out]bufPointer to the buffer where read data will be stored.
[in]lenThe number of bytes to read.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 71 of file utilities.c.

71 {
72 int32_t result = HAL_ERROR;
73 uint8_t tx_buffer[len + 1]; // Buffer to send address + dummy bytes
74 uint8_t rx_buffer[len + 1]; // Buffer to receive dummy byte + actual data
75
76 reg_addr |= 0x80; // Correctly set the read bit
77 tx_buffer[0] = reg_addr; // First byte to transmit is the address
78
79 // Fill the rest of the transmit buffer with dummy bytes
80 for (int i = 1; i <= len; i++) {
81 tx_buffer[i] = 0xFF; // Dummy byte (value doesn't usually matter)
82 }
83 if(HAL_GPIO_ReadPin(BARO_CS_GPIO_Port,BARO_CS_Pin)!=GPIO_PIN_SET){BMP390_CS_HIGH;}
84 if(HAL_GPIO_ReadPin(MAG_CS_GPIO_Port,MAG_CS_Pin)!=GPIO_PIN_SET){MAG_CS_HIGH;}
85
86 IMU_CS_LOW; // Lower CS
87
88 // Use TransmitReceive for simultaneous sending and receiving
89 if (HAL_SPI_TransmitReceive(&hspi2, tx_buffer, rx_buffer, len + 1, 100) == HAL_OK) {
90 // The actual data is in rx_buffer starting from the second byte
91 for (int i = 0; i < len; i++) {
92 buf[i] = rx_buffer[i + 1];
93 }
94 result = HAL_OK;
95 }
96
97 IMU_CS_HIGH; // Raise CS
98
99 return result;
100}

References HAL_ERROR, HAL_OK, and hspi2.

◆ imuP_write()

int32_t imuP_write ( void *  handle,
uint8_t  reg_addr,
const uint8_t *  buf,
uint16_t  len 
)

SPI write function for the primary IMU (LSM6DSO32).

This function is designed to be passed as a function pointer to the STMicroelectronics IMU driver library. It handles SPI bus transactions.

Parameters
[in]handleUnused handle pointer, for driver compatibility.
[in]reg_addrThe 7-bit register address to write to.
[in]bufPointer to the data buffer to be written.
[in]lenThe number of bytes to write.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 33 of file utilities.c.

33 {
34
35 int32_t result = HAL_ERROR;
36
37 BMP390_CS_HIGH;
38 MAG_CS_HIGH;
39 IMU_CS_LOW;
40
41 if (HAL_SPI_Transmit(&hspi2, &reg_addr, 1, 100) == HAL_OK) {
42 if (HAL_SPI_Transmit(&hspi2, (uint8_t *)buf, len, 100) == HAL_OK) {
43 result = HAL_OK;
44 }
45 }
46
47 IMU_CS_HIGH;
48
49 return result;
50}

References HAL_ERROR, HAL_OK, and hspi2.

Referenced by init_imup().

Here is the caller graph for this function:

◆ init_imuB()

int8_t init_imuB ( stmdev_ctx_t imu,
lsm6dso32_fs_xl_t  acc_full_scale,
lsm6dso32_fs_g_t  gyro_full_scale,
lsm6dso32_odr_xl_t  acc_output_data_rate,
lsm6dso32_odr_g_t  gyro_output_data_rate 
)

Initializes the backup IMU (LSM6DSO32).

Configures the IMU with the specified full-scale ranges and output data rates. Performs a device ID check and reset.

Parameters
[in,out]imuPointer to the stmdev_ctx_t driver context structure.
[in]acc_full_scaleDesired accelerometer full-scale range.
[in]gyro_full_scaleDesired gyroscope full-scale range.
[in]acc_output_data_rateDesired accelerometer output data rate (ODR).
[in]gyro_output_data_rateDesired gyroscope output data rate (ODR).
Returns
int8_t HAL_OK on successful initialization, HAL_ERROR otherwise.

Definition at line 665 of file utilities.c.

665 {
666
667// int8_t result = HAL_ERROR;
668
669 uint8_t who_am_i = 0;
670 uint8_t rst = 1;
671 uint8_t result = 1;
672
673 imu -> write_reg = imuB_write;
674 imu -> read_reg = imuB_read;
675 imu -> handle = &hspi3;
676
677 HAL_Delay(10); //FIXME here HAL_Delay used because this init is done during startup, so before kernel takes control of execution
678
679 lsm6dso32_device_id_get(imu, &who_am_i);
680
681 if (who_am_i != LSM6DSO32_ID) {
682 return HAL_ERROR;
683 }
684
685 /* Restore default configuration */
687
688 /* Wait until the imu does not exit reset status */
689 do {
690 lsm6dso32_reset_get(imu, &rst);
691 } while (rst);
692
693 if (result != 0) {
694 return HAL_ERROR;
695 }
696
697 /* Disable I3C interface */
699
700 if (result != 0) {
701 return HAL_ERROR;
702 }
703
704 /* Enable Block Data Update, this means that registers
705 * are not update until all the data have been read */
707
708 if (result != 0) {
709 return HAL_ERROR;
710 }
711
712 /* Set accelerometer and gyroscope full scale */
713 lsm6dso32_xl_full_scale_set(imu, acc_full_scale);
714 lsm6dso32_gy_full_scale_set(imu, gyro_full_scale);
715
716 /* Set accelerometer and gyroscope output data rate ODR */
717 lsm6dso32_xl_data_rate_set(imu, acc_output_data_rate);
718 lsm6dso32_gy_data_rate_set(imu, gyro_output_data_rate);
719
720 return HAL_OK;
721}
#define LSM6DSO32_ID
int32_t lsm6dso32_reset_get(stmdev_ctx_t *ctx, uint8_t *val)
Software reset. Restore the default values in user registers.[get].
int32_t lsm6dso32_reset_set(stmdev_ctx_t *ctx, uint8_t val)
Software reset. Restore the default values in user registers[set].
int32_t lsm6dso32_device_id_get(stmdev_ctx_t *ctx, uint8_t *buff)
Device "Who am I".[get].
int32_t lsm6dso32_gy_full_scale_set(stmdev_ctx_t *ctx, lsm6dso32_fs_g_t val)
Gyroscope UI chain full-scale selection.[set].
int32_t lsm6dso32_xl_full_scale_set(stmdev_ctx_t *ctx, lsm6dso32_fs_xl_t val)
Accelerometer full-scale selection.[set].
int32_t lsm6dso32_block_data_update_set(stmdev_ctx_t *ctx, uint8_t val)
Block data update.[set].
int32_t imuB_read(void *handle, uint8_t reg_addr, uint8_t *buf, uint16_t len)
SPI read function for the backup IMU (LSM6DSO32).
Definition utilities.c:582
int32_t lsm6dso32_xl_data_rate_set(stmdev_ctx_t *ctx, lsm6dso32_odr_xl_t val)
Accelerometer UI data rate and power mode selection.[set].
int32_t lsm6dso32_i3c_disable_set(stmdev_ctx_t *ctx, lsm6dso32_i3c_disable_t val)
I3C Enable/Disable communication protocol[.set].
int32_t lsm6dso32_gy_data_rate_set(stmdev_ctx_t *ctx, lsm6dso32_odr_g_t val)
Gyroscope UI data rate selection.[set].
int32_t imuB_write(void *handle, uint8_t reg_addr, const uint8_t *buf, uint16_t len)
SPI write function for the backup IMU (LSM6DSO32).
Definition utilities.c:563
#define PROPERTY_ENABLE
@ LSM6DSO32_I3C_DISABLE

References HAL_ERROR, HAL_OK, hspi3, imuB_read(), imuB_write(), lsm6dso32_block_data_update_set(), lsm6dso32_device_id_get(), lsm6dso32_gy_data_rate_set(), lsm6dso32_gy_full_scale_set(), LSM6DSO32_I3C_DISABLE, lsm6dso32_i3c_disable_set(), LSM6DSO32_ID, lsm6dso32_reset_get(), lsm6dso32_reset_set(), lsm6dso32_xl_data_rate_set(), lsm6dso32_xl_full_scale_set(), and PROPERTY_ENABLE.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_imup()

int8_t init_imup ( stmdev_ctx_t imu,
lsm6dso32_fs_xl_t  acc_full_scale,
lsm6dso32_fs_g_t  gyro_full_scale,
lsm6dso32_odr_xl_t  acc_output_data_rate,
lsm6dso32_odr_g_t  gyro_output_data_rate 
)

Initializes the primary IMU (LSM6DSO32).

Configures the IMU with the specified full-scale ranges and output data rates. Performs a device ID check and reset.

Parameters
[in,out]imuPointer to the stmdev_ctx_t driver context structure.
[in]acc_full_scaleDesired accelerometer full-scale range.
[in]gyro_full_scaleDesired gyroscope full-scale range.
[in]acc_output_data_rateDesired accelerometer output data rate (ODR).
[in]gyro_output_data_rateDesired gyroscope output data rate (ODR).
Returns
int8_t HAL_OK on successful initialization, HAL_ERROR otherwise.

Definition at line 193 of file utilities.c.

193 {
194
195
196
197 uint8_t who_am_i = 0;
198 uint8_t rst = 1;
199 uint8_t result = 1;
200
201 imu -> write_reg = imuP_write;
202 imu -> read_reg = imuP_read;
203 imu -> handle = &hspi2;
204
205 HAL_Delay(10); //FIXME here HAL_Delay used because this init is done during startup, so before kernel takes control of execution
206
207 lsm6dso32_device_id_get(imu, &who_am_i);
208
209
210 if (who_am_i != LSM6DSO32_ID) {
211 return HAL_ERROR;
212 }
213
214 /* Restore default configuration */
216
217 /* Wait until the imu does not exit reset status */
218 do {
219 lsm6dso32_reset_get(imu, &rst);
220 } while (rst);
221
222 if (result != 0) {
223 return HAL_ERROR;
224 }
225
226 /* Disable I3C interface */
228
229 if (result != 0) {
230 return HAL_ERROR;
231 }
232
233 /* Enable Block Data Update, this means that registers
234 * are not update until all the data have been read */
236
237 if (result != 0) {
238 return HAL_ERROR;
239 }
240
241 /* Set accelerometer and gyroscope full scale */
242 lsm6dso32_xl_full_scale_set(imu, acc_full_scale);
243 lsm6dso32_gy_full_scale_set(imu, gyro_full_scale);
244
245 /* Set accelerometer and gyroscope output data rate ODR */
246 lsm6dso32_xl_data_rate_set(imu, acc_output_data_rate);
247 lsm6dso32_gy_data_rate_set(imu, gyro_output_data_rate);
248
249 return HAL_OK;
250}
int32_t imuP_read(void *handle, uint8_t reg_addr, uint8_t *buf, uint16_t len)
SPI read function for the primary IMU (LSM6DSO32).
Definition utilities.c:52
int32_t imuP_write(void *handle, uint8_t reg_addr, const uint8_t *buf, uint16_t len)
SPI write function for the primary IMU (LSM6DSO32).
Definition utilities.c:33

References HAL_ERROR, HAL_OK, hspi2, imuP_read(), imuP_write(), lsm6dso32_block_data_update_set(), lsm6dso32_device_id_get(), lsm6dso32_gy_data_rate_set(), lsm6dso32_gy_full_scale_set(), LSM6DSO32_I3C_DISABLE, lsm6dso32_i3c_disable_set(), LSM6DSO32_ID, lsm6dso32_reset_get(), lsm6dso32_reset_set(), lsm6dso32_xl_data_rate_set(), lsm6dso32_xl_full_scale_set(), and PROPERTY_ENABLE.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_all_sources_get()

int32_t lsm6dso32_all_sources_get ( stmdev_ctx_t ctx,
lsm6dso32_all_sources_t val 
)

Read all the interrupt flag of the device.[get].

Parameters
ctxread / write interface definitions
valregisters ALL_INT_SRC; WAKE_UP_SRC; TAP_SRC; D6D_SRC; STATUS_REG; EMB_FUNC_STATUS; FSM_STATUS_A/B
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 778 of file lsm6dso32_reg.c.

780{
781 int32_t ret;
782
784 (uint8_t *)&val->all_int_src, 1);
785
786 if (ret == 0)
787 {
789 (uint8_t *)&val->wake_up_src, 1);
790 }
791
792 if (ret == 0)
793 {
795 (uint8_t *)&val->tap_src, 1);
796 }
797
798 if (ret == 0)
799 {
801 (uint8_t *)&val->d6d_src, 1);
802 }
803
804 if (ret == 0)
805 {
807 (uint8_t *)&val->status_reg, 1);
808 }
809
810 if (ret == 0)
811 {
813 }
814
815 if (ret == 0)
816 {
818 (uint8_t *)&val->emb_func_status, 1);
819 }
820
821 if (ret == 0)
822 {
824 (uint8_t *)&val->fsm_status_a, 1);
825 }
826
827 if (ret == 0)
828 {
830 (uint8_t *)&val->fsm_status_b, 1);
831 }
832
833 if (ret == 0)
834 {
836 }
837
838 return ret;
839}
int32_t __weak lsm6dso32_read_reg(stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len)
Read generic device register.
int32_t lsm6dso32_mem_bank_set(stmdev_ctx_t *ctx, lsm6dso32_reg_access_t val)
Enable access to the embedded functions/sensor hub configuration registers.[set].
#define LSM6DSO32_FSM_STATUS_A
@ LSM6DSO32_USER_BANK
@ LSM6DSO32_EMBEDDED_FUNC_BANK
#define LSM6DSO32_FSM_STATUS_B
#define LSM6DSO32_STATUS_REG
#define LSM6DSO32_WAKE_UP_SRC
#define LSM6DSO32_ALL_INT_SRC
#define LSM6DSO32_D6D_SRC
#define LSM6DSO32_EMB_FUNC_STATUS
#define LSM6DSO32_TAP_SRC
lsm6dso32_all_int_src_t all_int_src
lsm6dso32_emb_func_status_t emb_func_status
lsm6dso32_fsm_status_b_t fsm_status_b
lsm6dso32_d6d_src_t d6d_src
lsm6dso32_wake_up_src_t wake_up_src
lsm6dso32_fsm_status_a_t fsm_status_a
lsm6dso32_status_reg_t status_reg
lsm6dso32_tap_src_t tap_src

References lsm6dso32_all_sources_t::all_int_src, lsm6dso32_all_sources_t::d6d_src, lsm6dso32_all_sources_t::emb_func_status, lsm6dso32_all_sources_t::fsm_status_a, lsm6dso32_all_sources_t::fsm_status_b, LSM6DSO32_ALL_INT_SRC, LSM6DSO32_D6D_SRC, LSM6DSO32_EMB_FUNC_STATUS, LSM6DSO32_EMBEDDED_FUNC_BANK, LSM6DSO32_FSM_STATUS_A, LSM6DSO32_FSM_STATUS_B, lsm6dso32_mem_bank_set(), lsm6dso32_read_reg(), LSM6DSO32_STATUS_REG, LSM6DSO32_TAP_SRC, LSM6DSO32_USER_BANK, LSM6DSO32_WAKE_UP_SRC, lsm6dso32_all_sources_t::status_reg, lsm6dso32_all_sources_t::tap_src, and lsm6dso32_all_sources_t::wake_up_src.

Here is the call graph for this function:

◆ lsm6dso32_block_data_update_get()

int32_t lsm6dso32_block_data_update_get ( stmdev_ctx_t ctx,
uint8_t *  val 
)

Block data update.[get].

Parameters
ctxread / write interface definitions
valchange the values of bdu in reg CTRL3_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 695 of file lsm6dso32_reg.c.

697{
699 int32_t ret;
700
701 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL3_C, (uint8_t *)&reg, 1);
702 *val = reg.bdu;
703
704 return ret;
705}
#define LSM6DSO32_CTRL3_C

References lsm6dso32_ctrl3_c_t::bdu, LSM6DSO32_CTRL3_C, and lsm6dso32_read_reg().

Here is the call graph for this function:

◆ lsm6dso32_block_data_update_set()

int32_t lsm6dso32_block_data_update_set ( stmdev_ctx_t ctx,
uint8_t  val 
)

Block data update.[set].

Parameters
ctxread / write interface definitions
valchange the values of bdu in reg CTRL3_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 670 of file lsm6dso32_reg.c.

672{
674 int32_t ret;
675
676 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL3_C, (uint8_t *)&reg, 1);
677
678 if (ret == 0)
679 {
680 reg.bdu = val;
681 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL3_C, (uint8_t *)&reg, 1);
682 }
683
684 return ret;
685}
int32_t __weak lsm6dso32_write_reg(stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len)
Write generic device register.

References lsm6dso32_ctrl3_c_t::bdu, LSM6DSO32_CTRL3_C, lsm6dso32_read_reg(), and lsm6dso32_write_reg().

Referenced by init_imuB(), and init_imup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_gy_data_rate_get()

int32_t lsm6dso32_gy_data_rate_get ( stmdev_ctx_t ctx,
lsm6dso32_odr_g_t val 
)

Gyroscope UI data rate selection.[get].

Parameters
ctxread / write interface definitions
valGet the values of odr_g in reg CTRL2_G
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 574 of file lsm6dso32_reg.c.

576{
577 lsm6dso32_ctrl2_g_t ctrl2_g;
578 lsm6dso32_ctrl7_g_t ctrl7_g;
579 int32_t ret;
580
581 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL7_G, (uint8_t *)&ctrl7_g, 1);
582
583 if (ret == 0)
584 {
585 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&ctrl2_g, 1);
586 }
587
588 switch ((ctrl7_g.g_hm_mode << 4) + ctrl2_g.odr_g)
589 {
592 break;
593
596 break;
597
600 break;
601
604 break;
605
608 break;
609
612 break;
613
616 break;
617
620 break;
621
624 break;
625
628 break;
629
632 break;
633
636 break;
637
640 break;
641
644 break;
645
648 break;
649
652 break;
653
654 default:
656 break;
657 }
658
659 return ret;
660}
#define LSM6DSO32_CTRL7_G
#define LSM6DSO32_CTRL2_G
@ LSM6DSO32_GY_ODR_52Hz_LOW_PW
@ LSM6DSO32_GY_ODR_104Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_12Hz5_LOW_PW
@ LSM6DSO32_GY_ODR_26Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_208Hz_NORMAL_MD
@ LSM6DSO32_GY_ODR_6667Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_104Hz_NORMAL_MD
@ LSM6DSO32_GY_ODR_OFF
@ LSM6DSO32_GY_ODR_52Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_417Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_26Hz_LOW_PW
@ LSM6DSO32_GY_ODR_12Hz5_HIGH_PERF
@ LSM6DSO32_GY_ODR_3333Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_1667Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_833Hz_HIGH_PERF
@ LSM6DSO32_GY_ODR_208Hz_HIGH_PERF

References lsm6dso32_ctrl7_g_t::g_hm_mode, LSM6DSO32_CTRL2_G, LSM6DSO32_CTRL7_G, LSM6DSO32_GY_ODR_104Hz_HIGH_PERF, LSM6DSO32_GY_ODR_104Hz_NORMAL_MD, LSM6DSO32_GY_ODR_12Hz5_HIGH_PERF, LSM6DSO32_GY_ODR_12Hz5_LOW_PW, LSM6DSO32_GY_ODR_1667Hz_HIGH_PERF, LSM6DSO32_GY_ODR_208Hz_HIGH_PERF, LSM6DSO32_GY_ODR_208Hz_NORMAL_MD, LSM6DSO32_GY_ODR_26Hz_HIGH_PERF, LSM6DSO32_GY_ODR_26Hz_LOW_PW, LSM6DSO32_GY_ODR_3333Hz_HIGH_PERF, LSM6DSO32_GY_ODR_417Hz_HIGH_PERF, LSM6DSO32_GY_ODR_52Hz_HIGH_PERF, LSM6DSO32_GY_ODR_52Hz_LOW_PW, LSM6DSO32_GY_ODR_6667Hz_HIGH_PERF, LSM6DSO32_GY_ODR_833Hz_HIGH_PERF, LSM6DSO32_GY_ODR_OFF, lsm6dso32_read_reg(), and lsm6dso32_ctrl2_g_t::odr_g.

Here is the call graph for this function:

◆ lsm6dso32_gy_data_rate_set()

int32_t lsm6dso32_gy_data_rate_set ( stmdev_ctx_t ctx,
lsm6dso32_odr_g_t  val 
)

Gyroscope UI data rate selection.[set].

Parameters
ctxread / write interface definitions
valchange the values of odr_g in reg CTRL2_G
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 526 of file lsm6dso32_reg.c.

528{
529 lsm6dso32_ctrl2_g_t ctrl2_g;
530 lsm6dso32_ctrl7_g_t ctrl7_g;
531 int32_t ret;
532
533 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&ctrl2_g, 1);
534
535 if (ret == 0)
536 {
537 ctrl2_g.odr_g = (uint8_t) LSM6DSO32_GY_ODR_OFF & 0x0FU;
538 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&ctrl2_g, 1);
539 }
540
541 if (ret == 0)
542 {
543 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL7_G, (uint8_t *)&ctrl7_g, 1);
544 }
545
546 if (ret == 0)
547 {
548 ctrl7_g.g_hm_mode = ((uint8_t)val & 0x10U) >> 4;
549 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL7_G, (uint8_t *)&ctrl7_g, 1);
550 }
551
552 if (ret == 0)
553 {
554 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&ctrl2_g, 1);
555 }
556
557 if (ret == 0)
558 {
559 ctrl2_g.odr_g = (uint8_t)val & 0x0FU;
560 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&ctrl2_g, 1);
561 }
562
563 return ret;
564}

References lsm6dso32_ctrl7_g_t::g_hm_mode, LSM6DSO32_CTRL2_G, LSM6DSO32_CTRL7_G, LSM6DSO32_GY_ODR_OFF, lsm6dso32_read_reg(), lsm6dso32_write_reg(), and lsm6dso32_ctrl2_g_t::odr_g.

Referenced by init_imuB(), and init_imup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_gy_flag_data_ready_get()

int32_t lsm6dso32_gy_flag_data_ready_get ( stmdev_ctx_t ctx,
uint8_t *  val 
)

Gyroscope new data available.[get].

Parameters
ctxread / write interface definitions
valchange the values of gda in reg STATUS_REG
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 887 of file lsm6dso32_reg.c.

889{
891 int32_t ret;
892
893 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_STATUS_REG, (uint8_t *)&reg, 1);
894 *val = reg.gda;
895
896 return ret;
897}

References lsm6dso32_status_reg_t::gda, lsm6dso32_read_reg(), and LSM6DSO32_STATUS_REG.

Here is the call graph for this function:

◆ lsm6dso32_gy_full_scale_get()

int32_t lsm6dso32_gy_full_scale_get ( stmdev_ctx_t ctx,
lsm6dso32_fs_g_t val 
)

Gyroscope UI chain full-scale selection.[get].

Parameters
ctxread / write interface definitions
valGet the values of fs_g in reg CTRL2_G
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 480 of file lsm6dso32_reg.c.

482{
484 int32_t ret;
485
486 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&reg, 1);
487
488 switch (reg.fs_g)
489 {
490 case LSM6DSO32_250dps:
491 *val = LSM6DSO32_250dps;
492 break;
493
494 case LSM6DSO32_125dps:
495 *val = LSM6DSO32_125dps;
496 break;
497
498 case LSM6DSO32_500dps:
499 *val = LSM6DSO32_500dps;
500 break;
501
503 *val = LSM6DSO32_1000dps;
504 break;
505
507 *val = LSM6DSO32_2000dps;
508 break;
509
510 default:
511 *val = LSM6DSO32_250dps;
512 break;
513 }
514
515 return ret;
516}
@ LSM6DSO32_500dps
@ LSM6DSO32_125dps
@ LSM6DSO32_2000dps
@ LSM6DSO32_1000dps
@ LSM6DSO32_250dps

References lsm6dso32_ctrl2_g_t::fs_g, LSM6DSO32_1000dps, LSM6DSO32_125dps, LSM6DSO32_2000dps, LSM6DSO32_250dps, LSM6DSO32_500dps, LSM6DSO32_CTRL2_G, and lsm6dso32_read_reg().

Here is the call graph for this function:

◆ lsm6dso32_gy_full_scale_set()

int32_t lsm6dso32_gy_full_scale_set ( stmdev_ctx_t ctx,
lsm6dso32_fs_g_t  val 
)

Gyroscope UI chain full-scale selection.[set].

Parameters
ctxread / write interface definitions
valchange the values of fs_g in reg CTRL2_G
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 455 of file lsm6dso32_reg.c.

457{
459 int32_t ret;
460
461 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&reg, 1);
462
463 if (ret == 0)
464 {
465 reg.fs_g = (uint8_t) val;
466 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL2_G, (uint8_t *)&reg, 1);
467 }
468
469 return ret;
470}

References lsm6dso32_ctrl2_g_t::fs_g, LSM6DSO32_CTRL2_G, lsm6dso32_read_reg(), and lsm6dso32_write_reg().

Referenced by init_imuB(), and init_imup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_i2c_interface_get()

int32_t lsm6dso32_i2c_interface_get ( stmdev_ctx_t ctx,
lsm6dso32_i2c_disable_t val 
)

Disable / Enable I2C interface.[get].

Parameters
ctxread / write interface definitions
valGet the values of i2c_disable in reg CTRL4_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2910 of file lsm6dso32_reg.c.

2912{
2914 int32_t ret;
2915
2916 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL4_C, (uint8_t *)&reg, 1);
2917
2918 switch (reg.i2c_disable)
2919 {
2921 *val = LSM6DSO32_I2C_ENABLE;
2922 break;
2923
2925 *val = LSM6DSO32_I2C_DISABLE;
2926 break;
2927
2928 default:
2929 *val = LSM6DSO32_I2C_ENABLE;
2930 break;
2931 }
2932
2933 return ret;
2934}
#define LSM6DSO32_CTRL4_C
@ LSM6DSO32_I2C_ENABLE
@ LSM6DSO32_I2C_DISABLE

References lsm6dso32_ctrl4_c_t::i2c_disable, LSM6DSO32_CTRL4_C, LSM6DSO32_I2C_DISABLE, LSM6DSO32_I2C_ENABLE, and lsm6dso32_read_reg().

Here is the call graph for this function:

◆ lsm6dso32_i2c_interface_set()

int32_t lsm6dso32_i2c_interface_set ( stmdev_ctx_t ctx,
lsm6dso32_i2c_disable_t  val 
)

Disable / Enable I2C interface.[set].

Parameters
ctxread / write interface definitions
valchange the values of i2c_disable in reg CTRL4_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2884 of file lsm6dso32_reg.c.

2886{
2888 int32_t ret;
2889
2890 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL4_C, (uint8_t *)&reg, 1);
2891
2892 if (ret == 0)
2893 {
2894 reg.i2c_disable = (uint8_t)val;
2895 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL4_C, (uint8_t *)&reg, 1);
2896 }
2897
2898 return ret;
2899}

References lsm6dso32_ctrl4_c_t::i2c_disable, LSM6DSO32_CTRL4_C, lsm6dso32_read_reg(), and lsm6dso32_write_reg().

Here is the call graph for this function:

◆ lsm6dso32_i3c_disable_get()

int32_t lsm6dso32_i3c_disable_get ( stmdev_ctx_t ctx,
lsm6dso32_i3c_disable_t val 
)

I3C Enable/Disable communication protocol.[get].

Parameters
ctxread / write interface definitions
valchange the values of i3c_disable in reg CTRL9_XL
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2985 of file lsm6dso32_reg.c.

2987{
2988 lsm6dso32_ctrl9_xl_t ctrl9_xl;
2989 lsm6dso32_i3c_bus_avb_t i3c_bus_avb;
2990 int32_t ret;
2991
2993 (uint8_t *)&ctrl9_xl, 1);
2994
2995 if (ret == 0)
2996 {
2998 (uint8_t *)&i3c_bus_avb, 1);
2999
3000 switch ((ctrl9_xl.i3c_disable << 7) | i3c_bus_avb.i3c_bus_avb_sel)
3001 {
3003 *val = LSM6DSO32_I3C_DISABLE;
3004 break;
3005
3008 break;
3009
3012 break;
3013
3016 break;
3017
3020 break;
3021
3022 default:
3023 *val = LSM6DSO32_I3C_DISABLE;
3024 break;
3025 }
3026 }
3027
3028 return ret;
3029}
#define LSM6DSO32_CTRL9_XL
@ LSM6DSO32_I3C_ENABLE_T_25ms
@ LSM6DSO32_I3C_ENABLE_T_2us
@ LSM6DSO32_I3C_ENABLE_T_50us
@ LSM6DSO32_I3C_ENABLE_T_1ms
#define LSM6DSO32_I3C_BUS_AVB

References lsm6dso32_ctrl9_xl_t::i3c_disable, LSM6DSO32_CTRL9_XL, LSM6DSO32_I3C_BUS_AVB, LSM6DSO32_I3C_DISABLE, LSM6DSO32_I3C_ENABLE_T_1ms, LSM6DSO32_I3C_ENABLE_T_25ms, LSM6DSO32_I3C_ENABLE_T_2us, LSM6DSO32_I3C_ENABLE_T_50us, and lsm6dso32_read_reg().

Here is the call graph for this function:

◆ lsm6dso32_i3c_disable_set()

int32_t lsm6dso32_i3c_disable_set ( stmdev_ctx_t ctx,
lsm6dso32_i3c_disable_t  val 
)

I3C Enable/Disable communication protocol[.set].

Parameters
ctxread / write interface definitions
valchange the values of i3c_disable in reg CTRL9_XL
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2944 of file lsm6dso32_reg.c.

2946{
2947 lsm6dso32_i3c_bus_avb_t i3c_bus_avb;
2948 lsm6dso32_ctrl9_xl_t ctrl9_xl;
2949 int32_t ret;
2950
2952 (uint8_t *)&ctrl9_xl, 1);
2953
2954 if (ret == 0)
2955 {
2956 ctrl9_xl.i3c_disable = ((uint8_t)val & 0x80U) >> 7;
2958 (uint8_t *)&ctrl9_xl, 1);
2959 }
2960
2961 if (ret == 0)
2962 {
2964 (uint8_t *)&i3c_bus_avb, 1);
2965 }
2966
2967 if (ret == 0)
2968 {
2969 i3c_bus_avb.i3c_bus_avb_sel = (uint8_t)val & 0x03U;
2971 (uint8_t *)&i3c_bus_avb, 1);
2972 }
2973
2974 return ret;
2975}

References lsm6dso32_i3c_bus_avb_t::i3c_bus_avb_sel, lsm6dso32_ctrl9_xl_t::i3c_disable, LSM6DSO32_CTRL9_XL, LSM6DSO32_I3C_BUS_AVB, lsm6dso32_read_reg(), and lsm6dso32_write_reg().

Referenced by init_imuB(), and init_imup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_sdo_sa0_mode_get()

int32_t lsm6dso32_sdo_sa0_mode_get ( stmdev_ctx_t ctx,
lsm6dso32_sdo_pu_en_t val 
)

Connect/Disconnect SDO/SA0 internal pull-up.[get].

Parameters
ctxread / write interface definitions
valGet the values of sdo_pu_en in reg PIN_CTRL
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2791 of file lsm6dso32_reg.c.

2793{
2795 int32_t ret;
2796
2797 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_PIN_CTRL, (uint8_t *)&reg, 1);
2798
2799 switch (reg.sdo_pu_en)
2800 {
2803 break;
2804
2807 break;
2808
2809 default:
2811 break;
2812 }
2813
2814 return ret;
2815}
#define LSM6DSO32_PIN_CTRL
@ LSM6DSO32_PULL_UP_DISC
@ LSM6DSO32_PULL_UP_CONNECT

References LSM6DSO32_PIN_CTRL, LSM6DSO32_PULL_UP_CONNECT, LSM6DSO32_PULL_UP_DISC, lsm6dso32_read_reg(), and lsm6dso32_pin_ctrl_t::sdo_pu_en.

Here is the call graph for this function:

◆ lsm6dso32_sdo_sa0_mode_set()

int32_t lsm6dso32_sdo_sa0_mode_set ( stmdev_ctx_t ctx,
lsm6dso32_sdo_pu_en_t  val 
)

Connect/Disconnect SDO/SA0 internal pull-up.[set].

Parameters
ctxread / write interface definitions
valchange the values of sdo_pu_en in reg PIN_CTRL
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2766 of file lsm6dso32_reg.c.

2768{
2770 int32_t ret;
2771
2772 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_PIN_CTRL, (uint8_t *)&reg, 1);
2773
2774 if (ret == 0)
2775 {
2776 reg.sdo_pu_en = (uint8_t)val;
2777 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_PIN_CTRL, (uint8_t *)&reg, 1);
2778 }
2779
2780 return ret;
2781}

References LSM6DSO32_PIN_CTRL, lsm6dso32_read_reg(), lsm6dso32_write_reg(), and lsm6dso32_pin_ctrl_t::sdo_pu_en.

Here is the call graph for this function:

◆ lsm6dso32_spi_mode_get()

int32_t lsm6dso32_spi_mode_get ( stmdev_ctx_t ctx,
lsm6dso32_sim_t val 
)

SPI Serial Interface Mode selection.[get].

Parameters
ctxread / write interface definitions
valGet the values of sim in reg CTRL3_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2849 of file lsm6dso32_reg.c.

2851{
2853 int32_t ret;
2854
2855 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL3_C, (uint8_t *)&reg, 1);
2856
2857 switch (reg.sim)
2858 {
2860 *val = LSM6DSO32_SPI_4_WIRE;
2861 break;
2862
2864 *val = LSM6DSO32_SPI_3_WIRE;
2865 break;
2866
2867 default:
2868 *val = LSM6DSO32_SPI_4_WIRE;
2869 break;
2870 }
2871
2872 return ret;
2873}
@ LSM6DSO32_SPI_4_WIRE
@ LSM6DSO32_SPI_3_WIRE

References LSM6DSO32_CTRL3_C, lsm6dso32_read_reg(), LSM6DSO32_SPI_3_WIRE, LSM6DSO32_SPI_4_WIRE, and lsm6dso32_ctrl3_c_t::sim.

Here is the call graph for this function:

◆ lsm6dso32_spi_mode_set()

int32_t lsm6dso32_spi_mode_set ( stmdev_ctx_t ctx,
lsm6dso32_sim_t  val 
)

SPI Serial Interface Mode selection.[set].

Parameters
ctxread / write interface definitions
valchange the values of sim in reg CTRL3_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 2825 of file lsm6dso32_reg.c.

2826{
2828 int32_t ret;
2829
2830 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL3_C, (uint8_t *)&reg, 1);
2831
2832 if (ret == 0)
2833 {
2834 reg.sim = (uint8_t)val;
2835 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL3_C, (uint8_t *)&reg, 1);
2836 }
2837
2838 return ret;
2839}

References LSM6DSO32_CTRL3_C, lsm6dso32_read_reg(), lsm6dso32_write_reg(), and lsm6dso32_ctrl3_c_t::sim.

Here is the call graph for this function:

◆ lsm6dso32_status_reg_get()

int32_t lsm6dso32_status_reg_get ( stmdev_ctx_t ctx,
lsm6dso32_status_reg_t val 
)

The STATUS_REG register is read by the primary interface.[get].

Parameters
ctxread / write interface definitions
valregister STATUS_REG
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 849 of file lsm6dso32_reg.c.

851{
852 int32_t ret;
853
854 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_STATUS_REG, (uint8_t *) val, 1);
855
856 return ret;
857}

References lsm6dso32_read_reg(), and LSM6DSO32_STATUS_REG.

Referenced by calibrateIMU().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_temp_flag_data_ready_get()

int32_t lsm6dso32_temp_flag_data_ready_get ( stmdev_ctx_t ctx,
uint8_t *  val 
)

Temperature new data available.[get].

Parameters
ctxread / write interface definitions
valchange the values of tda in reg STATUS_REG
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 907 of file lsm6dso32_reg.c.

909{
911 int32_t ret;
912
913 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_STATUS_REG, (uint8_t *)&reg, 1);
914 *val = reg.tda;
915
916 return ret;
917}

References lsm6dso32_read_reg(), LSM6DSO32_STATUS_REG, and lsm6dso32_status_reg_t::tda.

Here is the call graph for this function:

◆ lsm6dso32_xl_data_rate_get()

int32_t lsm6dso32_xl_data_rate_get ( stmdev_ctx_t ctx,
lsm6dso32_odr_xl_t val 
)

Accelerometer UI data rate selection.[get].

Parameters
ctxread / write interface definitions
valGet the data rate and the power mode of the accelerometer
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 316 of file lsm6dso32_reg.c.

318{
319 lsm6dso32_ctrl1_xl_t ctrl1_xl;
320 lsm6dso32_ctrl5_c_t ctrl5_c;
321 lsm6dso32_ctrl6_c_t ctrl6_c;
322 lsm6dso32_func_cfg_access_t func_cfg_access;
323 int32_t ret;
324
326 (uint8_t *)&ctrl1_xl, 1);
327
328 if (ret == 0)
329 {
331 (uint8_t *)&func_cfg_access, 1);
332 }
333
334 if (ret == 0)
335 {
336 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL5_C, (uint8_t *) &ctrl5_c, 1);
337 }
338
339 if (ret == 0)
340 {
341 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL6_C, (uint8_t *) &ctrl6_c, 1);
342 }
343
344 switch ((ctrl5_c.xl_ulp_en << 5) + (ctrl6_c.xl_hm_mode << 4) +
345 ctrl1_xl.odr_xl)
346 {
349 break;
350
353 break;
354
357 break;
358
361 break;
362
365 break;
366
369 break;
370
373 break;
374
377 break;
378
381 break;
382
385 break;
386
389 break;
390
393 break;
394
397 break;
398
401 break;
402
405 break;
406
409 break;
410
413 break;
414
417 break;
418
421 break;
422
425 break;
426
429 break;
430
433 break;
434
437 break;
438
439 default:
441 break;
442 }
443
444 return ret;
445}
#define LSM6DSO32_CTRL6_C
#define LSM6DSO32_CTRL1_XL
@ LSM6DSO32_XL_ODR_3333Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_6667Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_833Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_208Hz_ULTRA_LOW_PW
@ LSM6DSO32_XL_ODR_12Hz5_HIGH_PERF
@ LSM6DSO32_XL_ODR_52Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_417Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_6Hz5_ULTRA_LOW_PW
@ LSM6DSO32_XL_ODR_208Hz_NORMAL_MD
@ LSM6DSO32_XL_ODR_26Hz_LOW_PW
@ LSM6DSO32_XL_ODR_208Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_12Hz5_LOW_PW
@ LSM6DSO32_XL_ODR_104Hz_NORMAL_MD
@ LSM6DSO32_XL_ODR_26Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_52Hz_ULTRA_LOW_PW
@ LSM6DSO32_XL_ODR_12Hz5_ULTRA_LOW_PW
@ LSM6DSO32_XL_ODR_6Hz5_LOW_PW
@ LSM6DSO32_XL_ODR_26Hz_ULTRA_LOW_PW
@ LSM6DSO32_XL_ODR_1667Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_OFF
@ LSM6DSO32_XL_ODR_104Hz_HIGH_PERF
@ LSM6DSO32_XL_ODR_52Hz_LOW_PW
@ LSM6DSO32_XL_ODR_104Hz_ULTRA_LOW_PW
#define LSM6DSO32_CTRL5_C
#define LSM6DSO32_FUNC_CFG_ACCESS

References LSM6DSO32_CTRL1_XL, LSM6DSO32_CTRL5_C, LSM6DSO32_CTRL6_C, LSM6DSO32_FUNC_CFG_ACCESS, lsm6dso32_read_reg(), LSM6DSO32_XL_ODR_104Hz_HIGH_PERF, LSM6DSO32_XL_ODR_104Hz_NORMAL_MD, LSM6DSO32_XL_ODR_104Hz_ULTRA_LOW_PW, LSM6DSO32_XL_ODR_12Hz5_HIGH_PERF, LSM6DSO32_XL_ODR_12Hz5_LOW_PW, LSM6DSO32_XL_ODR_12Hz5_ULTRA_LOW_PW, LSM6DSO32_XL_ODR_1667Hz_HIGH_PERF, LSM6DSO32_XL_ODR_208Hz_HIGH_PERF, LSM6DSO32_XL_ODR_208Hz_NORMAL_MD, LSM6DSO32_XL_ODR_208Hz_ULTRA_LOW_PW, LSM6DSO32_XL_ODR_26Hz_HIGH_PERF, LSM6DSO32_XL_ODR_26Hz_LOW_PW, LSM6DSO32_XL_ODR_26Hz_ULTRA_LOW_PW, LSM6DSO32_XL_ODR_3333Hz_HIGH_PERF, LSM6DSO32_XL_ODR_417Hz_HIGH_PERF, LSM6DSO32_XL_ODR_52Hz_HIGH_PERF, LSM6DSO32_XL_ODR_52Hz_LOW_PW, LSM6DSO32_XL_ODR_52Hz_ULTRA_LOW_PW, LSM6DSO32_XL_ODR_6667Hz_HIGH_PERF, LSM6DSO32_XL_ODR_6Hz5_LOW_PW, LSM6DSO32_XL_ODR_6Hz5_ULTRA_LOW_PW, LSM6DSO32_XL_ODR_833Hz_HIGH_PERF, LSM6DSO32_XL_ODR_OFF, lsm6dso32_ctrl1_xl_t::odr_xl, lsm6dso32_ctrl6_c_t::xl_hm_mode, and lsm6dso32_ctrl5_c_t::xl_ulp_en.

Here is the call graph for this function:

◆ lsm6dso32_xl_data_rate_set()

int32_t lsm6dso32_xl_data_rate_set ( stmdev_ctx_t ctx,
lsm6dso32_odr_xl_t  val 
)

Accelerometer UI data rate and power mode selection.[set].

Parameters
ctxread / write interface definitions
valChange the data rate and the power mode of the accelerometer
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 242 of file lsm6dso32_reg.c.

244{
245 lsm6dso32_ctrl1_xl_t ctrl1_xl;
246 lsm6dso32_ctrl5_c_t ctrl5_c;
247 lsm6dso32_ctrl6_c_t ctrl6_c;
248 lsm6dso32_func_cfg_access_t func_cfg_access;
249 int32_t ret;
250
252 (uint8_t *)&ctrl1_xl, 1);
253
254 if (ret == 0)
255 {
256 ctrl1_xl.odr_xl = (uint8_t) LSM6DSO32_XL_ODR_OFF & 0x0FU;
258 (uint8_t *)&ctrl1_xl, 1);
259 }
260
261 if (ret == 0)
262 {
264 (uint8_t *)&func_cfg_access, 1);
265 }
266
267 if (ret == 0)
268 {
269 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL5_C, (uint8_t *) &ctrl5_c, 1);
270 }
271
272 if (ret == 0)
273 {
274 ctrl5_c.xl_ulp_en = ((uint8_t)val & 0x20U) >> 5;
276 (uint8_t *) &ctrl5_c, 1);
277 }
278
279 if (ret == 0)
280 {
281 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL6_C, (uint8_t *) &ctrl6_c, 1);
282 }
283
284 if (ret == 0)
285 {
286 ctrl6_c.xl_hm_mode = ((uint8_t)val & 0x10U) >> 4;
288 (uint8_t *) &ctrl6_c, 1);
289 }
290
291 if (ret == 0)
292 {
294 (uint8_t *)&ctrl1_xl, 1);
295 }
296
297 if (ret == 0)
298 {
299 ctrl1_xl.odr_xl = (uint8_t) val & 0x0FU;
301 (uint8_t *)&ctrl1_xl, 1);
302 }
303
304 return ret;
305}

References LSM6DSO32_CTRL1_XL, LSM6DSO32_CTRL5_C, LSM6DSO32_CTRL6_C, LSM6DSO32_FUNC_CFG_ACCESS, lsm6dso32_read_reg(), lsm6dso32_write_reg(), LSM6DSO32_XL_ODR_OFF, lsm6dso32_ctrl1_xl_t::odr_xl, lsm6dso32_ctrl6_c_t::xl_hm_mode, and lsm6dso32_ctrl5_c_t::xl_ulp_en.

Referenced by init_imuB(), and init_imup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_xl_flag_data_ready_get()

int32_t lsm6dso32_xl_flag_data_ready_get ( stmdev_ctx_t ctx,
uint8_t *  val 
)

Accelerometer new data available.[get].

Parameters
ctxread / write interface definitions
valchange the values of xlda in reg STATUS_REG
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 867 of file lsm6dso32_reg.c.

869{
871 int32_t ret;
872
873 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_STATUS_REG, (uint8_t *)&reg, 1);
874 *val = reg.xlda;
875
876 return ret;
877}

References lsm6dso32_read_reg(), LSM6DSO32_STATUS_REG, and lsm6dso32_status_reg_t::xlda.

Here is the call graph for this function:

◆ lsm6dso32_xl_full_scale_get()

int32_t lsm6dso32_xl_full_scale_get ( stmdev_ctx_t ctx,
lsm6dso32_fs_xl_t val 
)

Accelerometer full-scale selection.[get].

Parameters
ctxread / write interface definitions
valGet the values of fs_xl in reg CTRL1_XL
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 199 of file lsm6dso32_reg.c.

201{
203 int32_t ret;
204
205 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL1_XL, (uint8_t *)&reg, 1);
206
207 switch (reg.fs_xl)
208 {
209 case LSM6DSO32_4g:
210 *val = LSM6DSO32_4g;
211 break;
212
213 case LSM6DSO32_8g:
214 *val = LSM6DSO32_8g;
215 break;
216
217 case LSM6DSO32_16g:
218 *val = LSM6DSO32_16g;
219 break;
220
221 case LSM6DSO32_32g:
222 *val = LSM6DSO32_32g;
223 break;
224
225 default:
226 *val = LSM6DSO32_4g;
227 break;
228 }
229
230 return ret;
231}
@ LSM6DSO32_32g
@ LSM6DSO32_16g
@ LSM6DSO32_8g
@ LSM6DSO32_4g

References lsm6dso32_ctrl1_xl_t::fs_xl, LSM6DSO32_16g, LSM6DSO32_32g, LSM6DSO32_4g, LSM6DSO32_8g, LSM6DSO32_CTRL1_XL, and lsm6dso32_read_reg().

Here is the call graph for this function:

◆ lsm6dso32_xl_full_scale_set()

int32_t lsm6dso32_xl_full_scale_set ( stmdev_ctx_t ctx,
lsm6dso32_fs_xl_t  val 
)

Accelerometer full-scale selection.[set].

Parameters
ctxread / write interface definitions
valchange the values of fs_xl in reg CTRL1_XL
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 172 of file lsm6dso32_reg.c.

174{
175 lsm6dso32_ctrl1_xl_t ctrl1_xl;
176 int32_t ret;
177
179 (uint8_t *)&ctrl1_xl, 1);
180
181 if (ret == 0)
182 {
183 ctrl1_xl.fs_xl = (uint8_t) val & 0x03U;
185 (uint8_t *)&ctrl1_xl, 1);
186 }
187
188 return ret;
189}

References lsm6dso32_ctrl1_xl_t::fs_xl, LSM6DSO32_CTRL1_XL, lsm6dso32_read_reg(), and lsm6dso32_write_reg().

Referenced by init_imuB(), and init_imup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_xl_offset_weight_get()

int32_t lsm6dso32_xl_offset_weight_get ( stmdev_ctx_t ctx,
lsm6dso32_usr_off_w_t val 
)

Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).[get].

Parameters
ctxread / write interface definitions
valGet the values of usr_off_w in reg CTRL6_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 742 of file lsm6dso32_reg.c.

744{
746 int32_t ret;
747
748 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL6_C, (uint8_t *)&reg, 1);
749
750 switch (reg.usr_off_w)
751 {
753 *val = LSM6DSO32_LSb_1mg;
754 break;
755
757 *val = LSM6DSO32_LSb_16mg;
758 break;
759
760 default:
761 *val = LSM6DSO32_LSb_1mg;
762 break;
763 }
764
765 return ret;
766}

References LSM6DSO32_CTRL6_C, LSM6DSO32_LSb_16mg, LSM6DSO32_LSb_1mg, lsm6dso32_read_reg(), and lsm6dso32_ctrl6_c_t::usr_off_w.

Here is the call graph for this function:

◆ lsm6dso32_xl_offset_weight_set()

int32_t lsm6dso32_xl_offset_weight_set ( stmdev_ctx_t ctx,
lsm6dso32_usr_off_w_t  val 
)

Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).[set].

Parameters
ctxread / write interface definitions
valchange the values of usr_off_w in reg CTRL6_C
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 716 of file lsm6dso32_reg.c.

718{
720 int32_t ret;
721
722 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL6_C, (uint8_t *)&reg, 1);
723
724 if (ret == 0)
725 {
726 reg.usr_off_w = (uint8_t)val;
727 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL6_C, (uint8_t *)&reg, 1);
728 }
729
730 return ret;
731}

References LSM6DSO32_CTRL6_C, lsm6dso32_read_reg(), lsm6dso32_write_reg(), and lsm6dso32_ctrl6_c_t::usr_off_w.

Referenced by calibrateIMU().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_xl_usr_offset_get()

int32_t lsm6dso32_xl_usr_offset_get ( stmdev_ctx_t ctx,
uint8_t *  val 
)

User offset on out flag.[get].

Parameters
ctxread / write interface definitions
valvalues of usr_off_on_out in reg CTRL7_G
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 1071 of file lsm6dso32_reg.c.

1072{
1074 int32_t ret;
1075
1076 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL7_G, (uint8_t *)&reg, 1);
1077 *val = reg.usr_off_on_out;
1078
1079 return ret;
1080}

References LSM6DSO32_CTRL7_G, lsm6dso32_read_reg(), and lsm6dso32_ctrl7_g_t::usr_off_on_out.

Here is the call graph for this function:

◆ lsm6dso32_xl_usr_offset_set()

int32_t lsm6dso32_xl_usr_offset_set ( stmdev_ctx_t ctx,
uint8_t  val 
)

Enables user offset on out.[set].

Parameters
ctxread / write interface definitions
valchange the values of usr_off_on_out in reg CTRL7_G
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 1047 of file lsm6dso32_reg.c.

1048{
1050 int32_t ret;
1051
1052 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_CTRL7_G, (uint8_t *)&reg, 1);
1053
1054 if (ret == 0)
1055 {
1056 reg.usr_off_on_out = val;
1057 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_CTRL7_G, (uint8_t *)&reg, 1);
1058 }
1059
1060 return ret;
1061}

References LSM6DSO32_CTRL7_G, lsm6dso32_read_reg(), lsm6dso32_write_reg(), and lsm6dso32_ctrl7_g_t::usr_off_on_out.

Referenced by calibrateIMU().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_xl_usr_offset_x_get()

int32_t lsm6dso32_xl_usr_offset_x_get ( stmdev_ctx_t ctx,
uint8_t *  buff 
)

Accelerometer X-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[get].

Parameters
ctxread / write interface definitions
buffbuffer that stores data read
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 949 of file lsm6dso32_reg.c.

951{
952 int32_t ret;
953
954 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_X_OFS_USR, buff, 1);
955
956 return ret;
957}
#define LSM6DSO32_X_OFS_USR

References lsm6dso32_read_reg(), and LSM6DSO32_X_OFS_USR.

Here is the call graph for this function:

◆ lsm6dso32_xl_usr_offset_x_set()

int32_t lsm6dso32_xl_usr_offset_x_set ( stmdev_ctx_t ctx,
uint8_t *  buff 
)

Accelerometer X-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[set].

Parameters
ctxread / write interface definitions
buffbuffer that contains data to write
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 929 of file lsm6dso32_reg.c.

931{
932 int32_t ret;
933
934 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_X_OFS_USR, buff, 1);
935
936 return ret;
937}

References lsm6dso32_write_reg(), and LSM6DSO32_X_OFS_USR.

Referenced by calibrateIMU().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_xl_usr_offset_y_get()

int32_t lsm6dso32_xl_usr_offset_y_get ( stmdev_ctx_t ctx,
uint8_t *  buff 
)

Accelerometer Y-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[get].

Parameters
ctxread / write interface definitions
buffbuffer that stores data read
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 989 of file lsm6dso32_reg.c.

991{
992 int32_t ret;
993
994 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_Y_OFS_USR, buff, 1);
995
996 return ret;
997}
#define LSM6DSO32_Y_OFS_USR

References lsm6dso32_read_reg(), and LSM6DSO32_Y_OFS_USR.

Here is the call graph for this function:

◆ lsm6dso32_xl_usr_offset_y_set()

int32_t lsm6dso32_xl_usr_offset_y_set ( stmdev_ctx_t ctx,
uint8_t *  buff 
)

Accelerometer Y-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[set].

Parameters
ctxread / write interface definitions
buffbuffer that contains data to write
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 969 of file lsm6dso32_reg.c.

971{
972 int32_t ret;
973
974 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_Y_OFS_USR, buff, 1);
975
976 return ret;
977}

References lsm6dso32_write_reg(), and LSM6DSO32_Y_OFS_USR.

Referenced by calibrateIMU().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lsm6dso32_xl_usr_offset_z_get()

int32_t lsm6dso32_xl_usr_offset_z_get ( stmdev_ctx_t ctx,
uint8_t *  buff 
)

Accelerometer Z-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[get].

Parameters
ctxread / write interface definitions
buffbuffer that stores data read
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 1029 of file lsm6dso32_reg.c.

1031{
1032 int32_t ret;
1033
1034 ret = lsm6dso32_read_reg(ctx, LSM6DSO32_Z_OFS_USR, buff, 1);
1035
1036 return ret;
1037}
#define LSM6DSO32_Z_OFS_USR

References lsm6dso32_read_reg(), and LSM6DSO32_Z_OFS_USR.

Here is the call graph for this function:

◆ lsm6dso32_xl_usr_offset_z_set()

int32_t lsm6dso32_xl_usr_offset_z_set ( stmdev_ctx_t ctx,
uint8_t *  buff 
)

Accelerometer Z-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range [-127 127].[set].

Parameters
ctxread / write interface definitions
buffbuffer that contains data to write
Return values
interfacestatus (MANDATORY: return 0 -> no Error)

Definition at line 1009 of file lsm6dso32_reg.c.

1011{
1012 int32_t ret;
1013
1014 ret = lsm6dso32_write_reg(ctx, LSM6DSO32_Z_OFS_USR, buff, 1);
1015
1016 return ret;
1017}

References lsm6dso32_write_reg(), and LSM6DSO32_Z_OFS_USR.

Referenced by calibrateIMU().

Here is the call graph for this function:
Here is the caller graph for this function: