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

LIS2MDL driver file. More...

#include "lis2mdl_reg.h"
#include "main.h"
Include dependency graph for lis2mdl_reg.c:

Go to the source code of this file.

Macros

#define LIS2MDL_CS_GPIO_Port   MAG_CS_GPIO_Port
 
#define LIS2MDL_CS_Pin   MAG_CS_Pin
 
#define platform_delay(ms)   HAL_Delay(ms)
 
#define LIS2MDL_SPI_TIMEOUT   100
 

Functions

int32_t __weak lis2mdl_read_reg (const stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, uint16_t len)
 Read generic device register.
 
int32_t __weak 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].
 
static int32_t platform_spi_write (void *handle, uint8_t reg, const uint8_t *bufp, uint16_t len)
 Write data to LIS2MDL sensor via SPI.
 
static int32_t platform_spi_read (void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)
 Read data from LIS2MDL sensor via SPI.
 
int32_t lis2mdl_init (stmdev_ctx_t *ctx)
 Initialize the LIS2MDL sensor.
 
int32_t lis2mdl_init_2 (stmdev_ctx_t *ctx)
 

Detailed Description

LIS2MDL driver file.

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.c.

Macro Definition Documentation

◆ LIS2MDL_CS_GPIO_Port

#define LIS2MDL_CS_GPIO_Port   MAG_CS_GPIO_Port

Definition at line 24 of file lis2mdl_reg.c.

◆ LIS2MDL_CS_Pin

#define LIS2MDL_CS_Pin   MAG_CS_Pin

Definition at line 27 of file lis2mdl_reg.c.

◆ LIS2MDL_SPI_TIMEOUT

#define LIS2MDL_SPI_TIMEOUT   100

Definition at line 36 of file lis2mdl_reg.c.

◆ platform_delay

#define platform_delay (   ms)    HAL_Delay(ms)

Definition at line 32 of file lis2mdl_reg.c.