c2x5wamp  2.0.0.0
c2x5wamp.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef C2X5WAMP_H
36 #define C2X5WAMP_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 C2X5WAMP_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 C2X5WAMP_RETVAL uint8_t
74 
75 #define C2X5WAMP_OK 0x00
76 #define C2X5WAMP_INIT_ERROR 0xFF
77 
83 #define C2X5WAMP_MODE_STANDBY 0x00
84 #define C2X5WAMP_MODE_MUTE 0x01
85 #define C2X5WAMP_MODE_PLAY 0x02
86 
92 #define C2X5WAMP_GAIN_20DB 0x00
93 #define C2X5WAMP_GAIN_26DB 0x01
94 #define C2X5WAMP_GAIN_30DB 0x02
95 #define C2X5WAMP_GAIN_32DB 0x03
96 
102 #define C2X5WAMP_RESULT_ERROR 0x00
103 #define C2X5WAMP_RESULT_OK 0x01
104  // End group macro
107 // --------------------------------------------------------------- PUBLIC TYPES
116 typedef struct
117 {
118  // Output pins
119 
120  digital_out_t gn0;
121  digital_out_t gn1;
122  digital_out_t stb;
123  digital_out_t mute;
124 
125  // Input pins
126 
127  digital_in_t dia;
128 
129 } c2x5wamp_t;
130 
134 typedef struct
135 {
136  // Additional gpio pins
137 
138  pin_name_t gn0;
139  pin_name_t gn1;
140  pin_name_t stb;
141  pin_name_t mute;
142  pin_name_t dia;
143 
145  // End types group
147 // ------------------------------------------------------------------ CONSTANTS // End constants group
156 // ------------------------------------------------------------------ VARIABLES // End variable group
164 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
165 
171 #ifdef __cplusplus
172 extern "C"{
173 #endif
174 
184 
193 
205 
223 uint8_t c2x5wamp_set_mode ( c2x5wamp_t *ctx, uint8_t select_mode );
224 
242 uint8_t c2x5wamp_set_gain ( c2x5wamp_t *ctx, uint8_t select_gain );
243 
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 #endif // _C2X5WAMP_H_
263  // End public_function group
266 
267 // ------------------------------------------------------------------------- END
c2x5wamp_cfg_setup
void c2x5wamp_cfg_setup(c2x5wamp_cfg_t *cfg)
Config Object Initialization function.
c2x5wamp_cfg_t::mute
pin_name_t mute
Definition: c2x5wamp.h:141
c2x5wamp_t
Click ctx object definition.
Definition: c2x5wamp.h:117
c2x5wamp_t::mute
digital_out_t mute
Definition: c2x5wamp.h:123
c2x5wamp_t::gn0
digital_out_t gn0
Definition: c2x5wamp.h:120
c2x5wamp_set_gain
uint8_t c2x5wamp_set_gain(c2x5wamp_t *ctx, uint8_t select_gain)
Set gain resistors of the amplifier function.
c2x5wamp_check_input
uint8_t c2x5wamp_check_input(c2x5wamp_t *ctx)
Check input impedance function.
c2x5wamp_cfg_t::gn1
pin_name_t gn1
Definition: c2x5wamp.h:139
c2x5wamp_t::gn1
digital_out_t gn1
Definition: c2x5wamp.h:121
c2x5wamp_t::dia
digital_in_t dia
Definition: c2x5wamp.h:127
c2x5wamp_cfg_t::dia
pin_name_t dia
Definition: c2x5wamp.h:142
c2x5wamp_init
C2X5WAMP_RETVAL c2x5wamp_init(c2x5wamp_t *ctx, c2x5wamp_cfg_t *cfg)
Initialization function.
c2x5wamp_cfg_t
Click configuration structure definition.
Definition: c2x5wamp.h:135
C2X5WAMP_RETVAL
#define C2X5WAMP_RETVAL
Definition: c2x5wamp.h:73
c2x5wamp_default_cfg
void c2x5wamp_default_cfg(c2x5wamp_t *ctx)
Click Default Configuration function.
c2x5wamp_t::stb
digital_out_t stb
Definition: c2x5wamp.h:122
c2x5wamp_set_mode
uint8_t c2x5wamp_set_mode(c2x5wamp_t *ctx, uint8_t select_mode)
Set mode selection of the amplifier function.
c2x5wamp_cfg_t::stb
pin_name_t stb
Definition: c2x5wamp.h:140
c2x5wamp_cfg_t::gn0
pin_name_t gn0
Definition: c2x5wamp.h:138