volume  2.0.0.0
volume.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 VOLUME_H
29 #define VOLUME_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_spi_master.h"
37 
54 #define VOLUME_ZCE_DISABLE 0x00
55 #define VOLUME_ZCE_ENABLE 0x01
56  // zce_state
58 
69 #define VOLUME_MUTE_ENABLE 0x00
70 #define VOLUME_MUTE_DISABLE 0x01
71  // mute_state
73 
74 
89 #define VOLUME_MAP_MIKROBUS( cfg, mikrobus ) \
90  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
91  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
92  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
93  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
94  cfg.zce = MIKROBUS( mikrobus, MIKROBUS_AN ); \
95  cfg.sen = MIKROBUS( mikrobus, MIKROBUS_PWM )
96  // volume_map // volume
99 
104 typedef struct
105 {
106  // Output pins
107 
108  digital_out_t zce;
109  digital_out_t sen;
111  // Modules
112 
113  spi_master_t spi;
115  pin_name_t chip_select;
117 } volume_t;
118 
123 typedef struct
124 {
125  // Communication gpio pins
126 
127  pin_name_t miso;
128  pin_name_t mosi;
129  pin_name_t sck;
130  pin_name_t cs;
132  // Additional gpio pins
133 
134  pin_name_t zce;
135  pin_name_t sen;
137  // static variable
138 
139  uint32_t spi_speed;
140  spi_master_mode_t spi_mode;
141  spi_master_chip_select_polarity_t cs_polarity;
143 } volume_cfg_t;
144 
160 void volume_cfg_setup ( volume_cfg_t *cfg );
161 
176 err_t volume_init ( volume_t *ctx, volume_cfg_t *cfg );
177 
188 void volume_default_cfg ( volume_t *ctx );
189 
199 void volume_power_up ( volume_t *ctx );
200 
211 void volume_hw_mute ( volume_t *ctx, uint8_t mute_state );
212 
223 void volume_zero_crossing ( volume_t *ctx, uint8_t zce_state );
224 
237 err_t volume_set_vol_gain ( volume_t *ctx, float volume_left_dB, float volume_right_dB );
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 #endif // VOLUME_H
243  // volume
245 
246 // ------------------------------------------------------------------------ END
volume_power_up
void volume_power_up(volume_t *ctx)
Power Up function.
volume_zero_crossing
void volume_zero_crossing(volume_t *ctx, uint8_t zce_state)
Zero Crossing option function.
volume_set_vol_gain
err_t volume_set_vol_gain(volume_t *ctx, float volume_left_dB, float volume_right_dB)
Set volume gain function.
volume_default_cfg
void volume_default_cfg(volume_t *ctx)
Volume default configuration function.
volume_t
Volume Click context object.
Definition: volume.h:103
volume_cfg_setup
void volume_cfg_setup(volume_cfg_t *cfg)
Volume configuration object setup function.
volume_hw_mute
void volume_hw_mute(volume_t *ctx, uint8_t mute_state)
Hardware MUTE function.
volume_cfg_t
Volume Click configuration object.
Definition: volume.h:122
volume_init
err_t volume_init(volume_t *ctx, volume_cfg_t *cfg)
Volume initialization function.