audioamp 2.0.0.0
audioamp.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
34#ifndef AUDIOAMP_H
35#define AUDIOAMP_H
36
41#ifdef PREINIT_SUPPORTED
42#include "preinit.h"
43#endif
44
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
47 #include "delays.h"
48 #endif
49#endif
50
51#include "drv_digital_in.h"
52#include "drv_i2c_master.h"
53
63#define AUDIOAMP_MAP_MIKROBUS( cfg, mikrobus ) \
64 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
73#define AUDIOAMP_OK 0
74#define AUDIOAMP_INIT_ERROR (-1)
81#define AUDIOAMP_I2C_ADDRESS_0 0x7C
82#define AUDIOAMP_I2C_ADDRESS_1 0x7D
89#define AUDIOAMP_IN_1 0x04
90#define AUDIOAMP_IN_2 0x08
97#define AUDIOAMP_DG_EN 0x10
98#define AUDIOAMP_DG_CONT 0x08
99#define AUDIOAMP_DG_RESET 0x06
100#define AUDIOAMP_DG_ILIMIT 0x04
103 // End group macro
104
113typedef struct
114{
115 // Input pins
116
117 digital_in_t int_pin;
118
119 // Modules
120
121 i2c_master_t i2c;
122
123 // ctx variable
124
126
127} audioamp_t;
128
132typedef struct
133{
134 // Communication gpio pins
135
136 pin_name_t scl;
137 pin_name_t sda;
138
139 // Additional gpio pins
140
141 pin_name_t int_pin;
142
143 // Static variable
144
145 uint32_t i2c_speed;
146 uint8_t i2c_address;
147
149
150 // End types group
151
157#ifdef __cplusplus
158extern "C"{
159#endif
160
170
182
195
207
221err_t audioamp_set_volume ( audioamp_t *ctx, uint8_t in_sel, uint8_t volume_level );
222
235
248
261
278err_t audioamp_set_fault_detecton_control ( audioamp_t *ctx, uint8_t input_command );
279
292err_t audioamp_set_diagnostic_control ( audioamp_t *ctx, uint8_t input_command );
293
305
306#ifdef __cplusplus
307}
308#endif
309#endif // AUDIOAMP_H
310
311 // End public_function group
312 // End click Driver group
313
314// ------------------------------------------------------------------------ END
err_t audioamp_power_off(audioamp_t *ctx)
Turn off the Audio Amp click function.
uint8_t audioamp_check_fault(audioamp_t *ctx)
Check Fault status function.
err_t audioamp_set_fault_normal_operation(audioamp_t *ctx)
Set normal opeation of Fault function.
err_t audioamp_set_volume(audioamp_t *ctx, uint8_t in_sel, uint8_t volume_level)
Set volume function.
err_t audioamp_set_fault_detecton_control(audioamp_t *ctx, uint8_t input_command)
Set fault detection control function.
err_t audioamp_set_diagnostic_control(audioamp_t *ctx, uint8_t input_command)
Set diagnostic control function.
err_t audioamp_unmute(audioamp_t *ctx)
Unmute input function.
err_t audioamp_power_on(audioamp_t *ctx)
Turn on the Audio Amp click function.
err_t audioamp_mute(audioamp_t *ctx)
Mute input function.
void audioamp_cfg_setup(audioamp_cfg_t *cfg)
Config Object Initialization function.
err_t audioamp_init(audioamp_t *ctx, audioamp_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition audioamp.h:133
uint32_t i2c_speed
Definition audioamp.h:145
pin_name_t scl
Definition audioamp.h:136
pin_name_t int_pin
Definition audioamp.h:141
pin_name_t sda
Definition audioamp.h:137
uint8_t i2c_address
Definition audioamp.h:146
Click ctx object definition.
Definition audioamp.h:114
digital_in_t int_pin
Definition audioamp.h:117
i2c_master_t i2c
Definition audioamp.h:121
uint8_t slave_address
Definition audioamp.h:125