1 /*
2  * Copyright (c) 2022 Badgerd Technologies B.V.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Driver is developed to be used with Zephyr. And it only supports i2c interface.
7  *
8  * Author: Talha Can Havadar <havadartalha@gmail.com>
9  *
10  */
11 
12 #ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_BMP581_USER_H_
13 #define ZEPHYR_INCLUDE_DRIVERS_SENSOR_BMP581_USER_H_
14 
15 #include <zephyr/drivers/sensor.h>
16 
17 #define BMP5_SEA_LEVEL_PRESSURE_PA 101325
18 
19 /* ODR settings */
20 #define BMP5_ODR_240_HZ	  0x00
21 #define BMP5_ODR_218_5_HZ 0x01
22 #define BMP5_ODR_199_1_HZ 0x02
23 #define BMP5_ODR_179_2_HZ 0x03
24 #define BMP5_ODR_160_HZ	  0x04
25 #define BMP5_ODR_149_3_HZ 0x05
26 #define BMP5_ODR_140_HZ	  0x06
27 #define BMP5_ODR_129_8_HZ 0x07
28 #define BMP5_ODR_120_HZ	  0x08
29 #define BMP5_ODR_110_1_HZ 0x09
30 #define BMP5_ODR_100_2_HZ 0x0A
31 #define BMP5_ODR_89_6_HZ  0x0B
32 #define BMP5_ODR_80_HZ	  0x0C
33 #define BMP5_ODR_70_HZ	  0x0D
34 #define BMP5_ODR_60_HZ	  0x0E
35 #define BMP5_ODR_50_HZ	  0x0F
36 #define BMP5_ODR_45_HZ	  0x10
37 #define BMP5_ODR_40_HZ	  0x11
38 #define BMP5_ODR_35_HZ	  0x12
39 #define BMP5_ODR_30_HZ	  0x13
40 #define BMP5_ODR_25_HZ	  0x14
41 #define BMP5_ODR_20_HZ	  0x15
42 #define BMP5_ODR_15_HZ	  0x16
43 #define BMP5_ODR_10_HZ	  0x17
44 #define BMP5_ODR_05_HZ	  0x18
45 #define BMP5_ODR_04_HZ	  0x19
46 #define BMP5_ODR_03_HZ	  0x1A
47 #define BMP5_ODR_02_HZ	  0x1B
48 #define BMP5_ODR_01_HZ	  0x1C
49 #define BMP5_ODR_0_5_HZ	  0x1D
50 #define BMP5_ODR_0_250_HZ 0x1E
51 #define BMP5_ODR_0_125_HZ 0x1F
52 
53 /* Oversampling for temperature and pressure */
54 #define BMP5_OVERSAMPLING_1X   0x00
55 #define BMP5_OVERSAMPLING_2X   0x01
56 #define BMP5_OVERSAMPLING_4X   0x02
57 #define BMP5_OVERSAMPLING_8X   0x03
58 #define BMP5_OVERSAMPLING_16X  0x04
59 #define BMP5_OVERSAMPLING_32X  0x05
60 #define BMP5_OVERSAMPLING_64X  0x06
61 #define BMP5_OVERSAMPLING_128X 0x07
62 
63 /* IIR filter for temperature and pressure */
64 #define BMP5_IIR_FILTER_BYPASS	  0x00
65 #define BMP5_IIR_FILTER_COEFF_1	  0x01
66 #define BMP5_IIR_FILTER_COEFF_3	  0x02
67 #define BMP5_IIR_FILTER_COEFF_7	  0x03
68 #define BMP5_IIR_FILTER_COEFF_15  0x04
69 #define BMP5_IIR_FILTER_COEFF_31  0x05
70 #define BMP5_IIR_FILTER_COEFF_63  0x06
71 #define BMP5_IIR_FILTER_COEFF_127 0x07
72 
73 /* Custom ATTR values */
74 
75 /* This is used to enable IIR config,
76  * keep in mind that disabling IIR back in runtime is not
77  * supported yet
78  */
79 #define BMP5_ATTR_IIR_CONFIG (SENSOR_ATTR_PRIV_START + 1u)
80 #define BMP5_ATTR_POWER_MODE (SENSOR_ATTR_PRIV_START + 2u)
81 
82 enum bmp5_powermode {
83 	/*! Standby powermode */
84 	BMP5_POWERMODE_STANDBY,
85 	/*! Normal powermode */
86 	BMP5_POWERMODE_NORMAL,
87 	/*! Forced powermode */
88 	BMP5_POWERMODE_FORCED,
89 	/*! Continuous powermode */
90 	BMP5_POWERMODE_CONTINUOUS,
91 	/*! Deep standby powermode */
92 	BMP5_POWERMODE_DEEP_STANDBY
93 };
94 
95 #endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_BMP581_USER_H_ */
96