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 "drv_digital_in.h"
38 #include "drv_i2c_master.h"
39 
49 #define AUDIOAMP_MAP_MIKROBUS( cfg, mikrobus ) \
50  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
51  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
52  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
53 
59 #define AUDIOAMP_OK 0
60 #define AUDIOAMP_INIT_ERROR (-1)
61 
67 #define AUDIOAMP_I2C_ADDRESS_0 0x7C
68 #define AUDIOAMP_I2C_ADDRESS_1 0x7D
69 
75 #define AUDIOAMP_IN_1 0x04
76 #define AUDIOAMP_IN_2 0x08
77 
83 #define AUDIOAMP_DG_EN 0x10
84 #define AUDIOAMP_DG_CONT 0x08
85 #define AUDIOAMP_DG_RESET 0x06
86 #define AUDIOAMP_DG_ILIMIT 0x04
87  // End group macro
90 
99 typedef struct
100 {
101  // Input pins
102 
103  digital_in_t int_pin;
104 
105  // Modules
106 
107  i2c_master_t i2c;
108 
109  // ctx variable
110 
111  uint8_t slave_address;
112 
113 } audioamp_t;
114 
118 typedef struct
119 {
120  // Communication gpio pins
121 
122  pin_name_t scl;
123  pin_name_t sda;
124 
125  // Additional gpio pins
126 
127  pin_name_t int_pin;
128 
129  // Static variable
130 
131  uint32_t i2c_speed;
132  uint8_t i2c_address;
133 
135  // End types group
137 
143 #ifdef __cplusplus
144 extern "C"{
145 #endif
146 
155 void audioamp_cfg_setup ( audioamp_cfg_t *cfg );
156 
167 err_t audioamp_init ( audioamp_t *ctx, audioamp_cfg_t *cfg );
168 
180 err_t audioamp_power_on ( audioamp_t *ctx );
181 
192 err_t audioamp_power_off ( audioamp_t *ctx );
193 
207 err_t audioamp_set_volume ( audioamp_t *ctx, uint8_t in_sel, uint8_t volume_level );
208 
220 err_t audioamp_mute ( audioamp_t *ctx );
221 
233 err_t audioamp_unmute ( audioamp_t *ctx );
234 
247 
264 err_t audioamp_set_fault_detecton_control ( audioamp_t *ctx, uint8_t input_command );
265 
278 err_t audioamp_set_diagnostic_control ( audioamp_t *ctx, uint8_t input_command );
279 
290 uint8_t audioamp_check_fault ( audioamp_t *ctx );
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 #endif // AUDIOAMP_H
296  // End public_function group // End click Driver group
299 
300 // ------------------------------------------------------------------------ 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:99
audioamp_cfg_t::scl
pin_name_t scl
Definition: audioamp.h:122
audioamp_mute
err_t audioamp_mute(audioamp_t *ctx)
Mute input function.
audioamp_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: audioamp.h:131
audioamp_cfg_t::i2c_address
uint8_t i2c_address
Definition: audioamp.h:132
audioamp_cfg_t
Click configuration structure definition.
Definition: audioamp.h:118
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:127
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:107
audioamp_cfg_t::sda
pin_name_t sda
Definition: audioamp.h:123
audioamp_unmute
err_t audioamp_unmute(audioamp_t *ctx)
Unmute input function.
audioamp_t::slave_address
uint8_t slave_address
Definition: audioamp.h:111
audioamp_t::int_pin
digital_in_t int_pin
Definition: audioamp.h:103
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.