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 
37 #include "mikrosdk_version.h"
38 
39 #ifdef __GNUC__
40 #if mikroSDK_GET_VERSION < 20800ul
41 #include "rcu_delays.h"
42 #else
43 #include "delays.h"
44 #endif
45 #endif
46 
47 #include "drv_digital_in.h"
48 #include "drv_i2c_master.h"
49 
59 #define AUDIOAMP_MAP_MIKROBUS( cfg, mikrobus ) \
60  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
61  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
62  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
63 
69 #define AUDIOAMP_OK 0
70 #define AUDIOAMP_INIT_ERROR (-1)
71 
77 #define AUDIOAMP_I2C_ADDRESS_0 0x7C
78 #define AUDIOAMP_I2C_ADDRESS_1 0x7D
79 
85 #define AUDIOAMP_IN_1 0x04
86 #define AUDIOAMP_IN_2 0x08
87 
93 #define AUDIOAMP_DG_EN 0x10
94 #define AUDIOAMP_DG_CONT 0x08
95 #define AUDIOAMP_DG_RESET 0x06
96 #define AUDIOAMP_DG_ILIMIT 0x04
97  // End group macro
100 
109 typedef struct
110 {
111  // Input pins
112 
113  digital_in_t int_pin;
114 
115  // Modules
116 
117  i2c_master_t i2c;
118 
119  // ctx variable
120 
121  uint8_t slave_address;
122 
123 } audioamp_t;
124 
128 typedef struct
129 {
130  // Communication gpio pins
131 
132  pin_name_t scl;
133  pin_name_t sda;
134 
135  // Additional gpio pins
136 
137  pin_name_t int_pin;
138 
139  // Static variable
140 
141  uint32_t i2c_speed;
142  uint8_t i2c_address;
143 
145  // End types group
147 
153 #ifdef __cplusplus
154 extern "C"{
155 #endif
156 
166 
178 
191 
203 
217 err_t audioamp_set_volume ( audioamp_t *ctx, uint8_t in_sel, uint8_t volume_level );
218 
230 err_t audioamp_mute ( audioamp_t *ctx );
231 
244 
257 
274 err_t audioamp_set_fault_detecton_control ( audioamp_t *ctx, uint8_t input_command );
275 
288 err_t audioamp_set_diagnostic_control ( audioamp_t *ctx, uint8_t input_command );
289 
301 
302 #ifdef __cplusplus
303 }
304 #endif
305 #endif // AUDIOAMP_H
306  // End public_function group // End click Driver group
309 
310 // ------------------------------------------------------------------------ END
audioamp_set_fault_detecton_control
err_t audioamp_set_fault_detecton_control(audioamp_t *ctx, uint8_t input_command)
Set fault detection control function.
audioamp_init
err_t audioamp_init(audioamp_t *ctx, audioamp_cfg_t *cfg)
Initialization function.
audioamp_cfg_setup
void audioamp_cfg_setup(audioamp_cfg_t *cfg)
Config Object Initialization function.
audioamp_t
Click ctx object definition.
Definition: audioamp.h:110
audioamp_cfg_t::scl
pin_name_t scl
Definition: audioamp.h:132
audioamp_mute
err_t audioamp_mute(audioamp_t *ctx)
Mute input function.
audioamp_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: audioamp.h:141
audioamp_cfg_t::i2c_address
uint8_t i2c_address
Definition: audioamp.h:142
audioamp_cfg_t
Click configuration structure definition.
Definition: audioamp.h:129
audioamp_power_off
err_t audioamp_power_off(audioamp_t *ctx)
Turn off the Audio Amp click function.
audioamp_cfg_t::int_pin
pin_name_t int_pin
Definition: audioamp.h:137
audioamp_set_volume
err_t audioamp_set_volume(audioamp_t *ctx, uint8_t in_sel, uint8_t volume_level)
Set volume function.
audioamp_check_fault
uint8_t audioamp_check_fault(audioamp_t *ctx)
Check Fault status function.
audioamp_set_diagnostic_control
err_t audioamp_set_diagnostic_control(audioamp_t *ctx, uint8_t input_command)
Set diagnostic control function.
audioamp_t::i2c
i2c_master_t i2c
Definition: audioamp.h:117
audioamp_cfg_t::sda
pin_name_t sda
Definition: audioamp.h:133
audioamp_unmute
err_t audioamp_unmute(audioamp_t *ctx)
Unmute input function.
audioamp_t::slave_address
uint8_t slave_address
Definition: audioamp.h:121
audioamp_t::int_pin
digital_in_t int_pin
Definition: audioamp.h:113
audioamp_set_fault_normal_operation
err_t audioamp_set_fault_normal_operation(audioamp_t *ctx)
Set normal opeation of Fault function.
audioamp_power_on
err_t audioamp_power_on(audioamp_t *ctx)
Turn on the Audio Amp click function.