volume2 2.0.0.0
volume2.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 VOLUME2_H
29#define VOLUME2_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
59#define VOLUME2_REG_VOLUME_1A_2A 0x00
60
65#define VOLUME2_REG_VOLUME_1B_ZERO1 0x01
66
71#define VOLUME2_REG_VOLUME_2B_ZERO2 0x02
72 // volume2_reg
74
89#define VOLUME2_GAIN_OPT_0_DB 0x00
90
95#define VOLUME2_GAIN_OPT_3_DB 0x01
96
101#define VOLUME2_GAIN_OPT_6_DB 0x02
102
107#define VOLUME2_GAIN_OPT_9_DB 0x03
108
113#define VOLUME2_ZERO_CROSS_DET_OPT_OFF 0x00
114
119#define VOLUME2_ZERO_CROSS_DET_OPT_ON 0x01
120
126#define VOLUME2_SET_DEV_ADDR 0x44
127 // volume2_set
129
144#define VOLUME2_DEVICE_MUTE_ON 0x00
145
150#define VOLUME2_DEVICE_MUTE_OFF 0x01
151 // mte_state
153
168#define VOLUME2_MAP_MIKROBUS( cfg, mikrobus ) \
169 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
170 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
171 cfg.mte = MIKROBUS( mikrobus, MIKROBUS_PWM )
172 // volume2_map // volume2
175
180typedef struct
181{
182 // Output pins
183
184 digital_out_t mte;
186 // Modules
187
188 i2c_master_t i2c;
190 // I2C slave address
191
194} volume2_t;
195
200typedef struct
201{
202 pin_name_t scl;
203 pin_name_t sda;
205 pin_name_t mte;
207 uint32_t i2c_speed;
208 uint8_t i2c_address;
211
216typedef enum
217{
219 VOLUME2_ERROR = -1
220
222
227typedef struct
228{
229 uint8_t gain_ch1;
230 uint8_t gain_ch2;
237
256
274
291
309err_t volume2_generic_write ( volume2_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
310
328err_t volume2_generic_read ( volume2_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
329
344err_t volume2_device_mute ( volume2_t *ctx, uint8_t mte_state );
345
363
364#ifdef __cplusplus
365}
366#endif
367#endif // VOLUME2_H
368 // volume2
370
371// ------------------------------------------------------------------------ END
err_t volume2_device_mute(volume2_t *ctx, uint8_t mte_state)
Volume 2 device mute function.
err_t volume2_init(volume2_t *ctx, volume2_cfg_t *cfg)
Volume 2 initialization function.
err_t volume2_generic_write(volume2_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Volume 2 I2C writing function.
err_t volume2_update_vol_data(volume2_t *ctx, volume2_vol_data_t update_data)
Volume 2 update volume data function.
void volume2_cfg_setup(volume2_cfg_t *cfg)
Volume 2 configuration object setup function.
err_t volume2_default_cfg(volume2_t *ctx)
Volume 2 default configuration function.
err_t volume2_generic_read(volume2_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Volume 2 I2C reading function.
Volume 2 Click configuration object.
Definition: volume2.h:201
pin_name_t mte
Definition: volume2.h:205
uint32_t i2c_speed
Definition: volume2.h:207
pin_name_t scl
Definition: volume2.h:202
pin_name_t sda
Definition: volume2.h:203
uint8_t i2c_address
Definition: volume2.h:208
Volume 2 Click context object.
Definition: volume2.h:181
digital_out_t mte
Definition: volume2.h:184
i2c_master_t i2c
Definition: volume2.h:188
uint8_t slave_address
Definition: volume2.h:192
Volume 2 Vol data structure.
Definition: volume2.h:228
uint8_t gain_ch2
Definition: volume2.h:230
uint8_t attenuation_ch1
Definition: volume2.h:231
uint8_t zero_cross_det_ch2
Definition: volume2.h:234
uint8_t attenuation_ch2
Definition: volume2.h:232
uint8_t gain_ch1
Definition: volume2.h:229
uint8_t zero_cross_det_ch1
Definition: volume2.h:233
volume2_return_value_t
Volume 2 Click return value data.
Definition: volume2.h:217
@ VOLUME2_ERROR
Definition: volume2.h:219
@ VOLUME2_OK
Definition: volume2.h:218