ambient7  2.0.0.0
ambient7.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
35 #ifndef AMBIENT7_H
36 #define AMBIENT7_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_analog_in.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
43 
53 #define AMBIENT7_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN );
55 
61 #define AMBIENT7_RETVAL uint8_t
62 
63 #define AMBIENT7_OK 0x00
64 #define AMBIENT7_INIT_ERROR 0xFF
65  // End group macro
68 // --------------------------------------------------------------- PUBLIC TYPES
77 typedef analog_in_data_t ambient7_data_t;
78 
82 typedef struct
83 {
84  // Modules
85 
86  analog_in_t adc;
87 
88 } ambient7_t;
89 
93 typedef struct
94 {
95  // Communication gpio pins
96 
97  pin_name_t an_pin;
98 
99  // static variable
100 
101  hal_adc_channel_t channel; // Channel
102  hal_adc_resolution_t resolution; // Resolution
103  hal_adc_voltage_reference_t vref; // VRef
104 
106  // End types group
108 
109 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
110 
116 #ifdef __cplusplus
117 extern "C"{
118 #endif
119 
128 void ambient7_cfg_setup ( ambient7_cfg_t *cfg );
129 
138 
148 
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 #endif // _AMBIENT7_H_
154  // End public_function group
157 
158 // ------------------------------------------------------------------------ END
ambient7_cfg_t::an_pin
pin_name_t an_pin
Definition: ambient7.h:97
ambient7_generic_read
ambient7_data_t ambient7_generic_read(ambient7_t *ctx)
Generic read function.
ambient7_data_t
analog_in_data_t ambient7_data_t
Analog data type.
Definition: ambient7.h:77
ambient7_cfg_t
Click configuration structure definition.
Definition: ambient7.h:93
ambient7_cfg_t::resolution
hal_adc_resolution_t resolution
Definition: ambient7.h:102
ambient7_t::adc
analog_in_t adc
Definition: ambient7.h:86
ambient7_cfg_t::channel
hal_adc_channel_t channel
Definition: ambient7.h:101
AMBIENT7_RETVAL
#define AMBIENT7_RETVAL
Definition: ambient7.h:61
ambient7_cfg_t::vref
hal_adc_voltage_reference_t vref
Definition: ambient7.h:103
ambient7_t
Click ctx object definition.
Definition: ambient7.h:82
ambient7_cfg_setup
void ambient7_cfg_setup(ambient7_cfg_t *cfg)
Config Object Initialization function.
ambient7_init
AMBIENT7_RETVAL ambient7_init(ambient7_t *ctx, ambient7_cfg_t *cfg)
Initialization function.