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
32extern "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_spi_master.h"
51
68#define VOLUME_ZCE_DISABLE 0x00
69#define VOLUME_ZCE_ENABLE 0x01
70
71 // zce_state
72
83#define VOLUME_MUTE_ENABLE 0x00
84#define VOLUME_MUTE_DISABLE 0x01
85
86 // mute_state
87
88
103#define VOLUME_MAP_MIKROBUS( cfg, mikrobus ) \
104 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
105 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
106 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
107 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
108 cfg.zce = MIKROBUS( mikrobus, MIKROBUS_AN ); \
109 cfg.sen = MIKROBUS( mikrobus, MIKROBUS_PWM )
110
111 // volume_map
112 // volume
113
118typedef struct
119{
120 // Output pins
121
122 digital_out_t zce;
123 digital_out_t sen;
125 // Modules
126
127 spi_master_t spi;
129 pin_name_t chip_select;
131} volume_t;
132
137typedef struct
138{
139 // Communication gpio pins
140
141 pin_name_t miso;
142 pin_name_t mosi;
143 pin_name_t sck;
144 pin_name_t cs;
146 // Additional gpio pins
147
148 pin_name_t zce;
149 pin_name_t sen;
151 // static variable
152
153 uint32_t spi_speed;
154 spi_master_mode_t spi_mode;
155 spi_master_chip_select_polarity_t cs_polarity;
158
175
190err_t volume_init ( volume_t *ctx, volume_cfg_t *cfg );
191
203
214
225void volume_hw_mute ( volume_t *ctx, uint8_t mute_state );
226
237void volume_zero_crossing ( volume_t *ctx, uint8_t zce_state );
238
251err_t volume_set_vol_gain ( volume_t *ctx, float volume_left_dB, float volume_right_dB );
252
253#ifdef __cplusplus
254}
255#endif
256#endif // VOLUME_H
257
258 // volume
259
260// ------------------------------------------------------------------------ END
void volume_power_up(volume_t *ctx)
Power Up function.
err_t volume_set_vol_gain(volume_t *ctx, float volume_left_dB, float volume_right_dB)
Set volume gain function.
void volume_cfg_setup(volume_cfg_t *cfg)
Volume configuration object setup function.
void volume_zero_crossing(volume_t *ctx, uint8_t zce_state)
Zero Crossing option function.
void volume_hw_mute(volume_t *ctx, uint8_t mute_state)
Hardware MUTE function.
void volume_default_cfg(volume_t *ctx)
Volume default configuration function.
err_t volume_init(volume_t *ctx, volume_cfg_t *cfg)
Volume initialization function.
Volume Click configuration object.
Definition volume.h:138
pin_name_t zce
Definition volume.h:148
spi_master_chip_select_polarity_t cs_polarity
Definition volume.h:155
pin_name_t sck
Definition volume.h:143
spi_master_mode_t spi_mode
Definition volume.h:154
pin_name_t mosi
Definition volume.h:142
uint32_t spi_speed
Definition volume.h:153
pin_name_t miso
Definition volume.h:141
pin_name_t sen
Definition volume.h:149
pin_name_t cs
Definition volume.h:144
Volume Click context object.
Definition volume.h:119
spi_master_t spi
Definition volume.h:127
digital_out_t sen
Definition volume.h:123
digital_out_t zce
Definition volume.h:122
pin_name_t chip_select
Definition volume.h:129