evc 2.0.0.0
evc.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef EVC_H
36#define EVC_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define EVC_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define EVC_RETVAL uint8_t
76
77#define EVC_OK 0x00
78#define EVC_INIT_ERROR 0xFF
85#define EVC_SET_VOLUME_1dB 0x11
86#define EVC_SET_VOLUME_10dB 0x01
87#define EVC_SET_VOLUME_20dB 0x02
88#define EVC_SET_VOLUME_2dB 0x12
89#define EVC_SET_VOLUME_30dB 0x03
90#define EVC_SET_VOLUME_3dB 0x13
91#define EVC_SET_VOLUME_40dB 0x04
92#define EVC_SET_VOLUME_4dB 0x14
93#define EVC_SET_VOLUME_50dB 0x05
94#define EVC_SET_VOLUME_5dB 0x15
95#define EVC_SET_VOLUME_60dB 0x06
96#define EVC_SET_VOLUME_6dB 0x16
97#define EVC_SET_VOLUME_70dB 0x07
98#define EVC_SET_VOLUME_7dB 0x17
99#define EVC_SET_VOLUME_0dB 0x00
100#define EVC_SET_VOLUME_8dB 0x18
101#define EVC_SET_VOLUME_9dB 0x19
108#define EVC_CHANNEL_1 0x80
109#define EVC_CHANNEL_2 0x40
110#define EVC_CHANNEL_3 0x00
111#define EVC_CHANNEL_4 0x20
112#define EVC_CHANNEL_5 0x60
113#define EVC_CHANNEL_6 0xA0
114#define EVC_ALL_CHANNEL 0xC0
121#define EVC_ALL_CHANNEL_MUTE 0xF9
122#define EVC_ALL_CHANNEL_UNMUTE 0xF8
129#define EVC_CLEAR_ALL 0xC0
136#define EVC_DEVICE_SLAVE_ADDRESS_01 0x42
137#define EVC_DEVICE_SLAVE_ADDRESS_00 0x40
138#define EVC_DEVICE_SLAVE_ADDRESS_10 0x44
139#define EVC_DEVICE_SLAVE_ADDRESS_11 0x46
142 // End group macro
143// --------------------------------------------------------------- PUBLIC TYPES
152typedef struct
153{
154 // Modules
155
156 i2c_master_t i2c;
157
158 // ctx variable
159
161 uint8_t mute_flag;
162 uint8_t play_flag;
163 int8_t volume;
164 uint8_t channel;
165 uint8_t test_flag;
166
167} evc_t;
168
172typedef struct
173{
174 // Communication gpio pins
175
176 pin_name_t scl;
177 pin_name_t sda;
178
179 // static variable
180
181 uint32_t i2c_speed;
182 uint8_t i2c_address;
186 uint8_t cfg_channel;
188
189} evc_cfg_t;
190
191 // End types group
192// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
193
199#ifdef __cplusplus
200extern "C"{
201#endif
202
212
222
232void evc_default_cfg ( evc_t *ctx );
233
244void evc_generic_write ( evc_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
245
256void evc_generic_read ( evc_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
257
268void evc_set_volume_part ( evc_t *ctx, uint8_t channel, uint8_t volume1, uint8_t volume2 );
269
279void evc_set_volume_full ( evc_t *ctx, uint8_t channel, int8_t volume );
280
292void evc_clear ( evc_t *ctx );
293
302void evc_mute ( evc_t *ctx, uint8_t mute );
303
304#ifdef __cplusplus
305}
306#endif
307#endif // _EVC_H_
308
309 // End public_function group
311
312// ------------------------------------------------------------------------- END
#define EVC_RETVAL
Definition evc.h:75
void evc_set_volume_full(evc_t *ctx, uint8_t channel, int8_t volume)
Set volume for the channel.
void evc_cfg_setup(evc_cfg_t *cfg)
Config Object Initialization function.
EVC_RETVAL evc_init(evc_t *ctx, evc_cfg_t *cfg)
Initialization function.
void evc_generic_write(evc_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void evc_generic_read(evc_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void evc_default_cfg(evc_t *ctx)
Click Default Configuration function.
void evc_clear(evc_t *ctx)
Clear register.
void evc_mute(evc_t *ctx, uint8_t mute)
Mute and Unmute.
void evc_set_volume_part(evc_t *ctx, uint8_t channel, uint8_t volume1, uint8_t volume2)
Set volume for the channel.
void mute(evc_t *ctx)
Definition main.c:84
Click configuration structure definition.
Definition evc.h:173
int8_t cfg_volume
Definition evc.h:185
uint8_t cfg_channel
Definition evc.h:186
uint32_t i2c_speed
Definition evc.h:181
pin_name_t scl
Definition evc.h:176
uint8_t play_cfg_flag
Definition evc.h:184
pin_name_t sda
Definition evc.h:177
uint8_t mute_cfg_flag
Definition evc.h:183
uint8_t test_cfg_flag
Definition evc.h:187
uint8_t i2c_address
Definition evc.h:182
Click ctx object definition.
Definition evc.h:153
int8_t volume
Definition evc.h:163
uint8_t test_flag
Definition evc.h:165
uint8_t channel
Definition evc.h:164
i2c_master_t i2c
Definition evc.h:156
uint8_t mute_flag
Definition evc.h:161
uint8_t slave_address
Definition evc.h:160
uint8_t play_flag
Definition evc.h:162