headphoneamp2  2.1.0.0
headphoneamp2.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 HEADPHONEAMP2_H
29 #define HEADPHONEAMP2_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 #include "drv_i2c_master.h"
52 
73 #define HEADPHONEAMP2_VOL_MUTE 0x00
74 #define HEADPHONEAMP2_VOL_LVL_1 0x01
75 #define HEADPHONEAMP2_VOL_LVL_2 0x02
76 #define HEADPHONEAMP2_VOL_LVL_3 0x03
77 #define HEADPHONEAMP2_VOL_LVL_4 0x04
78 #define HEADPHONEAMP2_VOL_LVL_5 0x05
79 #define HEADPHONEAMP2_VOL_LVL_6 0x06
80 #define HEADPHONEAMP2_VOL_LVL_7 0x07
81 #define HEADPHONEAMP2_VOL_LVL_8 0x08
82 #define HEADPHONEAMP2_VOL_LVL_9 0x09
83 #define HEADPHONEAMP2_VOL_LVL_10 0x0A
84 #define HEADPHONEAMP2_VOL_LVL_11 0x0B
85 #define HEADPHONEAMP2_VOL_LVL_12 0x0C
86 #define HEADPHONEAMP2_VOL_LVL_13 0x0D
87 #define HEADPHONEAMP2_VOL_LVL_14 0x0E
88 #define HEADPHONEAMP2_VOL_LVL_MAX 0x0F
89 
95 #define HEADPHONEAMP2_DEVICE_ADDRESS 0x4C
96  // headphoneamp2_set
98 
113 #define HEADPHONEAMP2_MAP_MIKROBUS( cfg, mikrobus ) \
114  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
115  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
116  cfg.shd = MIKROBUS( mikrobus, MIKROBUS_PWM )
117  // headphoneamp2_map // headphoneamp2
120 
125 typedef struct
126 {
127  // Output pins
128  digital_out_t shd;
130  // Modules
131  i2c_master_t i2c;
133  // I2C slave address
134  uint8_t slave_address;
137 
142 typedef struct
143 {
144  pin_name_t scl;
145  pin_name_t sda;
147  pin_name_t shd;
149  uint32_t i2c_speed;
150  uint8_t i2c_address;
153 
158 typedef enum
159 {
162 
164 
169 typedef struct
170 {
174  uint8_t volume;
177 
182 typedef enum
183 {
186 
188 
205 
220 
234 
246 err_t headphoneamp2_write_data ( headphoneamp2_t *ctx, uint8_t data_in );
247 
259 
271 
287 
288 #ifdef __cplusplus
289 }
290 #endif
291 #endif // HEADPHONEAMP2_H
292  // headphoneamp2
294 
295 // ------------------------------------------------------------------------ END
HEADPHONEAMP2_ERROR
@ HEADPHONEAMP2_ERROR
Definition: headphoneamp2.h:185
headphoneamp2_default_cfg
err_t headphoneamp2_default_cfg(headphoneamp2_t *ctx)
Headphone AMP 2 default configuration function.
headphoneamp2_cfg_t::shd
pin_name_t shd
Definition: headphoneamp2.h:147
headphoneamp2_disable
void headphoneamp2_disable(headphoneamp2_t *ctx)
Headphone AMP 2 disable the device function.
HEADPHONEAMP2_CMD_DISABLE
@ HEADPHONEAMP2_CMD_DISABLE
Definition: headphoneamp2.h:160
headphoneamp2_t::shd
digital_out_t shd
Definition: headphoneamp2.h:128
headphoneamp2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: headphoneamp2.h:149
headphoneamp2_cfg_t::i2c_address
uint8_t i2c_address
Definition: headphoneamp2.h:150
headphoneamp2_cmd_t::bass_max
headphoneamp2_cmd_ctrl_value_t bass_max
Definition: headphoneamp2.h:172
headphoneamp2_cmd_t
Headphone AMP 2 Click command object.
Definition: headphoneamp2.h:170
headphoneamp2_cfg_t
Headphone AMP 2 Click configuration object.
Definition: headphoneamp2.h:143
headphoneamp2_enable
void headphoneamp2_enable(headphoneamp2_t *ctx)
Headphone AMP 2 enable the device function.
headphoneamp2_return_value_t
headphoneamp2_return_value_t
Headphone AMP 2 Click return value data.
Definition: headphoneamp2.h:183
headphoneamp2_cfg_setup
void headphoneamp2_cfg_setup(headphoneamp2_cfg_t *cfg)
Headphone AMP 2 configuration object setup function.
headphoneamp2_init
err_t headphoneamp2_init(headphoneamp2_t *ctx, headphoneamp2_cfg_t *cfg)
Headphone AMP 2 initialization function.
headphoneamp2_cmd_ctrl_value_t
headphoneamp2_cmd_ctrl_value_t
Headphone AMP 2 Click command mode control value data.
Definition: headphoneamp2.h:159
headphoneamp2_write_data
err_t headphoneamp2_write_data(headphoneamp2_t *ctx, uint8_t data_in)
Headphone AMP 2 I2C writing function.
headphoneamp2_t::slave_address
uint8_t slave_address
Definition: headphoneamp2.h:134
headphoneamp2_set_command
err_t headphoneamp2_set_command(headphoneamp2_t *ctx, headphoneamp2_cmd_t cmd_ctrl)
Headphone AMP 2 set the command function.
HEADPHONEAMP2_OK
@ HEADPHONEAMP2_OK
Definition: headphoneamp2.h:184
headphoneamp2_cmd_t::gain_max
headphoneamp2_cmd_ctrl_value_t gain_max
Definition: headphoneamp2.h:173
headphoneamp2_cfg_t::scl
pin_name_t scl
Definition: headphoneamp2.h:144
HEADPHONEAMP2_CMD_ENABLE
@ HEADPHONEAMP2_CMD_ENABLE
Definition: headphoneamp2.h:161
headphoneamp2_cmd_t::volume
uint8_t volume
Definition: headphoneamp2.h:174
headphoneamp2_cmd_t::wakes_up
headphoneamp2_cmd_ctrl_value_t wakes_up
Definition: headphoneamp2.h:171
headphoneamp2_t::i2c
i2c_master_t i2c
Definition: headphoneamp2.h:131
headphoneamp2_cfg_t::sda
pin_name_t sda
Definition: headphoneamp2.h:145
headphoneamp2_t
Headphone AMP 2 Click context object.
Definition: headphoneamp2.h:126