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 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define HEADPHONEAMP2_VOL_MUTE 0x00
70 #define HEADPHONEAMP2_VOL_LVL_1 0x01
71 #define HEADPHONEAMP2_VOL_LVL_2 0x02
72 #define HEADPHONEAMP2_VOL_LVL_3 0x03
73 #define HEADPHONEAMP2_VOL_LVL_4 0x04
74 #define HEADPHONEAMP2_VOL_LVL_5 0x05
75 #define HEADPHONEAMP2_VOL_LVL_6 0x06
76 #define HEADPHONEAMP2_VOL_LVL_7 0x07
77 #define HEADPHONEAMP2_VOL_LVL_8 0x08
78 #define HEADPHONEAMP2_VOL_LVL_9 0x09
79 #define HEADPHONEAMP2_VOL_LVL_10 0x0A
80 #define HEADPHONEAMP2_VOL_LVL_11 0x0B
81 #define HEADPHONEAMP2_VOL_LVL_12 0x0C
82 #define HEADPHONEAMP2_VOL_LVL_13 0x0D
83 #define HEADPHONEAMP2_VOL_LVL_14 0x0E
84 #define HEADPHONEAMP2_VOL_LVL_MAX 0x0F
85 
91 #define HEADPHONEAMP2_DEVICE_ADDRESS 0x4C
92  // headphoneamp2_set
94 
109 #define HEADPHONEAMP2_MAP_MIKROBUS( cfg, mikrobus ) \
110  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
111  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
112  cfg.shd = MIKROBUS( mikrobus, MIKROBUS_PWM )
113  // headphoneamp2_map // headphoneamp2
116 
121 typedef struct
122 {
123  // Output pins
124  digital_out_t shd;
126  // Modules
127  i2c_master_t i2c;
129  // I2C slave address
130  uint8_t slave_address;
133 
138 typedef struct
139 {
140  pin_name_t scl;
141  pin_name_t sda;
143  pin_name_t shd;
145  uint32_t i2c_speed;
146  uint8_t i2c_address;
149 
154 typedef enum
155 {
158 
160 
165 typedef struct
166 {
170  uint8_t volume;
173 
178 typedef enum
179 {
182 
184 
201 
216 
230 
242 err_t headphoneamp2_write_data ( headphoneamp2_t *ctx, uint8_t data_in );
243 
255 
267 
283 
284 #ifdef __cplusplus
285 }
286 #endif
287 #endif // HEADPHONEAMP2_H
288  // headphoneamp2
290 
291 // ------------------------------------------------------------------------ END
HEADPHONEAMP2_ERROR
@ HEADPHONEAMP2_ERROR
Definition: headphoneamp2.h:181
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:143
headphoneamp2_disable
void headphoneamp2_disable(headphoneamp2_t *ctx)
Headphone AMP 2 disable the device function.
HEADPHONEAMP2_CMD_DISABLE
@ HEADPHONEAMP2_CMD_DISABLE
Definition: headphoneamp2.h:156
headphoneamp2_t::shd
digital_out_t shd
Definition: headphoneamp2.h:124
headphoneamp2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: headphoneamp2.h:145
headphoneamp2_cfg_t::i2c_address
uint8_t i2c_address
Definition: headphoneamp2.h:146
headphoneamp2_cmd_t::bass_max
headphoneamp2_cmd_ctrl_value_t bass_max
Definition: headphoneamp2.h:168
headphoneamp2_cmd_t
Headphone AMP 2 Click command object.
Definition: headphoneamp2.h:166
headphoneamp2_cfg_t
Headphone AMP 2 Click configuration object.
Definition: headphoneamp2.h:139
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:179
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:155
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:130
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:180
headphoneamp2_cmd_t::gain_max
headphoneamp2_cmd_ctrl_value_t gain_max
Definition: headphoneamp2.h:169
headphoneamp2_cfg_t::scl
pin_name_t scl
Definition: headphoneamp2.h:140
HEADPHONEAMP2_CMD_ENABLE
@ HEADPHONEAMP2_CMD_ENABLE
Definition: headphoneamp2.h:157
headphoneamp2_cmd_t::volume
uint8_t volume
Definition: headphoneamp2.h:170
headphoneamp2_cmd_t::wakes_up
headphoneamp2_cmd_ctrl_value_t wakes_up
Definition: headphoneamp2.h:167
headphoneamp2_t::i2c
i2c_master_t i2c
Definition: headphoneamp2.h:127
headphoneamp2_cfg_t::sda
pin_name_t sda
Definition: headphoneamp2.h:141
headphoneamp2_t
Headphone AMP 2 Click context object.
Definition: headphoneamp2.h:122