headphoneamp  2.0.0.0
headphoneamp.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef HEADPHONEAMP_H
29 #define HEADPHONEAMP_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
48 
49 
65 #define HEADPHONEAMP_SOUND_VOLUME_NEG_33_dB 0
66 #define HEADPHONEAMP_SOUND_VOLUME_NEG_30_dB 1
67 #define HEADPHONEAMP_SOUND_VOLUME_NEG_27_dB 2
68 #define HEADPHONEAMP_SOUND_VOLUME_NEG_24_dB 3
69 #define HEADPHONEAMP_SOUND_VOLUME_NEG_21_dB 4
70 #define HEADPHONEAMP_SOUND_VOLUME_NEG_18_dB 5
71 #define HEADPHONEAMP_SOUND_VOLUME_NEG_15_dB 6
72 #define HEADPHONEAMP_SOUND_VOLUME_NEG_12_dB 7
73 #define HEADPHONEAMP_SOUND_VOLUME_NEG_9_dB 8
74 #define HEADPHONEAMP_SOUND_VOLUME_NEG_6_dB 9
75 #define HEADPHONEAMP_SOUND_VOLUME_NEG_3_dB 10
76 #define HEADPHONEAMP_SOUND_VOLUME_NEG_0_dB 11
77 #define HEADPHONEAMP_SOUND_VOLUME_POS_3_dB 12
78 #define HEADPHONEAMP_SOUND_VOLUME_POS_6_dB 13
79 #define HEADPHONEAMP_SOUND_VOLUME_POS_9_dB 14
80 #define HEADPHONEAMP_SOUND_VOLUME_POS_12_dB 15
81  // headphoneamp_set
83 
98 #define HEADPHONEAMP_MAP_MIKROBUS( cfg, mikrobus ) \
99  cfg.shdn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
100  cfg.clk = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
101  cfg.ud = MIKROBUS( mikrobus, MIKROBUS_INT )
102  // headphoneamp_map // headphoneamp
105 
110 typedef struct
111 {
112  digital_out_t shdn;
113  digital_out_t clk;
114  digital_out_t ud;
117 
122 typedef struct
123 {
124  pin_name_t shdn;
125  pin_name_t clk;
126  pin_name_t ud;
129 
134 typedef enum
135 {
137  HEADPHONEAMP_ERROR = -1
138 
140 
157 
173 
188 
204 
219 
235 
251 
267 err_t headphoneamp_set_sound_volume ( headphoneamp_t *ctx, uint8_t sound_volume );
268 
269 #ifdef __cplusplus
270 }
271 #endif
272 #endif // HEADPHONEAMP_H
273  // headphoneamp
275 
276 // ------------------------------------------------------------------------ END
headphoneamp_cfg_t::ud
pin_name_t ud
Definition: headphoneamp.h:126
headphoneamp_t::clk
digital_out_t clk
Definition: headphoneamp.h:113
headphoneamp_cfg_t::clk
pin_name_t clk
Definition: headphoneamp.h:125
headphoneamp_set_sound_volume
err_t headphoneamp_set_sound_volume(headphoneamp_t *ctx, uint8_t sound_volume)
Headphone AMP set sound volume function.
headphoneamp_cfg_t
Headphone AMP Click configuration object.
Definition: headphoneamp.h:123
headphoneamp_volume_up
err_t headphoneamp_volume_up(headphoneamp_t *ctx)
Headphone AMP set sound volume up function.
headphoneamp_t::ud
digital_out_t ud
Definition: headphoneamp.h:114
HEADPHONEAMP_ERROR
@ HEADPHONEAMP_ERROR
Definition: headphoneamp.h:137
headphoneamp_init
err_t headphoneamp_init(headphoneamp_t *ctx, headphoneamp_cfg_t *cfg)
Headphone AMP initialization function.
HEADPHONEAMP_OK
@ HEADPHONEAMP_OK
Definition: headphoneamp.h:136
headphoneamp_default_cfg
err_t headphoneamp_default_cfg(headphoneamp_t *ctx)
Headphone AMP default configuration function.
headphoneamp_return_value_t
headphoneamp_return_value_t
Headphone AMP Click return value data.
Definition: headphoneamp.h:135
headphoneamp_power_up
err_t headphoneamp_power_up(headphoneamp_t *ctx)
Headphone AMP power up function.
headphoneamp_t::shdn
digital_out_t shdn
Definition: headphoneamp.h:112
headphoneamp_volume_down
err_t headphoneamp_volume_down(headphoneamp_t *ctx)
Headphone AMP set sound volume down function.
headphoneamp_shutdown
err_t headphoneamp_shutdown(headphoneamp_t *ctx)
Headphone AMP shutdown function.
headphoneamp_cfg_setup
void headphoneamp_cfg_setup(headphoneamp_cfg_t *cfg)
Headphone AMP configuration object setup function.
headphoneamp_t
Headphone AMP Click context object.
Definition: headphoneamp.h:111
headphoneamp_cfg_t::shdn
pin_name_t shdn
Definition: headphoneamp.h:124