thermo25 2.1.0.0
thermo25.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 THERMO25_H
29#define THERMO25_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 THERMO25_MODE_CONTINUOUS 0x00
75#define THERMO25_MODE_SHUTDOWN 0xFF
76
81#define THERMO25_DEVICE_ID 0x900F
82
87#define THERMO25_DATA_RESOLUTION 0.03125f
88
97#define THERMO25_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
98#define THERMO25_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
99
100 // thermo25_set
101
116#define THERMO25_MAP_MIKROBUS( cfg, mikrobus ) \
117 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
118 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
119 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
120 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
121
122 // thermo25_map
123 // thermo25
124
129typedef struct
130{
131 // Modules
132 spi_master_t spi;
134 pin_name_t chip_select;
136 uint8_t dev_mode;
138} thermo25_t;
139
144typedef struct
145{
146 // Communication gpio pins
147 pin_name_t miso;
148 pin_name_t mosi;
149 pin_name_t sck;
150 pin_name_t cs;
152 // static variable
153 uint32_t spi_speed;
154 spi_master_mode_t spi_mode;
155 spi_master_chip_select_polarity_t cs_polarity;
158
163typedef enum
164{
166 THERMO25_ERROR = -1
167
169
186
201
215err_t thermo25_set_mode ( thermo25_t *ctx, uint8_t mode );
216
229err_t thermo25_read_data ( thermo25_t *ctx, uint16_t *data_out );
230
243
255err_t thermo25_read_temperature ( thermo25_t *ctx, float *temperature );
256
257#ifdef __cplusplus
258}
259#endif
260#endif // THERMO25_H
261
262 // thermo25
263
264// ------------------------------------------------------------------------ END
err_t thermo25_init(thermo25_t *ctx, thermo25_cfg_t *cfg)
Thermo 25 initialization function.
err_t thermo25_check_communication(thermo25_t *ctx)
Thermo 25 check communication function.
err_t thermo25_read_data(thermo25_t *ctx, uint16_t *data_out)
Thermo 25 read data function.
void thermo25_cfg_setup(thermo25_cfg_t *cfg)
Thermo 25 configuration object setup function.
err_t thermo25_set_mode(thermo25_t *ctx, uint8_t mode)
Thermo 25 set mode function.
err_t thermo25_read_temperature(thermo25_t *ctx, float *temperature)
Thermo 25 read temperature function.
This file contains SPI specific macros, functions, etc.
Thermo 25 Click configuration object.
Definition thermo25.h:145
spi_master_chip_select_polarity_t cs_polarity
Definition thermo25.h:155
pin_name_t sck
Definition thermo25.h:149
spi_master_mode_t spi_mode
Definition thermo25.h:154
pin_name_t mosi
Definition thermo25.h:148
uint32_t spi_speed
Definition thermo25.h:153
pin_name_t miso
Definition thermo25.h:147
pin_name_t cs
Definition thermo25.h:150
Thermo 25 Click context object.
Definition thermo25.h:130
spi_master_t spi
Definition thermo25.h:132
uint8_t dev_mode
Definition thermo25.h:136
pin_name_t chip_select
Definition thermo25.h:134
thermo25_return_value_t
Thermo 25 Click return value data.
Definition thermo25.h:164
@ THERMO25_OK
Definition thermo25.h:165
@ THERMO25_ERROR
Definition thermo25.h:166