Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
lis2mdl_reg.h File Reference

This file contains all the functions prototypes for the lis2mdl_reg.c driver. More...

#include <stdint.h>
#include <stddef.h>
#include <math.h>
Include dependency graph for lis2mdl_reg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  bitwise_t
 
struct  stmdev_ctx_t
 
struct  ucf_line_t
 
struct  lis2mdl_cfg_reg_a_t
 
struct  lis2mdl_cfg_reg_b_t
 
struct  lis2mdl_cfg_reg_c_t
 
struct  lis2mdl_int_crtl_reg_t
 
struct  lis2mdl_int_source_reg_t
 
struct  lis2mdl_status_reg_t
 
union  lis2mdl_reg_t
 

Macros

#define DRV_LITTLE_ENDIAN   1234
 
#define DRV_BIG_ENDIAN   4321
 
#define DRV_BYTE_ORDER   DRV_LITTLE_ENDIAN
 
#define MEMS_SHARED_TYPES
 
#define PROPERTY_DISABLE   (0U)
 
#define PROPERTY_ENABLE   (1U)
 
#define MEMS_UCF_SHARED_TYPES
 
#define LIS2MDL_I2C_ADD   0x3DU
 
#define LIS2MDL_ID   0x40U
 
#define LIS2MDL_OFFSET_X_REG_L   0x45U
 
#define LIS2MDL_OFFSET_X_REG_H   0x46U
 
#define LIS2MDL_OFFSET_Y_REG_L   0x47U
 
#define LIS2MDL_OFFSET_Y_REG_H   0x48U
 
#define LIS2MDL_OFFSET_Z_REG_L   0x49U
 
#define LIS2MDL_OFFSET_Z_REG_H   0x4AU
 
#define LIS2MDL_WHO_AM_I   0x4FU
 
#define LIS2MDL_CFG_REG_A   0x60U
 
#define LIS2MDL_CFG_REG_B   0x61U
 
#define LIS2MDL_CFG_REG_C   0x62U
 
#define LIS2MDL_INT_CRTL_REG   0x63U
 
#define LIS2MDL_INT_SOURCE_REG   0x64U
 
#define LIS2MDL_INT_THS_L_REG   0x65U
 
#define LIS2MDL_INT_THS_H_REG   0x66U
 
#define LIS2MDL_STATUS_REG   0x67U
 
#define LIS2MDL_OUTX_L_REG   0x68U
 
#define LIS2MDL_OUTX_H_REG   0x69U
 
#define LIS2MDL_OUTY_L_REG   0x6AU
 
#define LIS2MDL_OUTY_H_REG   0x6BU
 
#define LIS2MDL_OUTZ_L_REG   0x6CU
 
#define LIS2MDL_OUTZ_H_REG   0x6DU
 
#define LIS2MDL_TEMP_OUT_L_REG   0x6EU
 
#define LIS2MDL_TEMP_OUT_H_REG   0x6FU
 
#define __weak   __attribute__((weak))
 

Typedefs

typedef int32_t(* stmdev_write_ptr) (void *, uint8_t, const uint8_t *, uint16_t)
 
typedef int32_t(* stmdev_read_ptr) (void *, uint8_t, uint8_t *, uint16_t)
 
typedef void(* stmdev_mdelay_ptr) (uint32_t millisec)
 

Enumerations

enum  lis2mdl_md_t { LIS2MDL_CONTINUOUS_MODE = 0 , LIS2MDL_SINGLE_TRIGGER = 1 , LIS2MDL_POWER_DOWN = 2 }
 
enum  lis2mdl_odr_t { LIS2MDL_ODR_10Hz = 0 , LIS2MDL_ODR_20Hz = 1 , LIS2MDL_ODR_50Hz = 2 , LIS2MDL_ODR_100Hz = 3 }
 
enum  lis2mdl_lp_t { LIS2MDL_HIGH_RESOLUTION = 0 , LIS2MDL_LOW_POWER = 1 }
 
enum  lis2mdl_lpf_t { LIS2MDL_ODR_DIV_2 = 0 , LIS2MDL_ODR_DIV_4 = 1 }
 
enum  lis2mdl_set_rst_t { LIS2MDL_SET_SENS_ODR_DIV_63 = 0 , LIS2MDL_SENS_OFF_CANC_EVERY_ODR = 1 , LIS2MDL_SET_SENS_ONLY_AT_POWER_ON = 2 }
 
enum  lis2mdl_ble_t { LIS2MDL_LSB_AT_LOW_ADD = 0 , LIS2MDL_MSB_AT_LOW_ADD = 1 }
 
enum  lis2mdl_int_on_dataoff_t { LIS2MDL_CHECK_BEFORE = 0 , LIS2MDL_CHECK_AFTER = 1 }
 
