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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
38 #include "spi_specifics.h"
39 
60 #define THERMO25_MODE_CONTINUOUS 0x00
61 #define THERMO25_MODE_SHUTDOWN 0xFF
62 
67 #define THERMO25_DEVICE_ID 0x900F
68 
73 #define THERMO25_DATA_RESOLUTION 0.03125f
74 
83 #define THERMO25_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
84 #define THERMO25_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
85  // thermo25_set
87 
102 #define THERMO25_MAP_MIKROBUS( cfg, mikrobus ) \
103  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
104  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
105  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
106  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
107  // thermo25_map // thermo25
110 
115 typedef struct
116 {
117  // Modules
118  spi_master_t spi;
120  pin_name_t chip_select;
122  uint8_t dev_mode;
124 } thermo25_t;
125 
130 typedef struct
131 {
132  // Communication gpio pins
133  pin_name_t miso;
134  pin_name_t mosi;
135  pin_name_t sck;
136  pin_name_t cs;
138  // static variable
139  uint32_t spi_speed;
140  spi_master_mode_t spi_mode;
141  spi_master_chip_select_polarity_t cs_polarity;
144 
149 typedef enum
150 {
152  THERMO25_ERROR = -1
153 
155 
172 
187 
201 err_t thermo25_set_mode ( thermo25_t *ctx, uint8_t mode );
202 
215 err_t thermo25_read_data ( thermo25_t *ctx, uint16_t *data_out );
216 
229 
241 err_t thermo25_read_temperature ( thermo25_t *ctx, float *temperature );
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 #endif // THERMO25_H
247  // thermo25
249 
250 // ------------------------------------------------------------------------ END
thermo25_t::chip_select
pin_name_t chip_select
Definition: thermo25.h:120
thermo25_cfg_t::miso
pin_name_t miso
Definition: thermo25.h:133
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:118
spi_specifics.h
This file contains SPI specific macros, functions, etc.
thermo25_cfg_t::spi_speed
uint32_t spi_speed
Definition: thermo25.h:139
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:141
thermo25_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: thermo25.h:140
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:134
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:131
THERMO25_ERROR
@ THERMO25_ERROR
Definition: thermo25.h:152
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:116
thermo25_return_value_t
thermo25_return_value_t
Thermo 25 Click return value data.
Definition: thermo25.h:150
thermo25_check_communication
err_t thermo25_check_communication(thermo25_t *ctx)
Thermo 25 check communication function.
THERMO25_OK
@ THERMO25_OK
Definition: thermo25.h:151
thermo25_t::dev_mode
uint8_t dev_mode
Definition: thermo25.h:122
thermo25_cfg_t::cs
pin_name_t cs
Definition: thermo25.h:136
thermo25_cfg_t::sck
pin_name_t sck
Definition: thermo25.h:135