thermo  2.0.0.0
thermo.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef THERMO_H
36 #define THERMO_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_spi_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
64 #define THERMO_MAP_MIKROBUS( cfg, mikrobus ) \
65  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
66  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
67  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
68  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
69 
75 #define THERMO_RETVAL uint8_t
76 
77 #define THERMO_OK 0x00
78 #define THERMO_INIT_ERROR 0xFF
79  // End group macro
82 // --------------------------------------------------------------- PUBLIC TYPES
91 typedef struct
92 {
93  digital_out_t cs;
94 
95  // Modules
96 
97  spi_master_t spi;
98  pin_name_t chip_select;
99 
100 } thermo_t;
101 
105 typedef struct
106 {
107  // Communication gpio pins
108 
109  pin_name_t miso;
110  pin_name_t mosi;
111  pin_name_t sck;
112  pin_name_t cs;
113 
114  // static variable
115 
116  uint32_t spi_speed;
117  spi_master_mode_t spi_mode;
118  spi_master_chip_select_polarity_t cs_polarity;
119 
120 } thermo_cfg_t;
121  // End types group
123 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
124 
129 #ifdef __cplusplus
130 extern "C"{
131 #endif
132 
142 
151 
162 uint32_t thermo_read_data ( thermo_t* ctx );
163 
175 
187 
199 uint8_t thermo_check_fault ( thermo_t* ctx );
200 
214 
228 
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 #endif // _THERMO_H_
247  // End public_function group
250 
251 // ------------------------------------------------------------------------- END
thermo_cfg_setup
void thermo_cfg_setup(thermo_cfg_t *cfg)
Config Object Initialization function.
thermo_t
Click ctx object definition.
Definition: thermo.h:92
thermo_cfg_t
Click configuration structure definition.
Definition: thermo.h:106
thermo_cfg_t::mosi
pin_name_t mosi
Definition: thermo.h:110
thermo_cfg_t::cs
pin_name_t cs
Definition: thermo.h:112
thermo_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: thermo.h:118
thermo_cfg_t::spi_speed
uint32_t spi_speed
Definition: thermo.h:116
thermo_cfg_t::miso
pin_name_t miso
Definition: thermo.h:109
thermo_t::chip_select
pin_name_t chip_select
Definition: thermo.h:98
thermo_read_data
uint32_t thermo_read_data(thermo_t *ctx)
Read data from sensor function.
thermo_check_fault
uint8_t thermo_check_fault(thermo_t *ctx)
Check fault states function.
thermo_t::cs
digital_out_t cs
Definition: thermo.h:93
thermo_t::spi
spi_master_t spi
Definition: thermo.h:97
thermo_init
THERMO_RETVAL thermo_init(thermo_t *ctx, thermo_cfg_t *cfg)
Initialization function.
thermo_short_circuited_gnd
uint8_t thermo_short_circuited_gnd(thermo_t *ctx)
Check short-circuited to GND function.
thermo_short_circuited_vcc
uint8_t thermo_short_circuited_vcc(thermo_t *ctx)
Check short-circuited to Vcc function.
thermo_cfg_t::sck
pin_name_t sck
Definition: thermo.h:111
thermo_check_connections
uint8_t thermo_check_connections(thermo_t *ctx)
Check connections fault function.
THERMO_RETVAL
#define THERMO_RETVAL
Definition: thermo.h:75
thermo_get_temperature
float thermo_get_temperature(thermo_t *ctx)
Get thermocouple temperature function.
thermo_get_junction_temperature
float thermo_get_junction_temperature(thermo_t *ctx)
Get reference junction temperature function.
thermo_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: thermo.h:117