audioamp2  2.0.0.0
audioamp2.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 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef AUDIOAMP2_H
36 #define AUDIOAMP2_H
37 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 
55 // -------------------------------------------------------------- PUBLIC MACROS
65 #define AUDIOAMP2_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.gn0= MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.gn1= MIKROBUS( mikrobus, MIKROBUS_RST ); \
68  cfg.stb= MIKROBUS( mikrobus, MIKROBUS_CS ); \
69  cfg.mute= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
70  cfg.dia= MIKROBUS( mikrobus, MIKROBUS_INT );
71 
77 #define AUDIOAMP2_RETVAL uint8_t
78 
79 #define AUDIOAMP2_OK 0x00
80 #define AUDIOAMP2_INIT_ERROR 0xFF
81 
87 #define AUDIOAMP2_STANDBY_MODE 0x00
88 #define AUDIOAMP2_MUTE_MODE 0x01
89 #define AUDIOAMP2_PLAY_MODE 0x02
90 
96 #define AUDIOAMP2_20DB_GAIN 0x00
97 #define AUDIOAMP2_26DB_GAIN 0x01
98 #define AUDIOAMP2_30DB_GAIN 0x02
99 #define AUDIOAMP2_32DB_GAIN 0x03
100  // End group macro
103 // --------------------------------------------------------------- PUBLIC TYPES
112 typedef struct
113 {
114  // Output pins
115 
116  digital_out_t gn0;
117  digital_out_t gn1;
118  digital_out_t stb;
119  digital_out_t mute;
120 
121  // Input pins
122 
123  digital_in_t dia;
124 
125 } audioamp2_t;
126 
130 typedef struct
131 {
132  // Additional gpio pins
133 
134  pin_name_t gn0;
135  pin_name_t gn1;
136  pin_name_t stb;
137  pin_name_t mute;
138  pin_name_t dia;
139 
141  // End types group
143 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
144 
150 #ifdef __cplusplus
151 extern "C"{
152 #endif
153 
163 
173 
184 uint8_t audioamp2_set_mode ( audioamp2_t *ctx, uint8_t sel_mode );
185 
196 uint8_t audioamp2_set_gain ( audioamp2_t *ctx, uint8_t sel_gain );
197 
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 #endif // _AUDIOAMP2_H_
213  // End public_function group
216 
217 // ------------------------------------------------------------------------- END
audioamp2_t::stb
digital_out_t stb
Definition: audioamp2.h:118
audioamp2_t::mute
digital_out_t mute
Definition: audioamp2.h:119
audioamp2_check_diagnostic
uint8_t audioamp2_check_diagnostic(audioamp2_t *ctx)
Diagnostic Check function.
audioamp2_cfg_t::gn1
pin_name_t gn1
Definition: audioamp2.h:135
audioamp2_cfg_setup
void audioamp2_cfg_setup(audioamp2_cfg_t *cfg)
Config Object Initialization function.
audioamp2_t::gn1
digital_out_t gn1
Definition: audioamp2.h:117
audioamp2_cfg_t::gn0
pin_name_t gn0
Definition: audioamp2.h:134
audioamp2_init
AUDIOAMP2_RETVAL audioamp2_init(audioamp2_t *ctx, audioamp2_cfg_t *cfg)
Initialization function.
audioamp2_set_gain
uint8_t audioamp2_set_gain(audioamp2_t *ctx, uint8_t sel_gain)
Gain Set function.
audioamp2_cfg_t::dia
pin_name_t dia
Definition: audioamp2.h:138
audioamp2_cfg_t
Click configuration structure definition.
Definition: audioamp2.h:131
audioamp2_t::gn0
digital_out_t gn0
Definition: audioamp2.h:116
audioamp2_set_mode
uint8_t audioamp2_set_mode(audioamp2_t *ctx, uint8_t sel_mode)
Mode Set function.
audioamp2_cfg_t::mute
pin_name_t mute
Definition: audioamp2.h:137
audioamp2_t::dia
digital_in_t dia
Definition: audioamp2.h:123
audioamp2_cfg_t::stb
pin_name_t stb
Definition: audioamp2.h:136
AUDIOAMP2_RETVAL
#define AUDIOAMP2_RETVAL
Definition: audioamp2.h:77
audioamp2_t
Click ctx object definition.
Definition: audioamp2.h:113