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
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define NO22_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.pht = MIKROBUS( mikrobus, MIKROBUS_PWM );
79#define NO22_RETVAL uint8_t
80
81#define NO22_OK 0x00
82#define NO22_INIT_ERROR 0xFF
89#define NO22_PIN_STATE_LOW 0
90#define NO22_PIN_STATE_HIGH 1
97#define NO22_DEVICE_ERROR 0xFF
98#define NO22_DEVICE_OK 0xAA
101 // End group macro
102// --------------------------------------------------------------- PUBLIC TYPES
111typedef struct
112{
113 // Output pins
114
115 digital_out_t pht;
116 digital_out_t cs;
117
118 // Modules
119
120 spi_master_t spi;
121 pin_name_t chip_select;
122
123} no22_t;
124
128typedef struct
129{
130 // Communication gpio pins
131
132 pin_name_t miso;
133 pin_name_t mosi;
134 pin_name_t sck;
135 pin_name_t cs;
136
137 // Additional gpio pins
138
139 pin_name_t pht;
140
141 // static variable
142
143 uint32_t spi_speed;
144 uint8_t spi_mode;
145 spi_master_chip_select_polarity_t cs_polarity;
146
147} no22_cfg_t;
148
149 // End types group
150// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
151
156#ifdef __cplusplus
157extern "C"{
158#endif
159
169
178
186uint16_t no22_read_data ( no22_t *ctx );
187
195float no22_get_ppb ( no22_t *ctx );
196
205uint8_t no22_set_pht_state ( no22_t *ctx, uint8_t state );
206
207#ifdef __cplusplus
208}
209#endif
210#endif // _NO22_H_
211
212 // End public_function group
214
215// ------------------------------------------------------------------------- END
#define NO22_RETVAL
Definition no22.h:79
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:129
uint8_t spi_mode
Definition no22.h:144
spi_master_chip_select_polarity_t cs_polarity
Definition no22.h:145
pin_name_t sck
Definition no22.h:134
pin_name_t mosi
Definition no22.h:133
pin_name_t pht
Definition no22.h:139
uint32_t spi_speed
Definition no22.h:143
pin_name_t miso
Definition no22.h:132
pin_name_t cs
Definition no22.h:135
Click ctx object definition.
Definition no22.h:112
digital_out_t cs
Definition no22.h:116
spi_master_t spi
Definition no22.h:120
digital_out_t pht
Definition no22.h:115
pin_name_t chip_select
Definition no22.h:121