Developer World
Spresense SDK Library v3.3.0-375c679
barometer.h
1/****************************************************************************
2 * modules/include/sensing/logical_sensor/barometer.h
3 *
4 * Copyright 2018 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
36#ifndef __INCLUDE_SENSING_BAROMETER_H
37#define __INCLUDE_SENSING_BAROMETER_H
38
44/****************************************************************************
45 * Included Files
46 ****************************************************************************/
47
48#include <sdk/config.h>
49#include <asmp/mpmq.h>
50#include <asmp/mptask.h>
51#include <nuttx/sensors/bmp280.h>
53#include "sensing/sensor_api.h"
54#include "sensing/sensor_id.h"
55#include "memutils/s_stl/queue.h"
56
57/****************************************************************************
58 * Pre-processor Definitions
59 ****************************************************************************/
60
61#define BAROMETER_PRESSURE_SAMPLING_FREQUENCY 8
62#define BAROMETER_PRESSURE_WATERMARK_NUM 40
63#define BAROMETER_TEMPERATURE_SAMPLING_FREQUENCY 8
64#define BAROMETER_TEMPERATURE_WATERMARK_NUM 40
66#define PRESSURE_SAMPLING_FREQUENCY BAROMETER_PRESSURE_SAMPLING_FREQUENCY
67#define PRESSURE_WATERMARK_NUM BAROMETER_PRESSURE_WATERMARK_NUM
68
69#define TEMPERATURE_SAMPLING_FREQUENCY BAROMETER_TEMPERATURE_SAMPLING_FREQUENCY
70#define TEMPERATURE_WATERMARK_NUM BAROMETER_TEMPERATURE_WATERMARK_NUM
71
72/****************************************************************************
73 * Public Types
74 ****************************************************************************/
75
81typedef struct
82{
85
91typedef struct
92{
95
96/*--------------------------------------------------------------------*/
97/* Barometer Class */
98/*--------------------------------------------------------------------*/
99
101{
102public:
103
104 /* public methods */
105 int open(void);
106 int close(void);
107 int start(void);
108 int stop(void);
109 int write(sensor_command_data_mh_t*);
110 void setAdjustParam(struct bmp280_press_adj_s* param);
111 void setAdjustParam(struct bmp280_temp_adj_s* param);
112
113 BarometerClass(SensorClientID id)
114 : m_id(id), isReceivedPressureData(false), isReceivedTemperatureData(false)
115 {
116 };
117
118 ~BarometerClass(){};
119
120private:
121
122 /* private members */
123
124 SensorClientID m_id;
125
126 struct bmp280_press_adj_s press_adj;
127 struct bmp280_temp_adj_s temp_adj;
128
129 bool isReceivedPressureData;
130 bool isReceivedTemperatureData;
131 MemMgrLite::MemHandle pressureDate;
132 MemMgrLite::MemHandle temperatureData;
133
134 void compemsate(void);
135 uint32_t compensatePressure(int32_t adc_P, int32_t comp_T);
136 int32_t compensateTemperature(int32_t adc_T);
137
138};
139
140/****************************************************************************
141 * Public Function Prototypes
142 ****************************************************************************/
143
150
157
164
171
178
186
192void BarometerSetPressureAdjustParam(struct bmp280_press_adj_s* param);
193
199void BarometerSetTemperatureAdjustParam(struct bmp280_temp_adj_s* param);
200
205#endif /* __INCLUDE_SENSING_BAROMETER_H */
206
Memory Handler API.
Definition: barometer.h:101
Memory Handler Class for "Memory Manager Lite". This is only wrapper class for convert project-specif...
Definition: MemManager.h:107
int BarometerClose(BarometerClass *ins)
Close BarometerClass.
int BarometerWrite(BarometerClass *ins, sensor_command_data_mh_t *command)
Send data to BarometerClass.
void BarometerSetTemperatureAdjustParam(struct bmp280_temp_adj_s *param)
Set sensor predefined adjustment values for temperature.
int BarometerStart(BarometerClass *ins)
Start Barometer.
BarometerClass * BarometerCreate(void)
Create BarometerClass instance.
#define BAROMETER_PRESSURE_WATERMARK_NUM
Definition: barometer.h:62
void BarometerSetPressureAdjustParam(struct bmp280_press_adj_s *param)
Set sensor predefined adjustment values for pressure.
int BarometerOpen(BarometerClass *ins)
Open BarometerClass.
int BarometerStop(BarometerClass *ins)
Stop Barometer.
#define BAROMETER_TEMPERATURE_WATERMARK_NUM
Definition: barometer.h:64
Input pressure data to DSP.
Definition: barometer.h:92
Input temperature data to DSP.
Definition: barometer.h:82
The command of send some sensor data with MemHandle to the sensor manager. This function only can cal...
Definition: sensor_api.h:134