no22 2.0.0.0
no22.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 NO22_H
36#define NO22_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_spi_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
53#define NO22_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
55 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
56 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
57 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58 cfg.pht = MIKROBUS( mikrobus, MIKROBUS_PWM );
65#define NO22_RETVAL uint8_t
66
67#define NO22_OK 0x00
68#define NO22_INIT_ERROR 0xFF
75#define NO22_PIN_STATE_LOW 0
76#define NO22_PIN_STATE_HIGH 1
83#define NO22_DEVICE_ERROR 0xFF
84#define NO22_DEVICE_OK 0xAA // End group macro
88// --------------------------------------------------------------- PUBLIC TYPES
97typedef struct
98{
99 // Output pins
100
101 digital_out_t pht;
102 digital_out_t cs;
103
104 // Modules
105
106 spi_master_t spi;
107 pin_name_t chip_select;
108
109} no22_t;
110
114typedef struct
115{
116 // Communication gpio pins
117
118 pin_name_t miso;
119 pin_name_t mosi;
120 pin_name_t sck;
121 pin_name_t cs;
122
123 // Additional gpio pins
124
125 pin_name_t pht;
126
127 // static variable
128
129 uint32_t spi_speed;
130 uint8_t spi_mode;
131 spi_master_chip_select_polarity_t cs_polarity;
132
133} no22_cfg_t;
134 // End types group
136// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
137
142#ifdef __cplusplus
143extern "C"{
144#endif
145
155
164
172uint16_t no22_read_data ( no22_t *ctx );
173
181float no22_get_ppb ( no22_t *ctx );
182
191uint8_t no22_set_pht_state ( no22_t *ctx, uint8_t state );
192
193#ifdef __cplusplus
194}
195#endif
196#endif // _NO22_H_
197 // End public_function group
200
201// ------------------------------------------------------------------------- END
#define NO22_RETVAL
Definition: no22.h:65
uint8_t no22_set_pht_state(no22_t *ctx, uint8_t state)
Function for setting pht pin.
uint16_t no22_read_data(no22_t *ctx)
Function for reading ADC data.
float no22_get_ppb(no22_t *ctx)
Function for reading ppb data.
void no22_cfg_setup(no22_cfg_t *cfg)
Config Object Initialization function.
NO22_RETVAL no22_init(no22_t *ctx, no22_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition: no22.h:115
uint8_t spi_mode
Definition: no22.h:130
spi_master_chip_select_polarity_t cs_polarity
Definition: no22.h:131
pin_name_t sck
Definition: no22.h:120
pin_name_t mosi
Definition: no22.h:119
pin_name_t pht
Definition: no22.h:125
uint32_t spi_speed
Definition: no22.h:129
pin_name_t miso
Definition: no22.h:118
pin_name_t cs
Definition: no22.h:121
Click ctx object definition.
Definition: no22.h:98
digital_out_t cs
Definition: no22.h:102
spi_master_t spi
Definition: no22.h:106
digital_out_t pht
Definition: no22.h:101
pin_name_t chip_select
Definition: no22.h:107