mic2
2.0.0.0
cmake
mic2
lib_mic2
include
mic2.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
35
#ifndef MIC2_H
36
#define MIC2_H
37
38
#include "drv_digital_out.h"
39
#include "drv_digital_in.h"
40
#include "drv_analog_in.h"
41
#include "drv_i2c_master.h"
42
43
// -------------------------------------------------------------- PUBLIC MACROS
44
54
#define MIC2_MAP_MIKROBUS( cfg, mikrobus ) \
55
cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
56
cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
57
cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
58
63
#define MIC2_RETVAL uint8_t
64
65
#define MIC2_OK 0x00
66
#define MIC2_INIT_ERROR 0xFF
67
#define MIC2_DEVICE_SLAVE_ADDRESS 0x2C
68
// End group macro
71
// --------------------------------------------------------------- PUBLIC TYPES
80
typedef
uint16_t
mic2_data_t
;
81
85
typedef
struct
86
{
87
// Modules
88
i2c_master_t
i2c
;
89
90
// ctx variable
91
uint8_t
slave_address
;
92
93
analog_in_t
adc
;
94
95
}
mic2_t
;
96
100
typedef
struct
101
{
102
// Communication gpio pins
103
pin_name_t
scl
;
104
pin_name_t
sda
;
105
pin_name_t
an_pin
;
106
107
// static variable
108
109
uint32_t
i2c_speed
;
110
uint8_t
i2c_address
;
111
112
analog_in_resolution_t
resolution
;
// Resolution
113
float
vref
;
// VRef
114
115
}
mic2_cfg_t
;
116
// End types group
118
// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
119
125
#ifdef __cplusplus
126
extern
"C"
{
127
#endif
128
137
void
mic2_cfg_setup
(
mic2_cfg_t
*cfg );
138
147
MIC2_RETVAL
mic2_init
(
mic2_t
*ctx,
mic2_cfg_t
*cfg );
148
156
void
mic2_generic_write
(
mic2_t
*ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
157
165
void
mic2_set_potentiometer
(
mic2_t
*ctx, uint8_t ptt_value );
166
175
mic2_data_t
mic2_generic_read
(
mic2_t
*ctx );
176
177
#ifdef __cplusplus
178
}
179
#endif
180
#endif // _MIC2_H_
181
// End public_function group
184
185
// ------------------------------------------------------------------------ END
mic2_generic_write
void mic2_generic_write(mic2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Click Default Configuration function.
mic2_cfg_t
Click configuration structure definition.
Definition:
mic2.h:101
mic2_cfg_t::i2c_address
uint8_t i2c_address
Definition:
mic2.h:110
mic2_cfg_t::sda
pin_name_t sda
Definition:
mic2.h:104
mic2_cfg_t::resolution
analog_in_resolution_t resolution
Definition:
mic2.h:112
MIC2_RETVAL
#define MIC2_RETVAL
Definition:
mic2.h:63
mic2_init
MIC2_RETVAL mic2_init(mic2_t *ctx, mic2_cfg_t *cfg)
Initialization function.
mic2_generic_read
mic2_data_t mic2_generic_read(mic2_t *ctx)
Generic read function.
mic2_cfg_t::an_pin
pin_name_t an_pin
Definition:
mic2.h:105
mic2_t
Click ctx object definition.
Definition:
mic2.h:86
mic2_cfg_t::vref
float vref
Definition:
mic2.h:113
mic2_set_potentiometer
void mic2_set_potentiometer(mic2_t *ctx, uint8_t ptt_value)
Set potenciometer value.
mic2_cfg_t::scl
pin_name_t scl
Definition:
mic2.h:103
mic2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition:
mic2.h:109
mic2_t::slave_address
uint8_t slave_address
Definition:
mic2.h:91
mic2_cfg_setup
void mic2_cfg_setup(mic2_cfg_t *cfg)
Config Object Initialization function.
mic2_t::adc
analog_in_t adc
Definition:
mic2.h:93
mic2_data_t
uint16_t mic2_data_t
Analog data type.
Definition:
mic2.h:80
mic2_t::i2c
i2c_master_t i2c
Definition:
mic2.h:88
Generated by
1.8.20