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 "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 )
65#define THERMO_RETVAL uint8_t
66
67#define THERMO_OK 0x00
68#define THERMO_INIT_ERROR 0xFF // End group macro
72// --------------------------------------------------------------- PUBLIC TYPES
81typedef struct
82{
83 digital_out_t cs;
84
85 // Modules
86
87 spi_master_t spi;
88 pin_name_t chip_select;
89
90} thermo_t;
91
95typedef struct
96{
97 // Communication gpio pins
98
99 pin_name_t miso;
100 pin_name_t mosi;
101 pin_name_t sck;
102 pin_name_t cs;
103
104 // static variable
105
106 uint32_t spi_speed;
107 spi_master_mode_t spi_mode;
108 spi_master_chip_select_polarity_t cs_polarity;
109
111 // End types group
113// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
114
119#ifdef __cplusplus
120extern "C"{
121#endif
122
132
141
152uint32_t thermo_read_data ( thermo_t* ctx );
153
165
177
190
204
218
232
233#ifdef __cplusplus
234}
235#endif
236#endif // _THERMO_H_
237 // End public_function group
240
241// ------------------------------------------------------------------------- END
#define THERMO_RETVAL
Definition: thermo.h:65
THERMO_RETVAL thermo_init(thermo_t *ctx, thermo_cfg_t *cfg)
Initialization function.
uint8_t thermo_short_circuited_vcc(thermo_t *ctx)
Check short-circuited to Vcc function.
float thermo_get_temperature(thermo_t *ctx)
Get thermocouple temperature function.
void thermo_cfg_setup(thermo_cfg_t *cfg)
Config Object Initialization 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.
uint32_t thermo_read_data(thermo_t *ctx)
Read data from sensor function.
uint8_t thermo_check_fault(thermo_t *ctx)
Check fault states function.
float thermo_get_junction_temperature(thermo_t *ctx)
Get reference junction temperature function.
Click configuration structure definition.
Definition: thermo.h:96
spi_master_chip_select_polarity_t cs_polarity
Definition: thermo.h:108
pin_name_t sck
Definition: thermo.h:101
spi_master_mode_t spi_mode
Definition: thermo.h:107
pin_name_t mosi
Definition: thermo.h:100
uint32_t spi_speed
Definition: thermo.h:106
pin_name_t miso
Definition: thermo.h:99
pin_name_t cs
Definition: thermo.h:102
Click ctx object definition.
Definition: thermo.h:82
digital_out_t cs
Definition: thermo.h:83
spi_master_t spi
Definition: thermo.h:87
pin_name_t chip_select
Definition: thermo.h:88