Skip to content

Commit fc37d51

Browse files
committed
clangf
1 parent 3791d19 commit fc37d51

File tree

2 files changed

+81
-78
lines changed

2 files changed

+81
-78
lines changed

Adafruit_LPS28.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ bool Adafruit_LPS28::setFullScaleMode(bool mode) {
6060

6161
bool Adafruit_LPS28::getFullScaleMode() {
6262
Adafruit_BusIO_Register ctrl_reg2(i2c_dev, LPS28_CTRL_REG2, 1);
63-
Adafruit_BusIO_RegisterBits fs_mode_bit(&ctrl_reg2, 1, 6); // FS_MODE bit is bit 6
63+
Adafruit_BusIO_RegisterBits fs_mode_bit(&ctrl_reg2, 1,
64+
6); // FS_MODE bit is bit 6
6465
return fs_mode_bit.read();
6566
}
6667

@@ -145,17 +146,21 @@ bool Adafruit_LPS28::setPressureInterrupt(bool low, bool high, bool latching) {
145146
return phe_bit.write(high) && ple_bit.write(low) && lir_bit.write(latching);
146147
}
147148

148-
149-
bool Adafruit_LPS28::setIntPinOutput(bool drdy, bool drdy_pulse, bool int_enable,
150-
bool fifo_full, bool fifo_watermark, bool fifo_overrun) {
149+
bool Adafruit_LPS28::setIntPinOutput(bool drdy, bool drdy_pulse,
150+
bool int_enable, bool fifo_full,
151+
bool fifo_watermark, bool fifo_overrun) {
151152
Adafruit_BusIO_Register ctrl_reg4(i2c_dev, LPS28_CTRL_REG4, 1);
152153

153-
Adafruit_BusIO_RegisterBits drdy_pulse_bit(&ctrl_reg4, 1, 6); // Bit 6: DRDY_PLS
154-
Adafruit_BusIO_RegisterBits drdy_bit(&ctrl_reg4, 1, 5); // Bit 5: DRDY
154+
Adafruit_BusIO_RegisterBits drdy_pulse_bit(&ctrl_reg4, 1,
155+
6); // Bit 6: DRDY_PLS
156+
Adafruit_BusIO_RegisterBits drdy_bit(&ctrl_reg4, 1, 5); // Bit 5: DRDY
155157
Adafruit_BusIO_RegisterBits int_enable_bit(&ctrl_reg4, 1, 4); // Bit 4: INT_EN
156-
Adafruit_BusIO_RegisterBits fifo_full_bit(&ctrl_reg4, 1, 2); // Bit 2: INT_F_FULL
157-
Adafruit_BusIO_RegisterBits fifo_watermark_bit(&ctrl_reg4, 1, 1); // Bit 1: INT_F_WTM
158-
Adafruit_BusIO_RegisterBits fifo_overrun_bit(&ctrl_reg4, 1, 0); // Bit 0: INT_F_OVR
158+
Adafruit_BusIO_RegisterBits fifo_full_bit(&ctrl_reg4, 1,
159+
2); // Bit 2: INT_F_FULL
160+
Adafruit_BusIO_RegisterBits fifo_watermark_bit(&ctrl_reg4, 1,
161+
1); // Bit 1: INT_F_WTM
162+
Adafruit_BusIO_RegisterBits fifo_overrun_bit(&ctrl_reg4, 1,
163+
0); // Bit 0: INT_F_OVR
159164

160165
bool drdy_pulse_ok = drdy_pulse_bit.write(drdy_pulse);
161166
bool drdy_ok = drdy_bit.write(drdy);
@@ -164,24 +169,25 @@ bool Adafruit_LPS28::setIntPinOutput(bool drdy, bool drdy_pulse, bool int_enable
164169
bool fifo_watermark_ok = fifo_watermark_bit.write(fifo_watermark);
165170
bool fifo_overrun_ok = fifo_overrun_bit.write(fifo_overrun);
166171

167-
return drdy_pulse_ok && drdy_ok && int_enable_ok &&
168-
fifo_full_ok && fifo_watermark_ok && fifo_overrun_ok;
172+
return drdy_pulse_ok && drdy_ok && int_enable_ok && fifo_full_ok &&
173+
fifo_watermark_ok && fifo_overrun_ok;
169174
}
170175

171-
172-
bool Adafruit_LPS28::setFIFOmode(bool stop_on_watermark, lps28_fifo_mode_t mode) {
176+
bool Adafruit_LPS28::setFIFOmode(bool stop_on_watermark,
177+
lps28_fifo_mode_t mode) {
173178
Adafruit_BusIO_Register fifo_ctrl(i2c_dev, LPS28_FIFO_CTRL, 1);
174179

175-
Adafruit_BusIO_RegisterBits stop_on_wtm_bit(&fifo_ctrl, 1, 3); // Bit 3: STOP_ON_WTM
176-
Adafruit_BusIO_RegisterBits f_mode_bits(&fifo_ctrl, 3, 0); // Bits 2:0 (F_MODE[2:0])
180+
Adafruit_BusIO_RegisterBits stop_on_wtm_bit(&fifo_ctrl, 1,
181+
3); // Bit 3: STOP_ON_WTM
182+
Adafruit_BusIO_RegisterBits f_mode_bits(&fifo_ctrl, 3,
183+
0); // Bits 2:0 (F_MODE[2:0])
177184

178185
bool stop_ok = stop_on_wtm_bit.write(stop_on_watermark);
179186
bool mode_ok = f_mode_bits.write(mode);
180187

181188
return stop_ok && mode_ok;
182189
}
183190

184-
185191
bool Adafruit_LPS28::setFIFOWatermark(uint8_t wtm) {
186192
Adafruit_BusIO_Register fifo_wtm(i2c_dev, LPS28_FIFO_WTM, 1);
187193
return fifo_wtm.write(wtm);
@@ -192,7 +198,6 @@ uint8_t Adafruit_LPS28::getFIFOWatermark() {
192198
return fifo_wtm.read();
193199
}
194200

195-
196201
int16_t Adafruit_LPS28::getReferencePressure() {
197202
Adafruit_BusIO_Register ref_p(i2c_dev, LPS28_REF_P, 2, LSBFIRST);
198203
return ref_p.read();
@@ -208,7 +213,6 @@ int16_t Adafruit_LPS28::getPressureOffset() {
208213
return rpds.read();
209214
}
210215

211-
212216
uint8_t Adafruit_LPS28::getIntSource() {
213217
Adafruit_BusIO_Register int_source(i2c_dev, LPS28_INT_SOURCE, 1);
214218
return int_source.read();
@@ -224,8 +228,6 @@ uint8_t Adafruit_LPS28::getStatus() {
224228
return status_reg.read();
225229
}
226230

227-
228-
229231
float Adafruit_LPS28::getPressure() {
230232
// Read the 3-byte PRESS_OUT register
231233
Adafruit_BusIO_Register pressure_out(i2c_dev, LPS28_PRESS_OUT, 3, LSBFIRST);
@@ -245,7 +247,6 @@ float Adafruit_LPS28::getPressure() {
245247
return pressure_hpa;
246248
}
247249

248-
249250
float Adafruit_LPS28::getTemperature() {
250251
// Read the 2-byte TEMP_OUT register (signed 16-bit, 2's complement)
251252
Adafruit_BusIO_Register temp_out(i2c_dev, LPS28_TEMP_OUT, 2, LSBFIRST);
@@ -259,7 +260,8 @@ float Adafruit_LPS28::getTemperature() {
259260

260261
float Adafruit_LPS28::getFIFOpressure() {
261262
// Read the 3-byte FIFO_DATA_OUT_PRESS_XL register
262-
Adafruit_BusIO_Register fifo_pressure_out(i2c_dev, LPS28_FIFO_DATA_OUT_PRESS_XL, 3, LSBFIRST);
263+
Adafruit_BusIO_Register fifo_pressure_out(
264+
i2c_dev, LPS28_FIFO_DATA_OUT_PRESS_XL, 3, LSBFIRST);
263265
int32_t raw_pressure = fifo_pressure_out.read();
264266

265267
// Get full-scale mode using the getter

Adafruit_LPS28.h

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,97 @@
11
#ifndef ADAFRUIT_LPS28_H
22
#define ADAFRUIT_LPS28_H
33

4-
#include <Arduino.h>
5-
#include <Adafruit_I2CDevice.h>
64
#include <Adafruit_BusIO_Register.h>
5+
#include <Adafruit_I2CDevice.h>
6+
#include <Arduino.h>
77

88
// I2C Address and Register Definitions
99
#define LPS28_DEFAULT_ADDRESS (0x5C) ///< Default I2C address
1010
#define LPS28_WHOAMI_REG 0x0F ///< WHO_AM_I register
1111
#define LPS28_WHOAMI_EXPECTED 0xB4 ///< Expected WHO_AM_I value
1212

13-
#define LPS28_THS_P 0x0C ///< Threshold Pressure (2 bytes)
14-
#define LPS28_CTRL_REG1 0x10 ///< Control Register 1 (ODR and AVG)
15-
#define LPS28_CTRL_REG2 0x11 ///< Control Register 2
16-
#define LPS28_CTRL_REG3 0x12 ///< Control Register 3 (Interrupt config)
17-
#define LPS28_CTRL_REG4 0x13 ///< Control Register 4
18-
#define LPS28_INTERRUPT_CFG 0x0B ///< Interrupt Configuration Register
19-
#define LPS28_IF_CTRL 0x0E ///< Interface Control Register
20-
#define LPS28_FIFO_CTRL 0x14 ///< FIFO Control Register
21-
#define LPS28_FIFO_WTM 0x15 ///< FIFO Watermark Register
22-
#define LPS28_REF_P 0x16 ///< Reference Pressure Register (2 bytes)
23-
#define LPS28_RPDS 0x18 ///< RPDS Register (Pressure Offset, 2 bytes)
24-
#define LPS28_INT_SOURCE 0x24 ///< INT_SOURCE Register
25-
#define LPS28_FIFO_STATUS1 0x25 ///< FIFO_STATUS1 Register
26-
#define LPS28_FIFO_STATUS2 0x26 ///< FIFO_STATUS2 Register
27-
#define LPS28_STATUS 0x27 ///< STATUS Register
28-
#define LPS28_PRESS_OUT 0x28 ///< PRESS_OUT Register (3 bytes)
29-
#define LPS28_TEMP_OUT 0x2B ///< TEMP_OUT Register (2 bytes)
30-
#define LPS28_FIFO_DATA_OUT_PRESS_XL 0x78 ///< FIFO_DATA_OUT_PRESS_XL Register (3 bytes)
31-
32-
13+
#define LPS28_THS_P 0x0C ///< Threshold Pressure (2 bytes)
14+
#define LPS28_CTRL_REG1 0x10 ///< Control Register 1 (ODR and AVG)
15+
#define LPS28_CTRL_REG2 0x11 ///< Control Register 2
16+
#define LPS28_CTRL_REG3 0x12 ///< Control Register 3 (Interrupt config)
17+
#define LPS28_CTRL_REG4 0x13 ///< Control Register 4
18+
#define LPS28_INTERRUPT_CFG 0x0B ///< Interrupt Configuration Register
19+
#define LPS28_IF_CTRL 0x0E ///< Interface Control Register
20+
#define LPS28_FIFO_CTRL 0x14 ///< FIFO Control Register
21+
#define LPS28_FIFO_WTM 0x15 ///< FIFO Watermark Register
22+
#define LPS28_REF_P 0x16 ///< Reference Pressure Register (2 bytes)
23+
#define LPS28_RPDS 0x18 ///< RPDS Register (Pressure Offset, 2 bytes)
24+
#define LPS28_INT_SOURCE 0x24 ///< INT_SOURCE Register
25+
#define LPS28_FIFO_STATUS1 0x25 ///< FIFO_STATUS1 Register
26+
#define LPS28_FIFO_STATUS2 0x26 ///< FIFO_STATUS2 Register
27+
#define LPS28_STATUS 0x27 ///< STATUS Register
28+
#define LPS28_PRESS_OUT 0x28 ///< PRESS_OUT Register (3 bytes)
29+
#define LPS28_TEMP_OUT 0x2B ///< TEMP_OUT Register (2 bytes)
30+
#define LPS28_FIFO_DATA_OUT_PRESS_XL \
31+
0x78 ///< FIFO_DATA_OUT_PRESS_XL Register (3 bytes)
3332

3433
// STATUS flags
35-
#define LPS28_STATUS_TEMP_OVERRUN 0x20 ///< Temperature data overrun (bit 5)
34+
#define LPS28_STATUS_TEMP_OVERRUN 0x20 ///< Temperature data overrun (bit 5)
3635
#define LPS28_STATUS_PRESS_OVERRUN 0x10 ///< Pressure data overrun (bit 4)
37-
#define LPS28_STATUS_TEMP_READY 0x02 ///< Temperature data available (bit 1)
38-
#define LPS28_STATUS_PRESS_READY 0x01 ///< Pressure data available (bit 0)
36+
#define LPS28_STATUS_TEMP_READY 0x02 ///< Temperature data available (bit 1)
37+
#define LPS28_STATUS_PRESS_READY 0x01 ///< Pressure data available (bit 0)
3938

4039
// FIFO_STATUS2 flags
41-
#define LPS28_FIFO_STATUS_WTM_IA 0x80 ///< FIFO Watermark interrupt active (bit 7)
42-
#define LPS28_FIFO_STATUS_OVR_IA 0x40 ///< FIFO Overrun interrupt active (bit 6)
40+
#define LPS28_FIFO_STATUS_WTM_IA \
41+
0x80 ///< FIFO Watermark interrupt active (bit 7)
42+
#define LPS28_FIFO_STATUS_OVR_IA 0x40 ///< FIFO Overrun interrupt active (bit 6)
4343
#define LPS28_FIFO_STATUS_FULL_IA 0x20 ///< FIFO Full interrupt active (bit 5)
4444

4545
// INT_SOURCE flags
46-
#define LPS28_INT_SOURCE_IA 0x20 ///< Interrupt Active flag (bit 5)
47-
#define LPS28_INT_SOURCE_PL 0x10 ///< Low pressure event flag (bit 4)
48-
#define LPS28_INT_SOURCE_PH 0x08 ///< High pressure event flag (bit 3)
49-
#define LPS28_INT_SOURCE_BOOT_ON 0x80 ///< Boot status flag (bit 7)
50-
46+
#define LPS28_INT_SOURCE_IA 0x20 ///< Interrupt Active flag (bit 5)
47+
#define LPS28_INT_SOURCE_PL 0x10 ///< Low pressure event flag (bit 4)
48+
#define LPS28_INT_SOURCE_PH 0x08 ///< High pressure event flag (bit 3)
49+
#define LPS28_INT_SOURCE_BOOT_ON 0x80 ///< Boot status flag (bit 7)
5150

5251
// Output Data Rate (ODR) configuration (Table 19)
5352
typedef enum {
5453
LPS28_ODR_ONESHOT = 0b0000, ///< One-shot mode
55-
LPS28_ODR_1_HZ = 0b0001, ///< 1 Hz
56-
LPS28_ODR_4_HZ = 0b0010, ///< 4 Hz
57-
LPS28_ODR_10_HZ = 0b0011, ///< 10 Hz
58-
LPS28_ODR_25_HZ = 0b0100, ///< 25 Hz
59-
LPS28_ODR_50_HZ = 0b0101, ///< 50 Hz
60-
LPS28_ODR_75_HZ = 0b0110, ///< 75 Hz
61-
LPS28_ODR_100_HZ = 0b0111, ///< 100 Hz
62-
LPS28_ODR_200_HZ = 0b1000 ///< 200 Hz
54+
LPS28_ODR_1_HZ = 0b0001, ///< 1 Hz
55+
LPS28_ODR_4_HZ = 0b0010, ///< 4 Hz
56+
LPS28_ODR_10_HZ = 0b0011, ///< 10 Hz
57+
LPS28_ODR_25_HZ = 0b0100, ///< 25 Hz
58+
LPS28_ODR_50_HZ = 0b0101, ///< 50 Hz
59+
LPS28_ODR_75_HZ = 0b0110, ///< 75 Hz
60+
LPS28_ODR_100_HZ = 0b0111, ///< 100 Hz
61+
LPS28_ODR_200_HZ = 0b1000 ///< 200 Hz
6362
} lps28_odr_t;
6463

6564
// Averaging (AVG) selection (Table 20)
6665
typedef enum {
67-
LPS28_AVG_4 = 0b000, ///< 4 samples
68-
LPS28_AVG_8 = 0b001, ///< 8 samples
69-
LPS28_AVG_16 = 0b010, ///< 16 samples
70-
LPS28_AVG_32 = 0b011, ///< 32 samples
71-
LPS28_AVG_64 = 0b100, ///< 64 samples
66+
LPS28_AVG_4 = 0b000, ///< 4 samples
67+
LPS28_AVG_8 = 0b001, ///< 8 samples
68+
LPS28_AVG_16 = 0b010, ///< 16 samples
69+
LPS28_AVG_32 = 0b011, ///< 32 samples
70+
LPS28_AVG_64 = 0b100, ///< 64 samples
7271
LPS28_AVG_128 = 0b101, ///< 128 samples
7372
LPS28_AVG_512 = 0b111 ///< 512 samples
7473
} lps28_avg_t;
7574

76-
7775
// FIFO Mode Selection based on TRIG_MODE and F_MODE bits
7876
typedef enum {
79-
LPS28_FIFO_BYPASS = 0b00, ///< Bypass mode (F_MODE[1:0] = 00)
80-
LPS28_FIFO_FIFO = 0b01, ///< FIFO mode (TRIG = 0, F_MODE[1:0] = 01)
81-
LPS28_FIFO_CONTINUOUS = 0b10, ///< Continuous mode (TRIG = 0, F_MODE[1:0] = 1x)
82-
LPS28_FIFO_BYPASS_TO_FIFO = 0b101, ///< Bypass-to-FIFO mode (TRIG = 1, F_MODE[1:0] = 01)
83-
LPS28_FIFO_BYPASS_TO_CONTINUOUS = 0b110, ///< Bypass-to-Continuous mode (TRIG = 1, F_MODE[1:0] = 10)
84-
LPS28_FIFO_CONTINUOUS_TO_FIFO = 0b111 ///< Continuous-to-FIFO mode (TRIG = 1, F_MODE[1:0] = 11)
77+
LPS28_FIFO_BYPASS = 0b00, ///< Bypass mode (F_MODE[1:0] = 00)
78+
LPS28_FIFO_FIFO = 0b01, ///< FIFO mode (TRIG = 0, F_MODE[1:0] = 01)
79+
LPS28_FIFO_CONTINUOUS =
80+
0b10, ///< Continuous mode (TRIG = 0, F_MODE[1:0] = 1x)
81+
LPS28_FIFO_BYPASS_TO_FIFO =
82+
0b101, ///< Bypass-to-FIFO mode (TRIG = 1, F_MODE[1:0] = 01)
83+
LPS28_FIFO_BYPASS_TO_CONTINUOUS =
84+
0b110, ///< Bypass-to-Continuous mode (TRIG = 1, F_MODE[1:0] = 10)
85+
LPS28_FIFO_CONTINUOUS_TO_FIFO =
86+
0b111 ///< Continuous-to-FIFO mode (TRIG = 1, F_MODE[1:0] = 11)
8587
} lps28_fifo_mode_t;
8688

87-
88-
8989
class Adafruit_LPS28 {
9090
public:
9191
Adafruit_LPS28();
9292

93-
bool begin(TwoWire *theWire = &Wire, uint8_t i2c_addr = LPS28_DEFAULT_ADDRESS);
93+
bool begin(TwoWire *theWire = &Wire,
94+
uint8_t i2c_addr = LPS28_DEFAULT_ADDRESS);
9495

9596
// Threshold Pressure (THS_P) functions
9697
bool setThresholdPressure(uint16_t threshold);
@@ -139,7 +140,7 @@ class Adafruit_LPS28 {
139140

140141
// FIFO
141142
bool setFIFOWatermark(uint8_t wtm);
142-
uint8_t getFIFOWatermark();
143+
uint8_t getFIFOWatermark();
143144
uint8_t getFIFOunreadSamples();
144145
uint8_t getFIFOstatus();
145146
bool setFIFOmode(bool stop_on_watermark, lps28_fifo_mode_t mode);

0 commit comments

Comments
 (0)