enum  lis2mdl_sim_t { LIS2MDL_SPI_4_WIRE = 1 , LIS2MDL_SPI_3_WIRE = 0 }
 
enum  lis2mdl_i2c_dis_t { LIS2MDL_I2C_ENABLE = 0 , LIS2MDL_I2C_DISABLE = 1 }
 

Functions

int32_t lis2mdl_read_reg (const stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len)
 Read generic device register.
 
int32_t lis2mdl_write_reg (const stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len)
 Write generic device register.
 
float_t lis2mdl_from_lsb_to_mgauss (int16_t lsb)
 
float_t lis2mdl_from_lsb_to_celsius (int16_t lsb)
 
float_t lis2mdl_from_lsb_to_nanotesla (int16_t lsb)
 Converts raw magnetic data to nanotesla (nT). Sensitivity: 1 LSB = 1.5 mG = 150 nT.
 
int32_t lis2mdl_mag_user_offset_set (const stmdev_ctx_t *ctx, int16_t *val)
 These registers comprise a 3 group of 16-bit number and represent hard-iron offset in order to compensate environmental effects. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG. These values act on the magnetic output data value in order to delete the environmental offset.[set].
 
int32_t lis2mdl_mag_user_offset_get (const stmdev_ctx_t *ctx, int16_t *val)
 These registers comprise a 3 group of 16-bit number and represent hard-iron offset in order to compensate environmental effects. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG. These values act on the magnetic output data value in order to delete the environmental offset.[get].
 
int32_t lis2mdl_operating_mode_set (const stmdev_ctx_t *ctx, lis2mdl_md_t val)
 Operating mode selection.[set].
 
int32_t lis2mdl_operating_mode_get (const stmdev_ctx_t *ctx, lis2mdl_md_t *val)
 Operating mode selection.[get].
 
int32_t lis2mdl_data_rate_set (const stmdev_ctx_t *ctx, lis2mdl_odr_t val)
 Output data rate selection.[set].
 
int32_t lis2mdl_data_rate_get (const stmdev_ctx_t *ctx, lis2mdl_odr_t *val)
 Output data rate selection.[get].
 
int32_t lis2mdl_power_mode_set (const stmdev_ctx_t *ctx, lis2mdl_lp_t val)
 Enables high-resolution/low-power mode.[set].
 
int32_t lis2mdl_power_mode_get (const stmdev_ctx_t *ctx, lis2mdl_lp_t *val)
 Enables high-resolution/low-power mode.[get].
 
int32_t lis2mdl_offset_temp_comp_set (const stmdev_ctx_t *ctx, uint8_t val)
 Enables the magnetometer temperature compensation.[set].
 
int32_t lis2mdl_offset_temp_comp_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Enables the magnetometer temperature compensation.[get].
 
int32_t lis2mdl_low_pass_bandwidth_set (const stmdev_ctx_t *ctx, lis2mdl_lpf_t val)
 Low-pass bandwidth selection.[set].
 
int32_t lis2mdl_low_pass_bandwidth_get (const stmdev_ctx_t *ctx, lis2mdl_lpf_t *val)
 Low-pass bandwidth selection.[get].
 
int32_t lis2mdl_set_rst_mode_set (const stmdev_ctx_t *ctx, lis2mdl_set_rst_t val)
 Reset mode.[set].
 
int32_t lis2mdl_set_rst_mode_get (const stmdev_ctx_t *ctx, lis2mdl_set_rst_t *val)
 Reset mode.[get].
 
int32_t lis2mdl_set_rst_sensor_single_set (const stmdev_ctx_t *ctx, uint8_t val)
 Enables offset cancellation in single measurement mode. The OFF_CANC bit must be set to 1 when enabling offset cancellation in single measurement mode this means a call function: set_rst_mode(SENS_OFF_CANC_EVERY_ODR) is need.[set].
 
int32_t lis2mdl_set_rst_sensor_single_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Enables offset cancellation in single measurement mode. The OFF_CANC bit must be set to 1 when enabling offset cancellation in single measurement mode this means a call function: set_rst_mode(SENS_OFF_CANC_EVERY_ODR) is need.[get].
 
int32_t lis2mdl_block_data_update_set (const stmdev_ctx_t *ctx, uint8_t val)
 Blockdataupdate.[set].
 
int32_t lis2mdl_block_data_update_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Blockdataupdate.[get].
 
int32_t lis2mdl_mag_data_ready_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Magnetic set of data available.[get].
 
int32_t lis2mdl_mag_data_ovr_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Magnetic set of data overrun.[get].
 
int32_t lis2mdl_magnetic_raw_get (const stmdev_ctx_t *ctx, int16_t *val)
 Magnetic output value.[get].
 
int32_t lis2mdl_temperature_raw_get (const stmdev_ctx_t *ctx, int16_t *val)
 Temperature output value.[get].
 
