Nordic Thingy:52 v2.2.0
drv_pressure.h
1 /*
2  Copyright (c) 2010 - 2017, Nordic Semiconductor ASA
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form, except as embedded into a Nordic
12  Semiconductor ASA integrated circuit in a product or a software update for
13  such product, must reproduce the above copyright notice, this list of
14  conditions and the following disclaimer in the documentation and/or other
15  materials provided with the distribution.
16 
17  3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  contributors may be used to endorse or promote products derived from this
19  software without specific prior written permission.
20 
21  4. This software, with or without modification, must only be used with a
22  Nordic Semiconductor ASA integrated circuit.
23 
24  5. Any software provided in binary form under this license must not be reverse
25  engineered, decompiled, modified and/or disassembled.
26 
27  THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29  OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
48 #ifndef __DRV_PRESSURE_H__
49 #define __DRV_PRESSURE_H__
50 
51 #include "nrf_drv_twi.h"
52 #include <stdint.h>
53 
56 typedef enum
57 {
61 
64 typedef enum
65 {
66  DRV_PRESSURE_MODE_ALTIMETER,
67  DRV_PRESSURE_MODE_BAROMETER
69 
72 typedef struct
73 {
77 
80 typedef void (*drv_pressure_evt_handler_t)(drv_pressure_evt_t const * p_evt);
81 
84 typedef struct
85 {
86  uint8_t twi_addr;
87  uint32_t pin_int;
88  nrf_drv_twi_t const * p_twi_instance;
89  nrf_drv_twi_config_t const * p_twi_cfg;
93 
101 uint32_t drv_pressure_init(drv_pressure_init_t * p_params);
102 
107 uint32_t drv_pressure_enable(void);
108 
113 uint32_t drv_pressure_disable(void);
114 
120 uint32_t drv_pressure_reset(void);
121 
130 
135 float drv_pressure_get(void);
136 
141 uint32_t drv_pressure_sample(void);
142 
147 uint32_t drv_pressure_sleep(void);
148 
149 #endif
150 
drv_pressure_evt_type_t
Pressure driver event types.
Definition: drv_pressure.h:56
uint8_t twi_addr
TWI address.
Definition: drv_pressure.h:86
drv_pressure_evt_handler_t evt_handler
Event handler - called after a pin interrupt has been detected.
Definition: drv_pressure.h:90
void(* drv_pressure_evt_handler_t)(drv_pressure_evt_t const *p_evt)
Pressure driver event handler callback type.
Definition: drv_pressure.h:80
Pressure event struct.
Definition: drv_pressure.h:72
Initialization struct for pressure driver.
Definition: drv_pressure.h:84
Definition: drv_pressure.h:59
uint32_t drv_pressure_sleep(void)
Function for putting the sensor to sleep.
uint32_t drv_pressure_reset(void)
Function for resetting the chip to all default register values.
float drv_pressure_get(void)
Function for getting the pressure data [hPa].
uint32_t drv_pressure_mode_set(drv_pressure_mode_t mode)
Function for changing the mode of the pressure sensor.
drv_pressure_mode_t mode
Current mode of operation.
Definition: drv_pressure.h:91
uint32_t pin_int
Interrupt pin.
Definition: drv_pressure.h:87
drv_pressure_mode_t
Pressure modes of operation.
Definition: drv_pressure.h:64
uint32_t drv_pressure_disable(void)
Function for disabling the pressure sensor.
uint32_t drv_pressure_enable(void)
Function for enabling the pressure sensor.
uint32_t drv_pressure_init(drv_pressure_init_t *p_params)
Function for initializing the pressure driver.
uint32_t drv_pressure_sample(void)
Function for starting the sampling.
nrf_drv_twi_config_t const * p_twi_cfg
The TWI configuration to use while the driver is enabled.
Definition: drv_pressure.h:89
Definition: drv_pressure.h:58
nrf_drv_twi_t const * p_twi_instance
The instance of TWI master to be used for transactions.
Definition: drv_pressure.h:88