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 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 
52 
53 
69 #define HEADPHONEAMP_SOUND_VOLUME_NEG_33_dB 0
70 #define HEADPHONEAMP_SOUND_VOLUME_NEG_30_dB 1
71 #define HEADPHONEAMP_SOUND_VOLUME_NEG_27_dB 2
72 #define HEADPHONEAMP_SOUND_VOLUME_NEG_24_dB 3
73 #define HEADPHONEAMP_SOUND_VOLUME_NEG_21_dB 4
74 #define HEADPHONEAMP_SOUND_VOLUME_NEG_18_dB 5
75 #define HEADPHONEAMP_SOUND_VOLUME_NEG_15_dB 6
76 #define HEADPHONEAMP_SOUND_VOLUME_NEG_12_dB 7
77 #define HEADPHONEAMP_SOUND_VOLUME_NEG_9_dB 8
78 #define HEADPHONEAMP_SOUND_VOLUME_NEG_6_dB 9
79 #define HEADPHONEAMP_SOUND_VOLUME_NEG_3_dB 10
80 #define HEADPHONEAMP_SOUND_VOLUME_NEG_0_dB 11
81 #define HEADPHONEAMP_SOUND_VOLUME_POS_3_dB 12
82 #define HEADPHONEAMP_SOUND_VOLUME_POS_6_dB 13
83 #define HEADPHONEAMP_SOUND_VOLUME_POS_9_dB 14
84 #define HEADPHONEAMP_SOUND_VOLUME_POS_12_dB 15
85  // headphoneamp_set
87 
102 #define HEADPHONEAMP_MAP_MIKROBUS( cfg, mikrobus ) \
103  cfg.shdn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
104  cfg.clk = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
105  cfg.ud = MIKROBUS( mikrobus, MIKROBUS_INT )
106  // headphoneamp_map // headphoneamp
109 
114 typedef struct
115 {
116  digital_out_t shdn;
117  digital_out_t clk;
118  digital_out_t ud;
121 
126 typedef struct
127 {
128  pin_name_t shdn;
129  pin_name_t clk;
130  pin_name_t ud;
133 
138 typedef enum
139 {
141  HEADPHONEAMP_ERROR = -1
142 
144 
161 
177 
192 
208 
223 
239 
255 
271 err_t headphoneamp_set_sound_volume ( headphoneamp_t *ctx, uint8_t sound_volume );
272 
273 #ifdef __cplusplus
274 }
275 #endif
276 #endif // HEADPHONEAMP_H
277  // headphoneamp
279 
280 // ------------------------------------------------------------------------ END
headphoneamp_cfg_t::ud
pin_name_t ud
Definition: headphoneamp.h:130
headphoneamp_t::clk
digital_out_t clk
Definition: headphoneamp.h:117
headphoneamp_cfg_t::clk
pin_name_t clk
Definition: headphoneamp.h:129
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:127
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:118
HEADPHONEAMP_ERROR
@ HEADPHONEAMP_ERROR
Definition: headphoneamp.h:141
headphoneamp_init
err_t headphoneamp_init(headphoneamp_t *ctx, headphoneamp_cfg_t *cfg)
Headphone AMP initialization function.
HEADPHONEAMP_OK
@ HEADPHONEAMP_OK
Definition: headphoneamp.h:140
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:139
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:116
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:115
headphoneamp_cfg_t::shdn
pin_name_t shdn
Definition: headphoneamp.h:128