int32_t lis2mdl_device_id_get (const stmdev_ctx_t *ctx, uint8_t *buff)
 DeviceWhoamI.[get].
 
int32_t lis2mdl_reset_set (const stmdev_ctx_t *ctx, uint8_t val)
 Software reset. Restore the default values in user registers.[set].
 
int32_t lis2mdl_reset_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Software reset. Restore the default values in user registers.[get].
 
int32_t lis2mdl_boot_set (const stmdev_ctx_t *ctx, uint8_t val)
 Reboot memory content. Reload the calibration parameters.[set].
 
int32_t lis2mdl_boot_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Reboot memory content. Reload the calibration parameters.[get].
 
int32_t lis2mdl_self_test_set (const stmdev_ctx_t *ctx, uint8_t val)
 Selftest.[set].
 
int32_t lis2mdl_self_test_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Selftest.[get].
 
int32_t lis2mdl_data_format_set (const stmdev_ctx_t *ctx, lis2mdl_ble_t val)
 Big/Little Endian data selection.[set].
 
int32_t lis2mdl_data_format_get (const stmdev_ctx_t *ctx, lis2mdl_ble_t *val)
 Big/Little Endian data selection.[get].
 
int32_t lis2mdl_status_get (const stmdev_ctx_t *ctx, lis2mdl_status_reg_t *val)
 Info about device status.[get].
 
int32_t lis2mdl_offset_int_conf_set (const stmdev_ctx_t *ctx, lis2mdl_int_on_dataoff_t val)
 The interrupt block recognition checks data after/before the hard-iron correction to discover the interrupt.[set].
 
int32_t lis2mdl_offset_int_conf_get (const stmdev_ctx_t *ctx, lis2mdl_int_on_dataoff_t *val)
 The interrupt block recognition checks data after/before the hard-iron correction to discover the interrupt.[get].
 
int32_t lis2mdl_drdy_on_pin_set (const stmdev_ctx_t *ctx, uint8_t val)
 Data-ready signal on INT_DRDY pin.[set].
 
int32_t lis2mdl_drdy_on_pin_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Data-ready signal on INT_DRDY pin.[get].
 
int32_t lis2mdl_int_on_pin_set (const stmdev_ctx_t *ctx, uint8_t val)
 Interrupt signal on INT_DRDY pin.[set].
 
int32_t lis2mdl_int_on_pin_get (const stmdev_ctx_t *ctx, uint8_t *val)
 Interrupt signal on INT_DRDY pin.[get].
 
int32_t lis2mdl_int_gen_conf_set (const stmdev_ctx_t *ctx, lis2mdl_int_crtl_reg_t *val)
 Interrupt generator configuration register.[set].
 
int32_t lis2mdl_int_gen_conf_get (const stmdev_ctx_t *ctx, lis2mdl_int_crtl_reg_t *val)
 Interrupt generator configuration register.[get].
 
int32_t lis2mdl_int_gen_source_get (const stmdev_ctx_t *ctx, lis2mdl_int_source_reg_t *val)
 Interrupt generator source register.[get].
 
int32_t lis2mdl_int_gen_threshold_set (const stmdev_ctx_t *ctx, uint16_t val)
 User-defined threshold value for xl interrupt event on generator. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG.[set].
 
int32_t lis2mdl_int_gen_threshold_get (const stmdev_ctx_t *ctx, uint16_t *val)
 User-defined threshold value for xl interrupt event on generator. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG.[get].
 
int32_t lis2mdl_spi_mode_set (const stmdev_ctx_t *ctx, lis2mdl_sim_t val)
 SPI Serial Interface Mode selection.[set].
 
int32_t lis2mdl_spi_mode_get (const stmdev_ctx_t *ctx, lis2mdl_sim_t *val)
 SPI Serial Interface Mode selection.[get].
 
int32_t lis2mdl_i2c_interface_set (const stmdev_ctx_t *ctx, lis2mdl_i2c_dis_t val)
 Enable/Disable I2C interface.[set].
 
int32_t lis2mdl_i2c_interface_get (const stmdev_ctx_t *ctx, lis2mdl_i2c_dis_t *val)
 Enable/Disable I2C interface.[get].
 
int32_t lis2mdl_init (stmdev_ctx_t *ctx)
 Initialize the LIS2MDL sensor.
 
int32_t lis2mdl_init_2 (stmdev_ctx_t *ctx)
 

Detailed Description

This file contains all the functions prototypes for the lis2mdl_reg.c driver.

Author
Sensors Software Solution Team
Attention

© Copyright (c) 2021 STMicroelectronics. All rights reserved.

This software component is licensed by ST under BSD 3-Clause license, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause

Definition in file lis2mdl_reg.h.