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 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define AUDIOAMP2_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.gn0= MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.gn1= MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.stb= MIKROBUS( mikrobus, MIKROBUS_CS ); \
65  cfg.mute= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
66  cfg.dia= MIKROBUS( mikrobus, MIKROBUS_INT );
67 
73 #define AUDIOAMP2_RETVAL uint8_t
74 
75 #define AUDIOAMP2_OK 0x00
76 #define AUDIOAMP2_INIT_ERROR 0xFF
77 
83 #define AUDIOAMP2_STANDBY_MODE 0x00
84 #define AUDIOAMP2_MUTE_MODE 0x01
85 #define AUDIOAMP2_PLAY_MODE 0x02
86 
92 #define AUDIOAMP2_20DB_GAIN 0x00
93 #define AUDIOAMP2_26DB_GAIN 0x01
94 #define AUDIOAMP2_30DB_GAIN 0x02
95 #define AUDIOAMP2_32DB_GAIN 0x03
96  // End group macro
99 // --------------------------------------------------------------- PUBLIC TYPES
108 typedef struct
109 {
110  // Output pins
111 
112  digital_out_t gn0;
113  digital_out_t gn1;
114  digital_out_t stb;
115  digital_out_t mute;
116 
117  // Input pins
118 
119  digital_in_t dia;
120 
121 } audioamp2_t;
122 
126 typedef struct
127 {
128  // Additional gpio pins
129 
130  pin_name_t gn0;
131  pin_name_t gn1;
132  pin_name_t stb;
133  pin_name_t mute;
134  pin_name_t dia;
135 
137  // End types group
139 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
140 
146 #ifdef __cplusplus
147 extern "C"{
148 #endif
149 
159 
169 
180 uint8_t audioamp2_set_mode ( audioamp2_t *ctx, uint8_t sel_mode );
181 
192 uint8_t audioamp2_set_gain ( audioamp2_t *ctx, uint8_t sel_gain );
193 
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 #endif // _AUDIOAMP2_H_
209  // End public_function group
212 
213 // ------------------------------------------------------------------------- END
audioamp2_t::stb
digital_out_t stb
Definition: audioamp2.h:114
audioamp2_t::mute
digital_out_t mute
Definition: audioamp2.h:115
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:131
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:113
audioamp2_cfg_t::gn0
pin_name_t gn0
Definition: audioamp2.h:130
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:134
audioamp2_cfg_t
Click configuration structure definition.
Definition: audioamp2.h:127
audioamp2_t::gn0
digital_out_t gn0
Definition: audioamp2.h:112
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:133
audioamp2_t::dia
digital_in_t dia
Definition: audioamp2.h:119
audioamp2_cfg_t::stb
pin_name_t stb
Definition: audioamp2.h:132
AUDIOAMP2_RETVAL
#define AUDIOAMP2_RETVAL
Definition: audioamp2.h:73
audioamp2_t
Click ctx object definition.
Definition: audioamp2.h:109