Skip to content

Commit 71b92d9

Browse files
authored
Merge pull request #1 from grobx/main
LPS22DF Version 1.0.0
2 parents a315a0b + 0ca8440 commit 71b92d9

File tree

10 files changed

+2726
-0
lines changed

10 files changed

+2726
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: LPS22DF Continuous Integration
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '*'
8+
- '**.md'
9+
- '**.txt'
10+
pull_request:
11+
paths-ignore:
12+
- '*'
13+
- '**.md'
14+
- '**.txt'
15+
jobs:
16+
astyle_check:
17+
runs-on: ubuntu-latest
18+
name: AStyle check
19+
steps:
20+
# First of all, clone the repo using the checkout action.
21+
- name: Checkout
22+
uses: actions/checkout@main
23+
24+
- name: Astyle check
25+
id: Astyle
26+
uses: stm32duino/actions/astyle-check@main
27+
28+
# Use the output from the `Astyle` step
29+
- name: Astyle Errors
30+
if: failure()
31+
run: |
32+
cat ${{ steps.Astyle.outputs.astyle-result }}
33+
exit 1
34+
spell-check:
35+
runs-on: ubuntu-latest
36+
name: Spell check
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
41+
- name: Spell check
42+
uses: arduino/actions/libraries/spell-check@master
43+
with:
44+
ignore-words-list: ./extras/codespell-ignore-words-list.txt
45+
lib_build:
46+
runs-on: ubuntu-latest
47+
name: Library compilation
48+
steps:
49+
50+
# First of all, clone the repo using the checkout action.
51+
- name: Checkout
52+
uses: actions/checkout@main
53+
54+
- name: Compilation
55+
id: compile
56+
uses: stm32duino/actions/compile-examples@main
57+
with:
58+
board-pattern: "NUCLEO_L476RG|B_U585I_IOT02A"
59+
60+
# Use the output from the `Compilation` step
61+
- name: Compilation Errors
62+
if: failure()
63+
run: |
64+
cat ${{ steps.compile.outputs.compile-result }}
65+
exit 1

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# LPS22DF
2+
3+
Arduino library to support the LPS22DF 260-1260 hPa absolute digital output barometer
4+
5+
## API
6+
7+
This sensor uses I2C or SPI to communicate.
8+
For I2C it is then required to create a TwoWire interface before accessing to the sensors:
9+
10+
TwoWire dev_i2c(I2C_SDA, I2C_SCL);
11+
dev_i2c.begin();
12+
13+
For SPI it is then required to create a SPI interface before accessing to the sensors:
14+
15+
SPIClass dev_spi(SPI_MOSI, SPI_MISO, SPI_SCK);
16+
dev_spi.begin();
17+
18+
An instance can be created and enabled when the I2C bus is used following the procedure below:
19+
20+
LPS22DFSensor PressTemp(&dev_i2c);
21+
PressTemp.begin();
22+
PressTemp.Enable();
23+
24+
An instance can be created and enabled when the SPI bus is used following the procedure below:
25+
26+
LPS22DFSensor PressTemp(&dev_spi, CS_PIN);
27+
PressTemp.begin();
28+
PressTemp.Enable();
29+
30+
The access to the sensor values is done as explained below:
31+
32+
Read pressure and temperature.
33+
34+
float pressure;
35+
float temperature;
36+
PressTemp.GetPressure(&pressure);
37+
PressTemp.GetTemperature(&temperature);
38+
39+
## Documentation
40+
41+
You can find the source files at
42+
https://github.com/stm32duino/LPS22DF
43+
44+
The LPS22DF datasheet is available at
45+
https://www.st.com/content/st_com/en/products/mems-and-sensors/pressure-sensors/lps22df.html
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
@file LPS22DF_Example.ino
3+
@author Giuseppe Roberti <giuseppe.roberti@ieee.org>
4+
@brief Example to use the LPS22DF 260-1260 hPa absolute digital
5+
output barometer
6+
*******************************************************************************
7+
Copyright (c) 2022, STMicroelectronics
8+
All rights reserved.
9+
This software component is licensed by ST under BSD 3-Clause license,
10+
the "License"; You may not use this file except in compliance with the
11+
License. You may obtain a copy of the License at:
12+
opensource.org/licenses/BSD-3-Clause
13+
*******************************************************************************
14+
*/
15+
16+
#include <LPS22DFSensor.h>
17+
18+
LPS22DFSensor sensor (&Wire);
19+
float pressure, temperature;
20+
21+
void setup() {
22+
pinMode(LED_BUILTIN, OUTPUT);
23+
Serial.begin(115200);
24+
Wire.begin();
25+
sensor.begin();
26+
sensor.Enable();
27+
}
28+
29+
void loop() {
30+
sensor.GetPressure(&pressure);
31+
sensor.GetTemperature(&temperature);
32+
33+
Serial.print("Pressure[hPa]:");
34+
Serial.print(pressure, 2);
35+
Serial.print(", Temperature[C]:");
36+
Serial.println(temperature, 2);
37+
38+
blink(LED_BUILTIN);
39+
}
40+
41+
inline void blink(int pin) {
42+
digitalWrite(pin, HIGH);
43+
delay(25);
44+
digitalWrite(pin, LOW);
45+
delay(975);
46+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ths

keywords.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#######################################
2+
# Syntax Coloring Map For LPS22DF
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
LPS22DFSensor KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
begin KEYWORD2
16+
end KEYWORD2
17+
ReadID KEYWORD2
18+
Enable KEYWORD2
19+
Disable KEYWORD2
20+
GetOutputDataRate KEYWORD2
21+
SetOutputDataRate KEYWORD2
22+
GetPressure KEYWORD2
23+
Get_PRESS_DRDY_Status KEYWORD2
24+
GetTemperature KEYWORD2
25+
Get_TEMP_DRDY_Status KEYWORD2
26+
Read_Reg KEYWORD2
27+
Write_Reg KEYWORD2
28+
Set_One_Shot KEYWORD2
29+
Get_One_Shot_Status KEYWORD2
30+
31+
#######################################
32+
# Constants (LITERAL1)
33+
#######################################
34+
35+
LPS22DF_OK LITERAL1
36+
LPS22DF_ERROR LITERAL1

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=STM32duino LPS22DF
2+
version=1.0.0
3+
author=SRA
4+
maintainer=stm32duino
5+
sentence=Nano pressure sensor.
6+
paragraph=This library provides Arduino support for the nano pressure sensor LPS22DF for STM32 boards.
7+
category=Sensors
8+
url=https://github.com/stm32duino/LPS22DF
9+
architectures=stm32, avr, sam

0 commit comments

Comments
 (0)