thermo21 2.0.0.0
thermo21.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 THERMO21_H
29#define THERMO21_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_spi_master.h"
38#include "spi_specifics.h"
39
64#define THERMO21_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
65#define THERMO21_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
66 // thermo21_set
68
83#define THERMO21_MAP_MIKROBUS( cfg, mikrobus ) \
84 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
85 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
86 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
87 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
88 // thermo21_map // thermo21
91
96typedef struct
97{
98 // Modules
99 spi_master_t spi;
100 pin_name_t chip_select;
102} thermo21_t;
103
108typedef struct
109{
110 // Communication gpio pins
111 pin_name_t miso;
112 pin_name_t mosi;
113 pin_name_t sck;
114 pin_name_t cs;
116 // static variable
117 uint32_t spi_speed;
118 spi_master_mode_t spi_mode;
119 spi_master_chip_select_polarity_t cs_polarity;
122
127typedef enum
128{
130 THERMO21_ERROR = -1
131
133
150
166
181err_t thermo21_generic_read ( thermo21_t *ctx, uint8_t *data_out, uint8_t len );
182
195err_t thermo21_temperature_read ( thermo21_t *ctx, float *data_out );
196
197#ifdef __cplusplus
198}
199#endif
200#endif // THERMO21_H
201 // thermo21
203
204// ------------------------------------------------------------------------ END
err_t thermo21_temperature_read(thermo21_t *ctx, float *data_out)
Temperature reading function.
err_t thermo21_generic_read(thermo21_t *ctx, uint8_t *data_out, uint8_t len)
Data reading function.
err_t thermo21_init(thermo21_t *ctx, thermo21_cfg_t *cfg)
Thermo 21 initialization function.
void thermo21_cfg_setup(thermo21_cfg_t *cfg)
Thermo 21 configuration object setup function.
This file contains SPI specific macros, functions, etc.
Thermo 21 Click configuration object.
Definition: thermo21.h:109
spi_master_chip_select_polarity_t cs_polarity
Definition: thermo21.h:119
pin_name_t sck
Definition: thermo21.h:113
spi_master_mode_t spi_mode
Definition: thermo21.h:118
pin_name_t mosi
Definition: thermo21.h:112
uint32_t spi_speed
Definition: thermo21.h:117
pin_name_t miso
Definition: thermo21.h:111
pin_name_t cs
Definition: thermo21.h:114
Thermo 21 Click context object.
Definition: thermo21.h:97
spi_master_t spi
Definition: thermo21.h:99
pin_name_t chip_select
Definition: thermo21.h:100
thermo21_return_value_t
Thermo 21 Click return value data.
Definition: thermo21.h:128
@ THERMO21_ERROR
Definition: thermo21.h:130
@ THERMO21_OK
Definition: thermo21.h:129