thermo25  2.1.0.0
thermo25.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 THERMO25_H
29 #define THERMO25_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_spi_master.h"
48 #include "spi_specifics.h"
49 
70 #define THERMO25_MODE_CONTINUOUS 0x00
71 #define THERMO25_MODE_SHUTDOWN 0xFF
72 
77 #define THERMO25_DEVICE_ID 0x900F
78 
83 #define THERMO25_DATA_RESOLUTION 0.03125f
84 
93 #define THERMO25_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
94 #define THERMO25_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
95  // thermo25_set
97 
112 #define THERMO25_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  // thermo25_map // thermo25
120 
125 typedef struct
126 {
127  // Modules
128  spi_master_t spi;
130  pin_name_t chip_select;
132  uint8_t dev_mode;
134 } thermo25_t;
135 
140 typedef struct
141 {
142  // Communication gpio pins
143  pin_name_t miso;
144  pin_name_t mosi;
145  pin_name_t sck;
146  pin_name_t cs;
148  // static variable
149  uint32_t spi_speed;
150  spi_master_mode_t spi_mode;
151  spi_master_chip_select_polarity_t cs_polarity;
154 
159 typedef enum
160 {
162  THERMO25_ERROR = -1
163 
165 
182 
197 
211 err_t thermo25_set_mode ( thermo25_t *ctx, uint8_t mode );
212 
225 err_t thermo25_read_data ( thermo25_t *ctx, uint16_t *data_out );
226 
239 
251 err_t thermo25_read_temperature ( thermo25_t *ctx, float *temperature );
252 
253 #ifdef __cplusplus
254 }
255 #endif
256 #endif // THERMO25_H
257  // thermo25
259 
260 // ------------------------------------------------------------------------ END
thermo25_t::chip_select
pin_name_t chip_select
Definition: thermo25.h:130
thermo25_cfg_t::miso
pin_name_t miso
Definition: thermo25.h:143
thermo25_set_mode
err_t thermo25_set_mode(thermo25_t *ctx, uint8_t mode)
Thermo 25 set mode function.
thermo25_t::spi
spi_master_t spi
Definition: thermo25.h:128
spi_specifics.h
This file contains SPI specific macros, functions, etc.
thermo25_cfg_t::spi_speed
uint32_t spi_speed
Definition: thermo25.h:149
thermo25_read_temperature
err_t thermo25_read_temperature(thermo25_t *ctx, float *temperature)
Thermo 25 read temperature function.
thermo25_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: thermo25.h:151
thermo25_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: thermo25.h:150
thermo25_read_data
err_t thermo25_read_data(thermo25_t *ctx, uint16_t *data_out)
Thermo 25 read data function.
thermo25_cfg_t::mosi
pin_name_t mosi
Definition: thermo25.h:144
thermo25_cfg_setup
void thermo25_cfg_setup(thermo25_cfg_t *cfg)
Thermo 25 configuration object setup function.
thermo25_cfg_t
Thermo 25 Click configuration object.
Definition: thermo25.h:141
THERMO25_ERROR
@ THERMO25_ERROR
Definition: thermo25.h:162
thermo25_init
err_t thermo25_init(thermo25_t *ctx, thermo25_cfg_t *cfg)
Thermo 25 initialization function.
thermo25_t
Thermo 25 Click context object.
Definition: thermo25.h:126
thermo25_return_value_t
thermo25_return_value_t
Thermo 25 Click return value data.
Definition: thermo25.h:160
thermo25_check_communication
err_t thermo25_check_communication(thermo25_t *ctx)
Thermo 25 check communication function.
THERMO25_OK
@ THERMO25_OK
Definition: thermo25.h:161
thermo25_t::dev_mode
uint8_t dev_mode
Definition: thermo25.h:132
thermo25_cfg_t::cs
pin_name_t cs
Definition: thermo25.h:146
thermo25_cfg_t::sck
pin_name_t sck
Definition: thermo25.h:145