thermo  2.0.0.0
thermo.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef THERMO_H
36 #define THERMO_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define THERMO_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
59 
65 #define THERMO_RETVAL uint8_t
66 
67 #define THERMO_OK 0x00
68 #define THERMO_INIT_ERROR 0xFF
69  // End group macro
72 // --------------------------------------------------------------- PUBLIC TYPES
81 typedef struct
82 {
83  // Modules
84 
85  spi_master_t spi;
86 
87 } thermo_t;
88 
92 typedef struct
93 {
94  // Communication gpio pins
95 
96  pin_name_t miso;
97  pin_name_t mosi;
98  pin_name_t sck;
99  pin_name_t cs;
100 
101  // static variable
102 
103  hal_spi_speed_t spi_speed;
104  hal_spi_mode_t spi_mode;
105 
106 } thermo_cfg_t;
107  // End types group
109 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
110 
115 #ifdef __cplusplus
116 extern "C"{
117 #endif
118 
127 void thermo_cfg_setup ( thermo_cfg_t *cfg );
128 
137 
148 uint32_t thermo_read_data ( thermo_t* ctx );
149 
160 float thermo_get_temperature ( thermo_t* ctx );
161 
173 
185 uint8_t thermo_check_fault ( thermo_t* ctx );
186 
199 uint8_t thermo_short_circuited_vcc ( thermo_t* ctx );
200 
213 uint8_t thermo_short_circuited_gnd ( thermo_t* ctx );
214 
227 uint8_t thermo_check_connections ( thermo_t* ctx );
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 #endif // _THERMO_H_
233  // End public_function group
236 
237 // ------------------------------------------------------------------------- END
uint8_t thermo_check_fault(thermo_t *ctx)
Check fault states function.
pin_name_t mosi
Definition: thermo.h:97
float thermo_get_temperature(thermo_t *ctx)
Get thermocouple temperature function.
#define THERMO_RETVAL
Definition: thermo.h:65
uint8_t thermo_short_circuited_vcc(thermo_t *ctx)
Check short-circuited to Vcc function.
uint8_t thermo_short_circuited_gnd(thermo_t *ctx)
Check short-circuited to GND function.
uint8_t thermo_check_connections(thermo_t *ctx)
Check connections fault function.
void thermo_cfg_setup(thermo_cfg_t *cfg)
Config Object Initialization function.
uint32_t thermo_read_data(thermo_t *ctx)
Read data from sensor function.
float thermo_get_junction_temperature(thermo_t *ctx)
Get reference junction temperature function.
Click ctx object definition.
Definition: thermo.h:81
pin_name_t sck
Definition: thermo.h:98
hal_spi_mode_t spi_mode
Definition: thermo.h:104
Click configuration structure definition.
Definition: thermo.h:92
THERMO_RETVAL thermo_init(thermo_t *ctx, thermo_cfg_t *cfg)
Initialization function.
hal_spi_speed_t spi_speed
Definition: thermo.h:103
pin_name_t cs
Definition: thermo.h:99
pin_name_t miso
Definition: thermo.h:96
spi_master_t spi
Definition: thermo.h:85