thermok3 2.1.0.0
thermok3.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 THERMOK3_H
29#define THERMOK3_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 THERMOK3_DUMMY_SIGN_BIT 0x80
75#define THERMOK3_OPEN_THERMOCOUPLE_BIT 0x04
76#define THERMOK3_DEVICE_ID_BIT 0x02
77
82#define THERMOK3_DATA_RESOLUTION 0x0FFFu
83#define THERMOK3_TEMP_RESOLUTION 0.25f
84
93#define THERMOK3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
94#define THERMOK3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
95
96 // thermok3_set
97
112#define THERMOK3_MAP_MIKROBUS( cfg, mikrobus ) \
113 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
114 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
115 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
116 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
117
118 // thermok3_map
119 // thermok3
120
125typedef struct
126{
127 // Modules
128 spi_master_t spi;
130 pin_name_t chip_select;
132} thermok3_t;
133
138typedef struct
139{
140 // Communication gpio pins
141 pin_name_t miso;
142 pin_name_t mosi;
143 pin_name_t sck;
144 pin_name_t cs;
146 // static variable
147 uint32_t spi_speed;
148 spi_master_mode_t spi_mode;
149 spi_master_chip_select_polarity_t cs_polarity;
152
164
181
196
209err_t thermok3_read_data ( thermok3_t *ctx, uint16_t *data_out );
210
223err_t thermok3_read_temperature ( thermok3_t *ctx, float *temperature );
224
225#ifdef __cplusplus
226}
227#endif
228#endif // THERMOK3_H
229
230 // thermok3
231
232// ------------------------------------------------------------------------ END
err_t thermok3_init(thermok3_t *ctx, thermok3_cfg_t *cfg)
Thermo K 3 initialization function.
void thermok3_cfg_setup(thermok3_cfg_t *cfg)
Thermo K 3 configuration object setup function.
err_t thermok3_read_temperature(thermok3_t *ctx, float *temperature)
Thermo K 3 read temperature function.
err_t thermok3_read_data(thermok3_t *ctx, uint16_t *data_out)
Thermo K 3 read data function.
This file contains SPI specific macros, functions, etc.
Thermo K 3 Click configuration object.
Definition thermok3.h:139
spi_master_chip_select_polarity_t cs_polarity
Definition thermok3.h:149
pin_name_t sck
Definition thermok3.h:143
spi_master_mode_t spi_mode
Definition thermok3.h:148
pin_name_t mosi
Definition thermok3.h:142
uint32_t spi_speed
Definition thermok3.h:147
pin_name_t miso
Definition thermok3.h:141
pin_name_t cs
Definition thermok3.h:144
Thermo K 3 Click context object.
Definition thermok3.h:126
spi_master_t spi
Definition thermok3.h:128
pin_name_t chip_select
Definition thermok3.h:130
thermok3_return_value_t
Thermo K 3 Click return value data.
Definition thermok3.h:158
@ THERMOK3_OK
Definition thermok3.h:159
@ THERMOK3_ERROR
Definition thermok3.h:160
@ THERMOK3_OPEN_THERMOCOUPLE
Definition thermok3.h:161