Skip to content

Implement LIS2MDL library #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# LIS2MDL
Arduino library to support the LIS2MDL high-performance 3-axis magnetometer

## API

This sensor uses I2C or SPI to communicate.
For I2C it is then required to create a TwoWire interface before accessing to the sensors:

dev_i2c = new TwoWire(I2C_SDA, I2C_SCL);
dev_i2c->begin();

For SPI it is then required to create a SPI interface before accessing to the sensors:

dev_spi = new SPIClass(SPI_MOSI, SPI_MISO, SPI_SCK);
dev_spi->begin();

An instance can be created and enbaled when the I2C bus is used following the procedure below:

Magneto = new LIS2MDLSensor(dev_i2c);
Magneto->Enable();

An instance can be created and enbaled when the SPI bus is used following the procedure below:

Magneto = new LIS2MDLSensor(dev_spi, CS_PIN);
Magneto->Enable();

The access to the sensor values is done as explained below:

Read magnetometer.

Magneto->GetAxes(&magnetometer);

## Documentation

You can find the source files at
https://github.com/stm32duino/LIS2MDL

The LIS2MDL datasheet is available at
https://www.st.com/en/mems-and-sensors/lis2mdl.html
36 changes: 36 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#######################################
# Syntax Coloring Map For LIS2MDL
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

LIS2MDLSensor KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

ReadID KEYWORD2
Enable KEYWORD2
Disable KEYWORD2
GetSensitivity KEYWORD2
GetOutputDataRate KEYWORD2
SetOutputDataRate KEYWORD2
GetFullScale KEYWORD2
SetFullScale KEYWORD2
GetAxes KEYWORD2
GetAxesRaw KEYWORD2
ReadReg KEYWORD2
WriteReg KEYWORD2
SetSelfTest KEYWORD2
GetDRDYStatus KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################

LIS2MDL_OK LITERAL1
LIS2MDL_ERROR LITERAL1
LIS2MDL_MAG_SENSITIVITY_FS_50GAUSS LITERAL1
9 changes: 9 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=STM32duino LIS2MDL
version=1.0.0
author=SRA
maintainer=stm32duino
sentence=Ultra Low Power 3D magnetometer.
paragraph=This library provides Arduino support for the Ultra Low Power 3D magnetometer LIS2MDL for STM32 boards.
category=Sensors
url=https://github.com/stm32duino/LIS2MDL
architectures=stm32, avr, sam
Loading