barometer7 2.0.0.0
barometer7.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef BAROMETER7_H
29#define BAROMETER7_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
52#include "spi_specifics.h"
53
74#define BAROMETER7_CMD_TRIGGER_TEST_MODE 0x0C
75#define BAROMETER7_CMD_RESET_BIT_MASK 0x10
76#define BAROMETER7_CMD_ACQUIRE_PRESSURE 0x20
77#define BAROMETER7_CMD_ACQUIRE_TEMPERATURE 0x40
78#define BAROMETER7_CMD_TRIGGER_DIAGNOSIS 0x80
79#define BAROMETER7_CMD_ACQUIRE_IDENTIFIER 0xE0
80
81 // barometer7_cmd
82
101#define BAROMETER7_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
102#define BAROMETER7_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
103
104 // barometer7_set
105
120#define BAROMETER7_MAP_MIKROBUS( cfg, mikrobus ) \
121 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
122 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
123 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
124 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
125
126 // barometer7_map
127 // barometer7
128
133typedef struct
134{
135 // Modules
136 spi_master_t spi;
138 pin_name_t chip_select;
140 uint8_t diagnosis;
141 uint8_t parity;
144
149typedef struct
150{
151 // Communication gpio pins
152 pin_name_t miso;
153 pin_name_t mosi;
154 pin_name_t sck;
155 pin_name_t cs;
157 // static variable
158 uint32_t spi_speed;
159 spi_master_mode_t spi_mode;
160 spi_master_chip_select_polarity_t cs_polarity;
163
168typedef struct
169{
170 uint8_t supplier;
173 uint8_t asic_name;
176
188
203
220
236
251
267err_t barometer7_generic_transfer ( barometer7_t *ctx, uint8_t cmd, uint16_t *data_out );
268
285err_t barometer7_set_command ( barometer7_t *ctx, uint8_t cmd, uint16_t *data_out );
286
306err_t barometer7_set_reset ( barometer7_t *ctx, uint8_t cmd, uint16_t *data_out );
307
322err_t barometer7_get_press_data ( barometer7_t *ctx, uint16_t *press_data );
323
338err_t barometer7_get_temp_data ( barometer7_t *ctx, uint16_t *temp_data );
339
354err_t barometer7_get_trigger_diagnosis_data ( barometer7_t *ctx, uint16_t *td_data );
355
370err_t barometer7_trigger_test_mode ( barometer7_t *ctx, uint16_t *tdm_data );
371
386err_t barometer7_get_id_data ( barometer7_t *ctx, uint16_t *id_data );
387
403
419err_t barometer7_get_pressure ( barometer7_t *ctx, float *pressure );
420
436err_t barometer7_get_temperature ( barometer7_t *ctx, float *temperature );
437
438
439
440#ifdef __cplusplus
441}
442#endif
443#endif // BAROMETER7_H
444
445 // barometer7
446
447// ------------------------------------------------------------------------ END
barometer7_return_value_t
Barometer 7 Click return value data.
Definition barometer7.h:182
@ BAROMETER7_ERROR
Definition barometer7.h:184
@ BAROMETER7_OK
Definition barometer7.h:183
@ BAROMETER7_CMD_ERROR
Definition barometer7.h:185
barometer7_diagnosis_code_t
Barometer 7 Click diagnosis code data.
Definition barometer7.h:194
@ BAROMETER7_ACQUISITION_CHAIN_FAILURE
Definition barometer7.h:196
@ BAROMETER7_NO_ERROR
Definition barometer7.h:200
@ BAROMETER7_PRESSURE_OUT_OF_RANGE_LOW
Definition barometer7.h:199
@ BAROMETER7_SENSOR_CELL_FAILURE
Definition barometer7.h:197
@ BAROMETER7_EEPROM_FEC_ERROR
Definition barometer7.h:195
@ BAROMETER7_PRESSURE_OUT_OF_RANGE_HIGH
Definition barometer7.h:198
err_t barometer7_get_pressure(barometer7_t *ctx, float *pressure)
Barometer 7 get pressure function.
err_t barometer7_generic_transfer(barometer7_t *ctx, uint8_t cmd, uint16_t *data_out)
Barometer 7 data transfer function.
err_t barometer7_trigger_test_mode(barometer7_t *ctx, uint16_t *tdm_data)
Barometer 7 get trigger test mode data function.
err_t barometer7_get_identifier(barometer7_t *ctx, barometer7_identifier_t *identifier)
Barometer 7 get identifier function.
err_t barometer7_set_reset(barometer7_t *ctx, uint8_t cmd, uint16_t *data_out)
Barometer 7 set reset function.
err_t barometer7_get_temp_data(barometer7_t *ctx, uint16_t *temp_data)
Barometer 7 get temperature data function.
err_t barometer7_get_id_data(barometer7_t *ctx, uint16_t *id_data)
Barometer 7 get ID data function.
err_t barometer7_set_command(barometer7_t *ctx, uint8_t cmd, uint16_t *data_out)
Barometer 7 set command function.
err_t barometer7_get_press_data(barometer7_t *ctx, uint16_t *press_data)
Barometer 7 get pressure data function.
err_t barometer7_get_temperature(barometer7_t *ctx, float *temperature)
Barometer 7 get temperature function.
err_t barometer7_default_cfg(barometer7_t *ctx)
Barometer 7 default configuration function.
err_t barometer7_init(barometer7_t *ctx, barometer7_cfg_t *cfg)
Barometer 7 initialization function.
void barometer7_cfg_setup(barometer7_cfg_t *cfg)
Barometer 7 configuration object setup function.
err_t barometer7_get_trigger_diagnosis_data(barometer7_t *ctx, uint16_t *td_data)
Barometer 7 get trigger diagnosis data function.
This file contains SPI specific macros, functions, etc.
Barometer 7 Click configuration object.
Definition barometer7.h:150
spi_master_chip_select_polarity_t cs_polarity
Definition barometer7.h:160
pin_name_t sck
Definition barometer7.h:154
spi_master_mode_t spi_mode
Definition barometer7.h:159
pin_name_t mosi
Definition barometer7.h:153
uint32_t spi_speed
Definition barometer7.h:158
pin_name_t miso
Definition barometer7.h:152
pin_name_t cs
Definition barometer7.h:155
Barometer 7 Click response structure for identifier.
Definition barometer7.h:169
uint8_t supplier
Definition barometer7.h:170
uint8_t metal_version
Definition barometer7.h:172
uint8_t silicon_version
Definition barometer7.h:171
uint8_t asic_name
Definition barometer7.h:173
Barometer 7 Click context object.
Definition barometer7.h:134
spi_master_t spi
Definition barometer7.h:136
uint8_t diagnosis
Definition barometer7.h:140
uint8_t parity
Definition barometer7.h:141
pin_name_t chip_select
Definition barometer7.h:138