-
Notifications
You must be signed in to change notification settings - Fork 0
/
lps28dfw_reg.h
758 lines (669 loc) · 21.5 KB
/
lps28dfw_reg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
/*
******************************************************************************
* @file lps28dfw_reg.h
* @author Sensors Software Solution Team
* @brief This file contains all the functions prototypes for the
* lps28dfw_reg.c driver.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2024 STMicroelectronics.
* All rights reserved.</center></h2>
*
* 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef LPS28DFW_REGS_H
#define LPS28DFW_REGS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stddef.h>
#include <math.h>
/** @addtogroup LPS28DFW
* @{
*
*/
/** @defgroup Endianness definitions
* @{
*
*/
#ifndef DRV_BYTE_ORDER
#ifndef __BYTE_ORDER__
#define DRV_LITTLE_ENDIAN 1234
#define DRV_BIG_ENDIAN 4321
/** if _BYTE_ORDER is not defined, choose the endianness of your architecture
* by uncommenting the define which fits your platform endianness
*/
//#define DRV_BYTE_ORDER DRV_BIG_ENDIAN
#define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN
#else /* defined __BYTE_ORDER__ */
#define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__
#define DRV_BYTE_ORDER __BYTE_ORDER__
#endif /* __BYTE_ORDER__*/
#endif /* DRV_BYTE_ORDER */
/**
* @}
*
*/
/** @defgroup STMicroelectronics sensors common types
* @{
*
*/
#ifndef MEMS_SHARED_TYPES
#define MEMS_SHARED_TYPES
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t bit0 : 1;
uint8_t bit1 : 1;
uint8_t bit2 : 1;
uint8_t bit3 : 1;
uint8_t bit4 : 1;
uint8_t bit5 : 1;
uint8_t bit6 : 1;
uint8_t bit7 : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t bit7 : 1;
uint8_t bit6 : 1;
uint8_t bit5 : 1;
uint8_t bit4 : 1;
uint8_t bit3 : 1;
uint8_t bit2 : 1;
uint8_t bit1 : 1;
uint8_t bit0 : 1;
#endif /* DRV_BYTE_ORDER */
} bitwise_t;
#define PROPERTY_DISABLE (0U)
#define PROPERTY_ENABLE (1U)
/** @addtogroup Interfaces_Functions
* @brief This section provide a set of functions used to read and
* write a generic register of the device.
* MANDATORY: return 0 -> no Error.
* @{
*
*/
typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, const uint8_t *, uint16_t);
typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t);
typedef void (*stmdev_mdelay_ptr)(uint32_t millisec);
typedef struct
{
/** Component mandatory fields **/
stmdev_write_ptr write_reg;
stmdev_read_ptr read_reg;
/** Component optional fields **/
stmdev_mdelay_ptr mdelay;
/** Customizable optional pointer **/
void *handle;
} stmdev_ctx_t;
/**
* @}
*
*/
#endif /* MEMS_SHARED_TYPES */
#ifndef MEMS_UCF_SHARED_TYPES
#define MEMS_UCF_SHARED_TYPES
/** @defgroup Generic address-data structure definition
* @brief This structure is useful to load a predefined configuration
* of a sensor.
* You can create a sensor configuration by your own or using
* Unico / Unicleo tools available on STMicroelectronics
* web site.
*
* @{
*
*/
typedef struct
{
uint8_t address;
uint8_t data;
} ucf_line_t;
/**
* @}
*
*/
#endif /* MEMS_UCF_SHARED_TYPES */
/**
* @}
*
*/
/** @defgroup LPS28DFW_Infos
* @{
*
*/
/** I2C Device Address 8 bit format if SA0=0 -> 0xB9 if SA0=1 -> 0xBB **/
#define LPS28DFW_I2C_ADD_L 0xB9U
#define LPS28DFW_I2C_ADD_H 0xBBU
/** Device Identification (Who am I) **/
#define LPS28DFW_ID 0xB4U
/**
* @}
*
*/
#define LPS28DFW_INTERRUPT_CFG 0x0BU
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t phe : 1;
uint8_t ple : 1;
uint8_t lir : 1;
uint8_t not_used_01 : 1;
uint8_t reset_az : 1;
uint8_t autozero : 1;
uint8_t reset_arp : 1;
uint8_t autorefp : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t autorefp : 1;
uint8_t reset_arp : 1;
uint8_t autozero : 1;
uint8_t reset_az : 1;
uint8_t not_used_01 : 1;
uint8_t lir : 1;
uint8_t ple : 1;
uint8_t phe : 1;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_interrupt_cfg_t;
#define LPS28DFW_THS_P_L 0x0CU
typedef struct
{
uint8_t ths : 8;
} lps28dfw_ths_p_l_t;
#define LPS28DFW_THS_P_H 0x0DU
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t ths : 7;
uint8_t not_used_01 : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_01 : 1;
uint8_t ths : 7;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_ths_p_h_t;
#define LPS28DFW_IF_CTRL 0x0EU
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t not_used_01 : 2;
uint8_t int_pd_dis : 1;
uint8_t not_used_02 : 1;
uint8_t sda_pu_en : 1;
uint8_t not_used_03 : 2;
uint8_t int_en_i3c : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t int_en_i3c : 1;
uint8_t not_used_03 : 2;
uint8_t sda_pu_en : 1;
uint8_t not_used_02 : 1;
uint8_t int_pd_dis : 1;
uint8_t not_used_01 : 2;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_if_ctrl_t;
#define LPS28DFW_WHO_AM_I 0x0FU
#define LPS28DFW_CTRL_REG1 0x10U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t avg : 3;
uint8_t odr : 4;
uint8_t not_used_01 : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_01 : 1;
uint8_t odr : 4;
uint8_t avg : 3;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_ctrl_reg1_t;
#define LPS28DFW_CTRL_REG2 0x11U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t oneshot : 1;
uint8_t not_used_01 : 1;
uint8_t swreset : 1;
uint8_t bdu : 1;
uint8_t en_lpfp : 1;
uint8_t lfpf_cfg : 1;
uint8_t fs_mode : 1;
uint8_t boot : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t boot : 1;
uint8_t fs_mode : 1;
uint8_t lfpf_cfg : 1;
uint8_t en_lpfp : 1;
uint8_t bdu : 1;
uint8_t swreset : 1;
uint8_t not_used_01 : 1;
uint8_t oneshot : 1;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_ctrl_reg2_t;
#define LPS28DFW_CTRL_REG3 0x12U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t if_add_inc : 1;
uint8_t pp_od : 1;
uint8_t not_used_02 : 1;
uint8_t int_h_l : 1;
uint8_t not_used_01 : 4;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_01 : 4;
uint8_t int_h_l : 1;
uint8_t not_used_02 : 1;
uint8_t pp_od : 1;
uint8_t if_add_inc : 1;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_ctrl_reg3_t;
#define LPS28DFW_CTRL_REG4 0x13U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t int_f_ovr : 1;
uint8_t int_f_wtm : 1;
uint8_t int_f_full : 1;
uint8_t not_used_02 : 1;
uint8_t int_en : 1;
uint8_t drdy : 1;
uint8_t drdy_pls : 1;
uint8_t not_used_01 : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_01 : 1;
uint8_t drdy_pls : 1;
uint8_t drdy : 1;
uint8_t int_en : 1;
uint8_t not_used_02 : 1;
uint8_t int_f_full : 1;
uint8_t int_f_wtm : 1;
uint8_t int_f_ovr : 1;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_ctrl_reg4_t;
#define LPS28DFW_FIFO_CTRL 0x14U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t f_mode : 2;
uint8_t trig_modes : 1;
uint8_t stop_on_wtm : 1;
uint8_t not_used_01 : 4;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_01 : 4;
uint8_t stop_on_wtm : 1;
uint8_t trig_modes : 1;
uint8_t f_mode : 2;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_fifo_ctrl_t;
#define LPS28DFW_FIFO_WTM 0x15U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t wtm : 7;
uint8_t not_used_01 : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_01 : 1;
uint8_t wtm : 7;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_fifo_wtm_t;
#define LPS28DFW_REF_P_L 0x16U
typedef struct
{
uint8_t refp : 8;
} lps28dfw_ref_p_l_t;
#define LPS28DFW_REF_P_H 0x17U
typedef struct
{
uint8_t refp : 8;
} lps28dfw_ref_p_h_t;
#define LPS28DFW_I3C_IF_CTRL 0x19U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t I3C_Bus_Avb_Sel : 2;
uint8_t not_used_02 : 3;
uint8_t asf_on : 1;
uint8_t not_used_01 : 2;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_01 : 2;
uint8_t asf_on : 1;
uint8_t not_used_02 : 3;
uint8_t I3C_Bus_Avb_Sel : 2;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_i3c_if_ctrl_t;
#define LPS28DFW_RPDS_L 0x1AU
#define LPS28DFW_RPDS_H 0x1BU
#define LPS28DFW_INT_SOURCE 0x24U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t ph : 1;
uint8_t pl : 1;
uint8_t ia : 1;
uint8_t not_used_01 : 4;
uint8_t boot_on : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t boot_on : 1;
uint8_t not_used_01 : 4;
uint8_t ia : 1;
uint8_t pl : 1;
uint8_t ph : 1;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_int_source_t;
#define LPS28DFW_FIFO_STATUS1 0x25U
typedef struct
{
uint8_t fss : 8;
} lps28dfw_fifo_status1_t;
#define LPS28DFW_FIFO_STATUS2 0x26U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t not_used_01 : 5;
uint8_t fifo_full_ia : 1;
uint8_t fifo_ovr_ia : 1;
uint8_t fifo_wtm_ia : 1;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t fifo_wtm_ia : 1;
uint8_t fifo_ovr_ia : 1;
uint8_t fifo_full_ia : 1;
uint8_t not_used_01 : 5;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_fifo_status2_t;
#define LPS28DFW_STATUS 0x27U
typedef struct
{
#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN
uint8_t p_da : 1;
uint8_t t_da : 1;
uint8_t not_used_01 : 2;
uint8_t p_or : 1;
uint8_t t_or : 1;
uint8_t not_used_02 : 2;
#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN
uint8_t not_used_02 : 2;
uint8_t t_or : 1;
uint8_t p_or : 1;
uint8_t not_used_01 : 2;
uint8_t t_da : 1;
uint8_t p_da : 1;
#endif /* DRV_BYTE_ORDER */
} lps28dfw_status_t;
#define LPS28DFW_PRESS_OUT_XL 0x28U
#define LPS28DFW_PRESS_OUT_L 0x29U
#define LPS28DFW_PRESS_OUT_H 0x2AU
#define LPS28DFW_TEMP_OUT_L 0x2BU
#define LPS28DFW_TEMP_OUT_H 0x2CU
#define LPS28DFW_FIFO_DATA_OUT_PRESS_XL 0x78U
#define LPS28DFW_FIFO_DATA_OUT_PRESS_L 0x79U
#define LPS28DFW_FIFO_DATA_OUT_PRESS_H 0x7AU
/**
* @defgroup LPS28DFW_Register_Union
* @brief This union group all the registers that has a bitfield
* description.
* This union is useful but not need by the driver.
*
* REMOVING this union you are compliant with:
* MISRA-C 2012 [Rule 19.2] -> " Union are not allowed "
*
* @{
*
*/
typedef union
{
lps28dfw_interrupt_cfg_t interrupt_cfg;
lps28dfw_ths_p_l_t ths_p_l;
lps28dfw_ths_p_h_t ths_p_h;
lps28dfw_if_ctrl_t if_ctrl;
lps28dfw_ctrl_reg1_t ctrl_reg1;
lps28dfw_ctrl_reg2_t ctrl_reg2;
lps28dfw_ctrl_reg3_t ctrl_reg3;
lps28dfw_ctrl_reg4_t ctrl_reg4;
lps28dfw_fifo_ctrl_t fifo_ctrl;
lps28dfw_fifo_wtm_t fifo_wtm;
lps28dfw_ref_p_l_t ref_p_l;
lps28dfw_ref_p_h_t ref_p_h;
lps28dfw_i3c_if_ctrl_t i3c_if_ctrl;
lps28dfw_int_source_t int_source;
lps28dfw_fifo_status1_t fifo_status1;
lps28dfw_fifo_status2_t fifo_status2;
lps28dfw_status_t status;
bitwise_t bitwise;
uint8_t byte;
} lps28dfw_reg_t;
#ifndef __weak
#define __weak __attribute__((weak))
#endif /* __weak */
/*
* These are the basic platform dependent I/O routines to read
* and write device registers connected on a standard bus.
* The driver keeps offering a default implementation based on function
* pointers to read/write routines for backward compatibility.
* The __weak directive allows the final application to overwrite
* them with a custom implementation.
*/
int32_t lps28dfw_read_reg(const stmdev_ctx_t *ctx, uint8_t reg,
uint8_t *data, uint16_t len);
int32_t lps28dfw_write_reg(const stmdev_ctx_t *ctx, uint8_t reg,
uint8_t *data, uint16_t len);
extern float_t lps28dfw_from_fs1260_to_hPa(int32_t lsb);
extern float_t lps28dfw_from_fs4060_to_hPa(int32_t lsb);
extern float_t lps28dfw_from_lsb_to_celsius(int16_t lsb);
typedef struct
{
uint8_t whoami;
} lps28dfw_id_t;
int32_t lps28dfw_id_get(const stmdev_ctx_t *ctx, lps28dfw_id_t *val);
typedef enum
{
LPS28DFW_SEL_BY_HW = 0x00, /* bus mode select by HW (SPI 3W disable) */
LPS28DFW_INT_PIN_ON_I3C = 0x04, /* INT pin polarized as OUT with I3C */
} lps28dfw_interface_t;
typedef enum
{
LPS28DFW_AUTO = 0x00, /* anti-spike filters managed by protocol */
LPS28DFW_ALWAYS_ON = 0x01, /* anti-spike filters always on */
} lps28dfw_filter_t;
typedef enum
{
LPS28DFW_BUS_AVB_TIME_50us = 0x00, /* bus available time equal to 50 us */
LPS28DFW_BUS_AVB_TIME_2us = 0x01, /* bus available time equal to 2 us */
LPS28DFW_BUS_AVB_TIME_1ms = 0x02, /* bus available time equal to 1 ms */
LPS28DFW_BUS_AVB_TIME_25ms = 0x03, /* bus available time equal to 25 ms */
} lps28dfw_bus_avb_time_t;
typedef struct
{
lps28dfw_interface_t interface;
lps28dfw_filter_t filter;
lps28dfw_bus_avb_time_t bus_avb_time;
} lps28dfw_bus_mode_t;
int32_t lps28dfw_bus_mode_set(const stmdev_ctx_t *ctx, lps28dfw_bus_mode_t *val);
int32_t lps28dfw_bus_mode_get(const stmdev_ctx_t *ctx, lps28dfw_bus_mode_t *val);
typedef enum
{
LPS28DFW_DRV_RDY = 0x00, /* Initialize the device for driver usage */
LPS28DFW_BOOT = 0x01, /* Restore calib. param. ( it takes 10ms ) */
LPS28DFW_RESET = 0x02, /* Reset configuration registers */
} lps28dfw_init_t;
int32_t lps28dfw_init_set(const stmdev_ctx_t *ctx, lps28dfw_init_t val);
typedef struct
{
uint8_t sw_reset : 1; /* Restoring configuration registers. */
uint8_t boot : 1; /* Restoring calibration parameters. */
uint8_t drdy_pres : 1; /* Pressure data ready. */
uint8_t drdy_temp : 1; /* Temperature data ready. */
uint8_t ovr_pres : 1; /* Pressure data overrun. */
uint8_t ovr_temp : 1; /* Temperature data overrun. */
uint8_t end_meas : 1; /* Single measurement is finished. */
uint8_t ref_done : 1; /* Auto-Zero value is set. */
} lps28dfw_stat_t;
int32_t lps28dfw_status_get(const stmdev_ctx_t *ctx, lps28dfw_stat_t *val);
typedef struct
{
uint8_t int_push_pull : 1; /* 1 = push-pull / 0 = open-drain*/
uint8_t int_pull_down : 1; /* 1 = pull-down always disabled (0=auto) */
uint8_t sda_pull_up : 1; /* 1 = pull-up always disabled */
} lps28dfw_pin_conf_t;
int32_t lps28dfw_pin_conf_set(const stmdev_ctx_t *ctx, lps28dfw_pin_conf_t *val);
int32_t lps28dfw_pin_conf_get(const stmdev_ctx_t *ctx, lps28dfw_pin_conf_t *val);
typedef struct
{
uint8_t drdy_pres : 1; /* Pressure data ready */
uint8_t drdy_temp : 1; /* Temperature data ready */
uint8_t over_pres : 1; /* Over pressure event */
uint8_t under_pres : 1; /* Under pressure event */
uint8_t thrsld_pres : 1; /* Over/Under pressure event */
uint8_t fifo_full : 1; /* FIFO full */
uint8_t fifo_ovr : 1; /* FIFO overrun */
uint8_t fifo_th : 1; /* FIFO threshold reached */
} lps28dfw_all_sources_t;
int32_t lps28dfw_all_sources_get(const stmdev_ctx_t *ctx,
lps28dfw_all_sources_t *val);
typedef enum
{
LPS28DFW_1260hPa = 0x00,
LPS28DFW_4060hPa = 0x01,
} lps28dfw_fs_t;
typedef enum
{
LPS28DFW_ONE_SHOT = 0x00, /* Device in power down till software trigger */
LPS28DFW_1Hz = 0x01,
LPS28DFW_4Hz = 0x02,
LPS28DFW_10Hz = 0x03,
LPS28DFW_25Hz = 0x04,
LPS28DFW_50Hz = 0x05,
LPS28DFW_75Hz = 0x06,
LPS28DFW_100Hz = 0x07,
LPS28DFW_200Hz = 0x08,
} lps28dfw_odr_t;
typedef enum
{
LPS28DFW_4_AVG = 0,
LPS28DFW_8_AVG = 1,
LPS28DFW_16_AVG = 2,
LPS28DFW_32_AVG = 3,
LPS28DFW_64_AVG = 4,
LPS28DFW_128_AVG = 5,
LPS28DFW_256_AVG = 6,
LPS28DFW_512_AVG = 7,
} lps28dfw_avg_t;
typedef enum
{
LPS28DFW_LPF_DISABLE = 0,
LPS28DFW_LPF_ODR_DIV_4 = 1,
LPS28DFW_LPF_ODR_DIV_9 = 3,
} lps28dfw_lpf_t;
typedef struct
{
lps28dfw_fs_t fs;
lps28dfw_odr_t odr;
lps28dfw_avg_t avg;
lps28dfw_lpf_t lpf;
} lps28dfw_md_t;
int32_t lps28dfw_mode_set(const stmdev_ctx_t *ctx, lps28dfw_md_t *val);
int32_t lps28dfw_mode_get(const stmdev_ctx_t *ctx, lps28dfw_md_t *val);
int32_t lps28dfw_trigger_sw(const stmdev_ctx_t *ctx, lps28dfw_md_t *md);
typedef struct
{
struct
{
float_t hpa;
int32_t raw; /* 32 bit signed-left algned format left */
} pressure;
struct
{
float_t deg_c;
int16_t raw;
} heat;
} lps28dfw_data_t;
int32_t lps28dfw_data_get(const stmdev_ctx_t *ctx, lps28dfw_md_t *md,
lps28dfw_data_t *data);
int32_t lps28dfw_pressure_raw_get(const stmdev_ctx_t *ctx, uint32_t *buff);
int32_t lps28dfw_temperature_raw_get(const stmdev_ctx_t *ctx, int16_t *buff);
typedef enum
{
LPS28DFW_BYPASS = 0,
LPS28DFW_FIFO = 1,
LPS28DFW_STREAM = 2,
LPS28DFW_STREAM_TO_FIFO = 7, /* Dynamic-Stream, FIFO on Trigger */
LPS28DFW_BYPASS_TO_STREAM = 6, /* Bypass, Dynamic-Stream on Trigger */
LPS28DFW_BYPASS_TO_FIFO = 5, /* Bypass, FIFO on Trigger */
} lps28dfw_operation_t;
typedef struct
{
lps28dfw_operation_t operation;
uint8_t watermark : 7; /* (0 disable) max 128.*/
} lps28dfw_fifo_md_t;
int32_t lps28dfw_fifo_mode_set(const stmdev_ctx_t *ctx, lps28dfw_fifo_md_t *val);
int32_t lps28dfw_fifo_mode_get(const stmdev_ctx_t *ctx, lps28dfw_fifo_md_t *val);
int32_t lps28dfw_fifo_level_get(const stmdev_ctx_t *ctx, uint8_t *val);
typedef struct
{
float_t hpa;
int32_t raw;
} lps28dfw_fifo_data_t;
int32_t lps28dfw_fifo_data_get(const stmdev_ctx_t *ctx, uint8_t samp,
lps28dfw_md_t *md, lps28dfw_fifo_data_t *data);
typedef struct
{
uint8_t int_latched : 1; /* int events are: int on threshold, FIFO */
uint8_t active_low : 1; /* 1 = active low / 0 = active high */
uint8_t drdy_latched : 1; /* pulsed ~5 μs with enabled drdy_pres " */
} lps28dfw_int_mode_t;
int32_t lps28dfw_interrupt_mode_set(const stmdev_ctx_t *ctx,
lps28dfw_int_mode_t *val);
int32_t lps28dfw_interrupt_mode_get(const stmdev_ctx_t *ctx,
lps28dfw_int_mode_t *val);
typedef struct
{
uint8_t drdy_pres : 1; /* Pressure data ready */
uint8_t fifo_th : 1; /* FIFO threshold reached */
uint8_t fifo_ovr : 1; /* FIFO overrun */
uint8_t fifo_full : 1; /* FIFO full */
} lps28dfw_pin_int_route_t;
int32_t lps28dfw_pin_int_route_set(const stmdev_ctx_t *ctx,
lps28dfw_pin_int_route_t *val);
int32_t lps28dfw_pin_int_route_get(const stmdev_ctx_t *ctx,
lps28dfw_pin_int_route_t *val);
typedef struct
{
uint16_t threshold; /* Threshold in hPa * 16 (@1260hPa)
* Threshold in hPa * 8 (@4060hPa)
*/
uint8_t over_th : 1; /* Pressure data over threshold event */
uint8_t under_th : 1; /* Pressure data under threshold event */
} lps28dfw_int_th_md_t;
int32_t lps28dfw_int_on_threshold_mode_set(const stmdev_ctx_t *ctx,
lps28dfw_int_th_md_t *val);
int32_t lps28dfw_int_on_threshold_mode_get(const stmdev_ctx_t *ctx,
lps28dfw_int_th_md_t *val);
typedef enum
{
LPS28DFW_OUT_AND_INTERRUPT = 0,
LPS28DFW_ONLY_INTERRUPT = 1,
LPS28DFW_RST_REFS = 2,
} lps28dfw_apply_ref_t;
typedef struct
{
lps28dfw_apply_ref_t apply_ref;
uint8_t get_ref : 1; /* Use current pressure value as reference */
} lps28dfw_ref_md_t;
int32_t lps28dfw_reference_mode_set(const stmdev_ctx_t *ctx,
lps28dfw_ref_md_t *val);
int32_t lps28dfw_reference_mode_get(const stmdev_ctx_t *ctx,
lps28dfw_ref_md_t *val);
int32_t lps28dfw_refp_get(const stmdev_ctx_t *ctx, int16_t *val);
int32_t lps28dfw_opc_set(const stmdev_ctx_t *ctx, int16_t val);
int32_t lps28dfw_opc_get(const stmdev_ctx_t *ctx, int16_t *val);
/**
*@}
*
*/
#ifdef __cplusplus
}
#endif
#endif /* LPS28DFW_REGS_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/