1
- /* *
2
- * @file Adafruit_LPS28.cpp
3
- * @brief Driver for the LPS28 Pressure Sensor
4
- * @author Adafruit Industries
5
- * @copyright BSD License
1
+ // For Adafruit_LPS28.cpp:
2
+ /* !
3
+ * @file Adafruit_LPS28.cpp
4
+ *
5
+ * @mainpage Adafruit LPS28 Pressure & Temperature Sensor library
6
+ *
7
+ * @section intro_sec Introduction
8
+ *
9
+ * This is a library for the LPS28 Pressure & Temperature Sensor
10
+ *
11
+ * Designed specifically to work with the Adafruit LPS28 Breakout
12
+ * ----> http://www.adafruit.com/products/6067
13
+ *
14
+ * These sensors use I2C to communicate, 2 pins are required to interface.
15
+ *
16
+ * Adafruit invests time and resources providing this open source code,
17
+ * please support Adafruit and open-source hardware by purchasing products
18
+ * from Adafruit!
19
+ *
20
+ * @section author Author
21
+ *
22
+ * Written by Limor Fried/Ladyada for Adafruit Industries.
23
+ *
24
+ * @section license License
25
+ *
26
+ * MIT license, all text above must be included in any redistribution
6
27
*/
7
28
8
29
#include " Adafruit_LPS28.h"
@@ -15,7 +36,7 @@ Adafruit_LPS28::Adafruit_LPS28() {}
15
36
/* *
16
37
* @brief Initializes the sensor with given parameters, tried reading
17
38
* and veriying the WHOAMI register
18
- *
39
+ *
19
40
* @param theWire The Wire object to be used for I2C communication
20
41
* @param i2c_addr The I2C address of the sensor
21
42
* @return true If sensor initialization was successful
@@ -33,7 +54,7 @@ bool Adafruit_LPS28::begin(TwoWire *theWire, uint8_t i2c_addr) {
33
54
34
55
/* *
35
56
* @brief Sets the pressure threshold for interrupt generation
36
- *
57
+ *
37
58
* @param threshold The pressure threshold value to set
38
59
* @return true If threshold was set successfully
39
60
* @return false If threshold setting failed
@@ -45,7 +66,7 @@ bool Adafruit_LPS28::setThresholdPressure(uint16_t threshold) {
45
66
46
67
/* *
47
68
* @brief Gets the current pressure threshold value for the IRQ
48
- *
69
+ *
49
70
* @return uint16_t The current pressure threshold value
50
71
*/
51
72
uint16_t Adafruit_LPS28::getThresholdPressure () {
@@ -55,7 +76,7 @@ uint16_t Adafruit_LPS28::getThresholdPressure() {
55
76
56
77
/* *
57
78
* @brief Sets the data output rate of the sensor (ODR)
58
- *
79
+ *
59
80
* @param odr The desired output data rate from lps28_odr_t enum
60
81
* @return true If data rate was set successfully
61
82
* @return false If data rate setting failed
@@ -68,7 +89,7 @@ bool Adafruit_LPS28::setDataRate(lps28_odr_t odr) {
68
89
69
90
/* *
70
91
* @brief Gets the current data output rate setting (ODR)
71
- *
92
+ *
72
93
* @return lps28_odr_t The current output data rate setting
73
94
*/
74
95
lps28_odr_t Adafruit_LPS28::getDataRate () {
@@ -77,10 +98,9 @@ lps28_odr_t Adafruit_LPS28::getDataRate() {
77
98
return (lps28_odr_t )odr_bits.read ();
78
99
}
79
100
80
-
81
101
/* *
82
102
* @brief Sets the number of pressure and temperature samples to average
83
- *
103
+ *
84
104
* @param avg The averaging setting from lps28_avg_t enum
85
105
* @return true If averaging setting was set successfully
86
106
* @return false If averaging setting failed
@@ -93,7 +113,7 @@ bool Adafruit_LPS28::setAveraging(lps28_avg_t avg) {
93
113
94
114
/* *
95
115
* @brief Gets the current averaging setting
96
- *
116
+ *
97
117
* @return lps28_avg_t The current averaging setting
98
118
*/
99
119
lps28_avg_t Adafruit_LPS28::getAveraging () {
@@ -104,7 +124,7 @@ lps28_avg_t Adafruit_LPS28::getAveraging() {
104
124
105
125
/* *
106
126
* @brief Reboots the memory content of the sensor
107
- *
127
+ *
108
128
* @return true If memory reboot was successful
109
129
* @return false If memory reboot failed
110
130
*/
@@ -116,8 +136,9 @@ bool Adafruit_LPS28::rebootMemory() {
116
136
117
137
/* *
118
138
* @brief Sets the full scale mode of the sensor
119
- *
120
- * @param mode true for FS_MODE=1 (1/2048 hPa/LSB), false for FS_MODE=0 (1/4096 hPa/LSB)
139
+ *
140
+ * @param mode true for FS_MODE=1 (1/2048 hPa/LSB), false for FS_MODE=0 (1/4096
141
+ * hPa/LSB)
121
142
* @return true If full scale mode was set successfully
122
143
* @return false If full scale mode setting failed
123
144
*/
@@ -129,7 +150,7 @@ bool Adafruit_LPS28::setFullScaleMode(bool mode) {
129
150
130
151
/* *
131
152
* @brief Gets the current full scale mode setting
132
- *
153
+ *
133
154
* @return true FS_MODE=1 (1/2048 hPa/LSB)
134
155
* @return false FS_MODE=0 (1/4096 hPa/LSB)
135
156
*/
@@ -141,7 +162,7 @@ bool Adafruit_LPS28::getFullScaleMode() {
141
162
142
163
/* *
143
164
* @brief Enables or disables the low-pass filter at ODR/9
144
- *
165
+ *
145
166
* @param enable true to enable the low-pass filter, false to disable
146
167
* @return true If setting was applied successfully
147
168
* @return false If setting failed
@@ -152,10 +173,9 @@ bool Adafruit_LPS28::setLowPassODR9(bool enable) {
152
173
return lpfp_cfg_bit.write (enable);
153
174
}
154
175
155
-
156
176
/* *
157
177
* @brief Performs a software reset of the sensor
158
- *
178
+ *
159
179
* @return true If reset was successful
160
180
* @return false If reset failed
161
181
*/
@@ -167,7 +187,7 @@ bool Adafruit_LPS28::reset() {
167
187
168
188
/* *
169
189
* @brief Triggers a one-shot measurement
170
- *
190
+ *
171
191
* @return true If one-shot measurement was triggered successfully
172
192
* @return false If trigger failed
173
193
*/
@@ -179,7 +199,7 @@ bool Adafruit_LPS28::triggerOneShot() {
179
199
180
200
/* *
181
201
* @brief Configures the interrupt pin settings
182
- *
202
+ *
183
203
* @param polarity true for active-high, false for active-low
184
204
* @param openDrain true for open-drain output, false for push-pull
185
205
* @return true If interrupt pin configuration was successful
@@ -194,7 +214,7 @@ bool Adafruit_LPS28::setInterruptPin(bool polarity, bool openDrain) {
194
214
195
215
/* *
196
216
* @brief Enables or disables the SDA line internal pull-up resistor
197
- *
217
+ *
198
218
* @param enable true to enable pull-up, false to disable
199
219
* @return true If pull-up setting was changed successfully
200
220
* @return false If setting change failed
@@ -207,7 +227,7 @@ bool Adafruit_LPS28::setSDAPullup(bool enable) {
207
227
208
228
/* *
209
229
* @brief Enables or disables the INT pin internal pull-down resistor
210
- *
230
+ *
211
231
* @param enable true to enable pull-down, false to disable
212
232
* @return true If pull-down setting was changed successfully
213
233
* @return false If setting change failed
@@ -220,7 +240,7 @@ bool Adafruit_LPS28::setINTPulldown(bool enable) {
220
240
221
241
/* *
222
242
* @brief Sets up automatic reference pressure mode
223
- *
243
+ *
224
244
* @param enable true to enable auto reference pressure, false to disable
225
245
* @return true If auto reference pressure setting was changed successfully
226
246
* @return false If setting change failed
@@ -231,10 +251,9 @@ bool Adafruit_LPS28::setAutoReferencePressure(bool enable) {
231
251
return autozero_bit.write (enable);
232
252
}
233
253
234
-
235
254
/* *
236
255
* @brief Gets the current auto reference pressure setting
237
- *
256
+ *
238
257
* @return true If auto reference pressure is enabled
239
258
* @return false If auto reference pressure is disabled
240
259
*/
@@ -246,7 +265,7 @@ bool Adafruit_LPS28::getAutoReferencePressure() {
246
265
247
266
/* *
248
267
* @brief Resets the auto reference pressure setting
249
- *
268
+ *
250
269
* @return true If reset was successful
251
270
* @return false If reset failed
252
271
*/
@@ -258,7 +277,7 @@ bool Adafruit_LPS28::resetAutoReferencePressure() {
258
277
259
278
/* *
260
279
* @brief Enables or disables the auto-zero function
261
- *
280
+ *
262
281
* @param enable true to enable auto-zero, false to disable
263
282
* @return true If auto-zero setting was changed successfully
264
283
* @return false If setting change failed
@@ -271,7 +290,7 @@ bool Adafruit_LPS28::setAutoZero(bool enable) {
271
290
272
291
/* *
273
292
* @brief Gets the current auto-zero setting
274
- *
293
+ *
275
294
* @return true If auto-zero is enabled
276
295
* @return false If auto-zero is disabled
277
296
*/
@@ -283,7 +302,7 @@ bool Adafruit_LPS28::getAutoZero() {
283
302
284
303
/* *
285
304
* @brief Resets the auto-zero function
286
- *
305
+ *
287
306
* @return true If reset was successful
288
307
* @return false If reset failed
289
308
*/
@@ -295,7 +314,7 @@ bool Adafruit_LPS28::resetAutoZero() {
295
314
296
315
/* *
297
316
* @brief Configures pressure interrupt settings
298
- *
317
+ *
299
318
* @param low Enable low pressure interrupt
300
319
* @param high Enable high pressure interrupt
301
320
* @param latching Enable latching mode for interrupts
@@ -312,7 +331,7 @@ bool Adafruit_LPS28::setPressureInterrupt(bool low, bool high, bool latching) {
312
331
313
332
/* *
314
333
* @brief Configures which conditions trigger the interrupt pin
315
- *
334
+ *
316
335
* @param drdy Enable data ready interrupt
317
336
* @param drdy_pulse Enable pulsed mode for data ready interrupt
318
337
* @param int_enable Enable pressure threshold interrupt
@@ -349,10 +368,9 @@ bool Adafruit_LPS28::setIntPinOutput(bool drdy, bool drdy_pulse,
349
368
fifo_watermark_ok && fifo_overrun_ok;
350
369
}
351
370
352
-
353
371
/* *
354
372
* @brief Configures the FIFO operation mode
355
- *
373
+ *
356
374
* @param stop_on_watermark Stop collecting data when watermark is reached
357
375
* @param mode FIFO operation mode from lps28_fifo_mode_t enum
358
376
* @return true If FIFO configuration was successful
@@ -375,7 +393,7 @@ bool Adafruit_LPS28::setFIFOmode(bool stop_on_watermark,
375
393
376
394
/* *
377
395
* @brief Sets the FIFO watermark level
378
- *
396
+ *
379
397
* @param wtm Watermark level (0-127)
380
398
* @return true If watermark was set successfully
381
399
* @return false If setting failed
@@ -387,7 +405,7 @@ bool Adafruit_LPS28::setFIFOWatermark(uint8_t wtm) {
387
405
388
406
/* *
389
407
* @brief Gets the current FIFO watermark level
390
- *
408
+ *
391
409
* @return uint8_t Current watermark level (0-127)
392
410
*/
393
411
uint8_t Adafruit_LPS28::getFIFOWatermark () {
@@ -397,7 +415,7 @@ uint8_t Adafruit_LPS28::getFIFOWatermark() {
397
415
398
416
/* *
399
417
* @brief Gets the current reference pressure value
400
- *
418
+ *
401
419
* @return int16_t Current reference pressure value
402
420
*/
403
421
int16_t Adafruit_LPS28::getReferencePressure () {
@@ -407,7 +425,7 @@ int16_t Adafruit_LPS28::getReferencePressure() {
407
425
408
426
/* *
409
427
* @brief Sets the pressure offset value
410
- *
428
+ *
411
429
* @param offset Pressure offset value to set
412
430
* @return true If offset was set successfully
413
431
* @return false If setting failed
@@ -419,7 +437,7 @@ bool Adafruit_LPS28::setPressureOffset(int16_t offset) {
419
437
420
438
/* *
421
439
* @brief Gets the current pressure offset value
422
- *
440
+ *
423
441
* @return int16_t Current pressure offset value
424
442
*/
425
443
int16_t Adafruit_LPS28::getPressureOffset () {
@@ -429,7 +447,7 @@ int16_t Adafruit_LPS28::getPressureOffset() {
429
447
430
448
/* *
431
449
* @brief Gets the source of the last interrupt
432
- *
450
+ *
433
451
* @return uint8_t Interrupt source register value
434
452
* Bit 7: AUTOZERO
435
453
* Bit 6: RESET_ARP
@@ -447,7 +465,7 @@ uint8_t Adafruit_LPS28::getIntSource() {
447
465
448
466
/* *
449
467
* @brief Gets the number of unread samples in the FIFO
450
- *
468
+ *
451
469
* @return uint8_t Number of unread FIFO samples
452
470
*/
453
471
uint8_t Adafruit_LPS28::getFIFOunreadSamples () {
@@ -457,7 +475,7 @@ uint8_t Adafruit_LPS28::getFIFOunreadSamples() {
457
475
458
476
/* *
459
477
* @brief Gets the current sensor status
460
- *
478
+ *
461
479
* @return uint8_t Status register value
462
480
* Bit 3: P_OR (Pressure data overrun)
463
481
* Bit 2: T_OR (Temperature data overrun)
@@ -471,7 +489,7 @@ uint8_t Adafruit_LPS28::getStatus() {
471
489
472
490
/* *
473
491
* @brief Gets the current pressure reading
474
- *
492
+ *
475
493
* @return float Pressure reading in hPa (hectopascals)
476
494
* @note Resolution depends on FS_MODE:
477
495
* - FS_MODE = 0: 1 LSB = 1/4096 hPa
@@ -498,7 +516,7 @@ float Adafruit_LPS28::getPressure() {
498
516
499
517
/* *
500
518
* @brief Gets the current temperature reading
501
- *
519
+ *
502
520
* @return float Temperature in degrees Celsius
503
521
* @note Resolution is 0.01°C per LSB
504
522
*/
@@ -515,7 +533,7 @@ float Adafruit_LPS28::getTemperature() {
515
533
516
534
/* *
517
535
* @brief Gets the current FIFO status
518
- *
536
+ *
519
537
* @return uint8_t FIFO status register value
520
538
* Bit 7-6: FIFO_FULL_IA (FIFO full interrupt active)
521
539
* Bit 5: FIFO_OVR_IA (FIFO overrun interrupt active)
@@ -529,7 +547,7 @@ uint8_t Adafruit_LPS28::getFIFOstatus() {
529
547
530
548
/* *
531
549
* @brief Reads the next pressure value from the FIFO buffer
532
- *
550
+ *
533
551
* @return float Pressure reading from FIFO in hPa (hectopascals)
534
552
* @note Resolution depends on FS_MODE:
535
553
* - FS_MODE = 0: 1 LSB = 1/4096 hPa
0 commit comments