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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define HEADPHONEAMP2_VOL_MUTE 0x00
60 #define HEADPHONEAMP2_VOL_LVL_1 0x01
61 #define HEADPHONEAMP2_VOL_LVL_2 0x02
62 #define HEADPHONEAMP2_VOL_LVL_3 0x03
63 #define HEADPHONEAMP2_VOL_LVL_4 0x04
64 #define HEADPHONEAMP2_VOL_LVL_5 0x05
65 #define HEADPHONEAMP2_VOL_LVL_6 0x06
66 #define HEADPHONEAMP2_VOL_LVL_7 0x07
67 #define HEADPHONEAMP2_VOL_LVL_8 0x08
68 #define HEADPHONEAMP2_VOL_LVL_9 0x09
69 #define HEADPHONEAMP2_VOL_LVL_10 0x0A
70 #define HEADPHONEAMP2_VOL_LVL_11 0x0B
71 #define HEADPHONEAMP2_VOL_LVL_12 0x0C
72 #define HEADPHONEAMP2_VOL_LVL_13 0x0D
73 #define HEADPHONEAMP2_VOL_LVL_14 0x0E
74 #define HEADPHONEAMP2_VOL_LVL_MAX 0x0F
75 
81 #define HEADPHONEAMP2_DEVICE_ADDRESS 0x4C
82  // headphoneamp2_set
84 
99 #define HEADPHONEAMP2_MAP_MIKROBUS( cfg, mikrobus ) \
100  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
101  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
102  cfg.shd = MIKROBUS( mikrobus, MIKROBUS_PWM )
103  // headphoneamp2_map // headphoneamp2
106 
111 typedef struct
112 {
113  // Output pins
114  digital_out_t shd;
116  // Modules
117  i2c_master_t i2c;
119  // I2C slave address
120  uint8_t slave_address;
123 
128 typedef struct
129 {
130  pin_name_t scl;
131  pin_name_t sda;
133  pin_name_t shd;
135  uint32_t i2c_speed;
136  uint8_t i2c_address;
139 
144 typedef enum
145 {
148 
150 
155 typedef struct
156 {
160  uint8_t volume;
163 
168 typedef enum
169 {
172 
174 
191 
206 
220 
232 err_t headphoneamp2_write_data ( headphoneamp2_t *ctx, uint8_t data_in );
233 
245 
257 
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 #endif // HEADPHONEAMP2_H
278  // headphoneamp2
280 
281 // ------------------------------------------------------------------------ END
HEADPHONEAMP2_ERROR
@ HEADPHONEAMP2_ERROR
Definition: headphoneamp2.h:171
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:133
headphoneamp2_disable
void headphoneamp2_disable(headphoneamp2_t *ctx)
Headphone AMP 2 disable the device function.
HEADPHONEAMP2_CMD_DISABLE
@ HEADPHONEAMP2_CMD_DISABLE
Definition: headphoneamp2.h:146
headphoneamp2_t::shd
digital_out_t shd
Definition: headphoneamp2.h:114
headphoneamp2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: headphoneamp2.h:135
headphoneamp2_cfg_t::i2c_address
uint8_t i2c_address
Definition: headphoneamp2.h:136
headphoneamp2_cmd_t::bass_max
headphoneamp2_cmd_ctrl_value_t bass_max
Definition: headphoneamp2.h:158
headphoneamp2_cmd_t
Headphone AMP 2 Click command object.
Definition: headphoneamp2.h:156
headphoneamp2_cfg_t
Headphone AMP 2 Click configuration object.
Definition: headphoneamp2.h:129
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:169
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:145
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:120
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:170
headphoneamp2_cmd_t::gain_max
headphoneamp2_cmd_ctrl_value_t gain_max
Definition: headphoneamp2.h:159
headphoneamp2_cfg_t::scl
pin_name_t scl
Definition: headphoneamp2.h:130
HEADPHONEAMP2_CMD_ENABLE
@ HEADPHONEAMP2_CMD_ENABLE
Definition: headphoneamp2.h:147
headphoneamp2_cmd_t::volume
uint8_t volume
Definition: headphoneamp2.h:160
headphoneamp2_cmd_t::wakes_up
headphoneamp2_cmd_ctrl_value_t wakes_up
Definition: headphoneamp2.h:157
headphoneamp2_t::i2c
i2c_master_t i2c
Definition: headphoneamp2.h:117
headphoneamp2_cfg_t::sda
pin_name_t sda
Definition: headphoneamp2.h:131
headphoneamp2_t
Headphone AMP 2 Click context object.
Definition: headphoneamp2.h:112