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
32 extern "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 
60 #define THERMOK3_DUMMY_SIGN_BIT 0x80
61 #define THERMOK3_OPEN_THERMOCOUPLE_BIT 0x04
62 #define THERMOK3_DEVICE_ID_BIT 0x02
63 
68 #define THERMOK3_DATA_RESOLUTION 0x0FFFu
69 #define THERMOK3_TEMP_RESOLUTION 0.25f
70 
79 #define THERMOK3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
80 #define THERMOK3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
81  // thermok3_set
83 
98 #define THERMOK3_MAP_MIKROBUS( cfg, mikrobus ) \
99  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
100  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
101  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
102  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
103  // thermok3_map // thermok3
106 
111 typedef struct
112 {
113  // Modules
114  spi_master_t spi;
116  pin_name_t chip_select;
118 } thermok3_t;
119 
124 typedef struct
125 {
126  // Communication gpio pins
127  pin_name_t miso;
128  pin_name_t mosi;
129  pin_name_t sck;
130  pin_name_t cs;
132  // static variable
133  uint32_t spi_speed;
134  spi_master_mode_t spi_mode;
135  spi_master_chip_select_polarity_t cs_polarity;
138 
143 typedef enum
144 {
148 
150 
167 
182 
195 err_t thermok3_read_data ( thermok3_t *ctx, uint16_t *data_out );
196 
209 err_t thermok3_read_temperature ( thermok3_t *ctx, float *temperature );
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // THERMOK3_H
215  // thermok3
217 
218 // ------------------------------------------------------------------------ END
thermok3_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: thermok3.h:134
thermok3_t::spi
spi_master_t spi
Definition: thermok3.h:114
spi_specifics.h
This file contains SPI specific macros, functions, etc.
thermok3_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: thermok3.h:135
thermok3_cfg_setup
void thermok3_cfg_setup(thermok3_cfg_t *cfg)
Thermo K 3 configuration object setup function.
thermok3_cfg_t::miso
pin_name_t miso
Definition: thermok3.h:127
thermok3_cfg_t::spi_speed
uint32_t spi_speed
Definition: thermok3.h:133
THERMOK3_OPEN_THERMOCOUPLE
@ THERMOK3_OPEN_THERMOCOUPLE
Definition: thermok3.h:147
thermok3_cfg_t::cs
pin_name_t cs
Definition: thermok3.h:130
thermok3_read_data
err_t thermok3_read_data(thermok3_t *ctx, uint16_t *data_out)
Thermo K 3 read data function.
thermok3_cfg_t::mosi
pin_name_t mosi
Definition: thermok3.h:128
thermok3_return_value_t
thermok3_return_value_t
Thermo K 3 Click return value data.
Definition: thermok3.h:144
thermok3_init
err_t thermok3_init(thermok3_t *ctx, thermok3_cfg_t *cfg)
Thermo K 3 initialization function.
thermok3_t
Thermo K 3 Click context object.
Definition: thermok3.h:112
thermok3_cfg_t::sck
pin_name_t sck
Definition: thermok3.h:129
THERMOK3_ERROR
@ THERMOK3_ERROR
Definition: thermok3.h:146
thermok3_t::chip_select
pin_name_t chip_select
Definition: thermok3.h:116
thermok3_read_temperature
err_t thermok3_read_temperature(thermok3_t *ctx, float *temperature)
Thermo K 3 read temperature function.
THERMOK3_OK
@ THERMOK3_OK
Definition: thermok3.h:145
thermok3_cfg_t
Thermo K 3 Click configuration object.
Definition: thermok3.h:125