audioamp8  2.0.0.0
audioamp8.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2021 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 AUDIOAMP8_H
29 #define AUDIOAMP8_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 AUDIOAMP8_REG_PWR_MODE_CTRL 0x00
70 #define AUDIOAMP8_REG_THSH_PWR_MODE_PM12 0x01
71 #define AUDIOAMP8_REG_THSH_PWR_MODE_PM21 0x02
72 #define AUDIOAMP8_REG_THSH_PWR_MODE_PM23 0x03
73 #define AUDIOAMP8_REG_THSH_PWR_MODE_PM32 0x04
74 #define AUDIOAMP8_REG_SOFT_CLP_OVC_PROT_LAT 0x0A
75 #define AUDIOAMP8_REG_SEL_PWR_MODE_PROFILE 0x1D
76 #define AUDIOAMP8_REG_PWR_MODE_PROFILE_CFG 0x1E
77 #define AUDIOAMP8_REG_OVC_PROT_LAT_CLR 0x20
78 #define AUDIOAMP8_REG_AUDIO_IN_MODE 0x25
79 #define AUDIOAMP8_REG_DC_PROTECTION 0x26
80 #define AUDIOAMP8_REG_AUDIO_IN_MODE_OVERWRITE 0x27
81 #define AUDIOAMP8_REG_ERROR_HANDLER_CLEAR 0x2D
82 
83 #define AUDIOAMP8_REG_MON_CH_0_FREQ_PWR_MODE 0x60
84 #define AUDIOAMP8_REG_MON_CH_0 0x61
85 #define AUDIOAMP8_REG_MON_CH_0_MODUL_INDEX 0x62
86 #define AUDIOAMP8_REG_MON_CH_1_FREQ_PWR_MODE 0x64
87 #define AUDIOAMP8_REG_MON_CH_1 0x65
88 #define AUDIOAMP8_REG_MON_CH_1_MODUL_INDEX 0x66
89 #define AUDIOAMP8_REG_ERROR_ACCUMULATED 0x6D
90 #define AUDIOAMP8_REG_MONITOR_MSEL 0x75
91 #define AUDIOAMP8_REG_ERROR 0x7C
92  // audioamp8_reg
94 
109 #define AUDIOAMP8_SET_MON_CH_0 0x00
110 #define AUDIOAMP8_SET_MON_CH_1 0x01
111 #define AUDIOAMP8_SET_AUTO_PWR_MODE 0x00
112 #define AUDIOAMP8_SET_MANUAL_PWR_MODE 0x01
113 #define AUDIOAMP8_SET_MTHR_1TO2_DEFAULT 0x3C
114 #define AUDIOAMP8_SET_MTHR_2TO1_DEFAULT 0x32
115 #define AUDIOAMP8_SET_MTHR_2TO3_DEFAULT 0x5A
116 #define AUDIOAMP8_SET_MTHR_3TO2_DEFAULT 0x50
117 #define AUDIOAMP8_SET_DISABLE 0x00
118 #define AUDIOAMP8_SET_ENABLE 0x01
119 
120 
126 #define AUDIOAMP8_SET_DEV_ADDR_0 0x20
127 #define AUDIOAMP8_SET_DEV_ADDR_1 0x21
128 #define AUDIOAMP8_SET_DEV_ADDR_2 0x22
129 #define AUDIOAMP8_SET_DEV_ADDR_3 0x23
130  // audioamp8_set
132 
147 #define AUDIOAMP8_MAP_MIKROBUS( cfg, mikrobus ) \
148  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
149  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
150  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
151  cfg.mut = MIKROBUS( mikrobus, MIKROBUS_RST ); \
152  cfg.ms0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
153  cfg.ms1 = MIKROBUS( mikrobus, MIKROBUS_INT )
154  // audioamp8_map // audioamp8
157 
162 typedef struct
163 {
164  // Output pins
165  digital_out_t en;
166  digital_out_t mut;
167  digital_out_t ms0;
168  digital_out_t ms1;
170  // Modules
171  i2c_master_t i2c;
173  // I2C slave address
174  uint8_t slave_address;
176 } audioamp8_t;
177 
182 typedef struct
183 {
184  pin_name_t scl;
185  pin_name_t sda;
187  pin_name_t en;
188  pin_name_t mut;
189  pin_name_t ms0;
190  pin_name_t ms1;
192  uint32_t i2c_speed;
193  uint8_t i2c_address;
196 
201 typedef struct
202 {
203  uint8_t manual_pm;
204  uint8_t pm_man;
205  uint8_t mthr_1to2;
206  uint8_t mthr_2to1;
207  uint8_t mthr_2to3;
208  uint8_t mthr_3to2;
209 
211 
216 typedef struct
217 {
218  uint8_t pm_profile;
219  uint8_t pm3_man_sh;
220  uint8_t pm2_man_sh;
221  uint8_t pm1_man_sh;
222 
224 
229 typedef struct
230 {
231  uint8_t freq_mode;
232  uint8_t pwr_mode;
233  uint8_t mute_mon;
234  uint8_t vdd_mon;
235  uint8_t pvdd_mon;
236  uint8_t cfly2_mon;
237  uint8_t cfly1_mon;
238  uint8_t ovc_prot;
240 
242 
247 typedef struct
248 {
249  uint8_t fly_cap_ov_vtg;
250  uint8_t ov_curr_prot;
251  uint8_t pll_err;
253  uint8_t ov_temp_wrg;
254  uint8_t ov_temp_err;
255  uint8_t imped_prot;
256  uint8_t dc_prot;
257 
259 
264 typedef enum
265 {
267  AUDIOAMP8_ERROR = -1
268 
270 
275 typedef enum
276 {
280 
282 
287 typedef enum
288 {
294 
296 
301 typedef enum
302 {
307 
309 
314 typedef enum
315 {
318 
320 
325 typedef enum
326 {
329 
331 
348 
364 
379 
395 err_t audioamp8_generic_write ( audioamp8_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
396 
412 err_t audioamp8_generic_read ( audioamp8_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
413 
427 
441 
454 err_t audioamp8_set_mute ( audioamp8_t *ctx, uint8_t en_mute );
455 
468 err_t audioamp8_set_enable ( audioamp8_t *ctx, uint8_t dev_en );
469 
484 
500 
516 
536 err_t audioamp8_set_soft_copl ( audioamp8_t *ctx, uint8_t lf_clamp_en, uint8_t ocp_latch_en );
537 
553 
569 
584 
601 err_t audioamp8_set_audio_imode ( audioamp8_t *ctx, uint8_t audio_in_mode );
602 
619 err_t audioamp8_set_dc_protection ( audioamp8_t *ctx, uint8_t eh_dcshdn );
620 
637 err_t audioamp8_set_audio_imode_ow ( audioamp8_t *ctx, uint8_t audio_in_mode_ext );
638 
653 
672 
691 err_t audioamp8_monitor_msel ( audioamp8_t *ctx, uint8_t *msel );
692 
708 
709 #ifdef __cplusplus
710 }
711 #endif
712 #endif // AUDIOAMP8_H
713  // audioamp8
715 
716 // ------------------------------------------------------------------------ END
audioamp8_pwr_mon_cfg_t::mthr_3to2
uint8_t mthr_3to2
Definition: audioamp8.h:208
AUDIOAMP8_AUDIO_IN_MODE_0_20dB
@ AUDIOAMP8_AUDIO_IN_MODE_0_20dB
Definition: audioamp8.h:316
audioamp8_audio_in_mode_value_t
audioamp8_audio_in_mode_value_t
AudioAmp 8 Click audio input mode value data.
Definition: audioamp8.h:315
audioamp8_error_status_t::imped_prot
uint8_t imped_prot
Definition: audioamp8.h:255
audioamp8_monitor_msel
err_t audioamp8_monitor_msel(audioamp8_t *ctx, uint8_t *msel)
AudioAmp 8 monitor msel function.
AUDIOAMP8_SCHEME_D
@ AUDIOAMP8_SCHEME_D
Definition: audioamp8.h:306
audioamp8_t::i2c
i2c_master_t i2c
Definition: audioamp8.h:171
audioamp8_t::ms1
digital_out_t ms1
Definition: audioamp8.h:168
audioamp8_return_value_t
audioamp8_return_value_t
AudioAmp 8 Click return value data.
Definition: audioamp8.h:265
AUDIOAMP8_ERROR
@ AUDIOAMP8_ERROR
Definition: audioamp8.h:267
audioamp8_t::ms0
digital_out_t ms0
Definition: audioamp8.h:167
AUDIOAMP8_PM_MAN_3
@ AUDIOAMP8_PM_MAN_3
Definition: audioamp8.h:279
audioamp8_monitor_channel_t::freq_mode
uint8_t freq_mode
Definition: audioamp8.h:231
audioamp8_pwr_mod_profile_cfg_t::pm2_man_sh
uint8_t pm2_man_sh
Definition: audioamp8.h:220
audioamp8_monitor_channel_t
AudioAmp 8 Click monitor channel object.
Definition: audioamp8.h:230
AUDIOAMP8_SCHEME_A
@ AUDIOAMP8_SCHEME_A
Definition: audioamp8.h:303
audioamp8_error_status_t::ov_temp_err
uint8_t ov_temp_err
Definition: audioamp8.h:254
audioamp8_pm_profile_value_t
audioamp8_pm_profile_value_t
AudioAmp 8 Click select power mode profile value data.
Definition: audioamp8.h:288
audioamp8_monitor_channel_t::pvdd_mon
uint8_t pvdd_mon
Definition: audioamp8.h:235
audioamp8_channel_monitoring
err_t audioamp8_channel_monitoring(audioamp8_t *ctx, uint8_t mon_ch, audioamp8_monitor_channel_t *ch_mon)
AudioAmp 8 monitors the status of the channel's function.
audioamp8_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: audioamp8.h:192
audioamp8_cfg_t::mut
pin_name_t mut
Definition: audioamp8.h:188
audioamp8_cfg_t::ms0
pin_name_t ms0
Definition: audioamp8.h:189
audioamp8_monitor_channel_t::ovc_prot
uint8_t ovc_prot
Definition: audioamp8.h:238
audioamp8_t::en
digital_out_t en
Definition: audioamp8.h:165
audioamp8_manual_pm_value_t
audioamp8_manual_pm_value_t
AudioAmp 8 Click manual selected power mode value data.
Definition: audioamp8.h:276
audioamp8_pwr_mon_cfg_t::mthr_1to2
uint8_t mthr_1to2
Definition: audioamp8.h:205
audioamp8_set_cfg_pmode
err_t audioamp8_set_cfg_pmode(audioamp8_t *ctx, audioamp8_pwr_mon_cfg_t pwr_mode)
AudioAmp 8 set power mode configuration function.
audioamp8_monitor_channel_t::modul_index_mon
uint8_t modul_index_mon
Definition: audioamp8.h:239
AUDIOAMP8_PM_PROFILE_0
@ AUDIOAMP8_PM_PROFILE_0
Definition: audioamp8.h:289
AUDIOAMP8_PM_MAN_2
@ AUDIOAMP8_PM_MAN_2
Definition: audioamp8.h:278
audioamp8_set_cfg_pmode_p
err_t audioamp8_set_cfg_pmode_p(audioamp8_t *ctx, audioamp8_pwr_mod_profile_cfg_t pm_profile)
AudioAmp 8 set power mode profile configuration function.
AUDIOAMP8_AUDIO_IN_MODE_0_26dB
@ AUDIOAMP8_AUDIO_IN_MODE_0_26dB
Definition: audioamp8.h:317
audioamp8_monitor_channel_t::cfly2_mon
uint8_t cfly2_mon
Definition: audioamp8.h:236
audioamp8_cfg_t
AudioAmp 8 Click configuration object.
Definition: audioamp8.h:183
audioamp8_cfg_t::i2c_address
uint8_t i2c_address
Definition: audioamp8.h:193
AUDIOAMP8_PM_PROFILE_1
@ AUDIOAMP8_PM_PROFILE_1
Definition: audioamp8.h:290
audioamp8_btl_cfg
err_t audioamp8_btl_cfg(audioamp8_t *ctx)
AudioAmp 8 BTL configuration function.
audioamp8_pwr_mod_profile_cfg_t::pm1_man_sh
uint8_t pm1_man_sh
Definition: audioamp8.h:221
audioamp8_cfg_t::sda
pin_name_t sda
Definition: audioamp8.h:185
audioamp8_monitor_channel_t::vdd_mon
uint8_t vdd_mon
Definition: audioamp8.h:234
audioamp8_cfg_t::scl
pin_name_t scl
Definition: audioamp8.h:184
audioamp8_pwr_mod_profile_cfg_t::pm3_man_sh
uint8_t pm3_man_sh
Definition: audioamp8.h:219
audioamp8_set_soft_copl
err_t audioamp8_set_soft_copl(audioamp8_t *ctx, uint8_t lf_clamp_en, uint8_t ocp_latch_en)
AudioAmp 8 set soft-clipping and overcurrent protection latching function.
audioamp8_error_status_t::fly_cap_ov_vtg
uint8_t fly_cap_ov_vtg
Definition: audioamp8.h:249
AUDIOAMP8_SCHEME_B
@ AUDIOAMP8_SCHEME_B
Definition: audioamp8.h:304
audioamp8_clr_err_handler
err_t audioamp8_clr_err_handler(audioamp8_t *ctx)
AudioAmp 8 error handler clear function.
AUDIOAMP8_PM_PROFILE_3
@ AUDIOAMP8_PM_PROFILE_3
Definition: audioamp8.h:292
AUDIOAMP8_OK
@ AUDIOAMP8_OK
Definition: audioamp8.h:266
audioamp8_get_cfg_pmode_p
err_t audioamp8_get_cfg_pmode_p(audioamp8_t *ctx, audioamp8_pwr_mod_profile_cfg_t *pm_profile)
AudioAmp 8 get power mode configuration function.
audioamp8_shut_down
err_t audioamp8_shut_down(audioamp8_t *ctx)
AudioAmp 8 shut-down procedure function.
audioamp8_generic_read
err_t audioamp8_generic_read(audioamp8_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
AudioAmp 8 I2C reading function.
audioamp8_error_status_t::ov_temp_wrg
uint8_t ov_temp_wrg
Definition: audioamp8.h:253
audioamp8_set_enable
err_t audioamp8_set_enable(audioamp8_t *ctx, uint8_t dev_en)
AudioAmp 8 enable function.
audioamp8_t::mut
digital_out_t mut
Definition: audioamp8.h:166
audioamp8_err_status
err_t audioamp8_err_status(audioamp8_t *ctx, audioamp8_error_status_t *error_status)
AudioAmp 8 get error status function.
audioamp8_monitor_channel_t::pwr_mode
uint8_t pwr_mode
Definition: audioamp8.h:232
audioamp8_pwr_mod_profile_cfg_t
AudioAmp 8 Click power mode profile configuration object.
Definition: audioamp8.h:217
audioamp8_audio_in_mode_ext_value_t
audioamp8_audio_in_mode_ext_value_t
AudioAmp 8 Click audio input mode value data.
Definition: audioamp8.h:326
AUDIOAMP8_AUDIO_IN_MODE_EXT_ENABLE
@ AUDIOAMP8_AUDIO_IN_MODE_EXT_ENABLE
Definition: audioamp8.h:328
audioamp8_pwr_mod_profile_cfg_t::pm_profile
uint8_t pm_profile
Definition: audioamp8.h:218
AUDIOAMP8_SCHEME_C
@ AUDIOAMP8_SCHEME_C
Definition: audioamp8.h:305
audioamp8_pwr_mon_cfg_t::mthr_2to3
uint8_t mthr_2to3
Definition: audioamp8.h:207
audioamp8_get_cfg_pmode
err_t audioamp8_get_cfg_pmode(audioamp8_t *ctx, audioamp8_pwr_mon_cfg_t *pwr_mode)
AudioAmp 8 get power mode configuration function.
audioamp8_generic_write
err_t audioamp8_generic_write(audioamp8_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
AudioAmp 8 I2C writing function.
audioamp8_cfg_t::en
pin_name_t en
Definition: audioamp8.h:187
audioamp8_error_status_t::pvdd_un_vtg_prot
uint8_t pvdd_un_vtg_prot
Definition: audioamp8.h:252
audioamp8_monitor_channel_t::mute_mon
uint8_t mute_mon
Definition: audioamp8.h:233
audioamp8_t::slave_address
uint8_t slave_address
Definition: audioamp8.h:174
audioamp8_pm_man_sh_value_t
audioamp8_pm_man_sh_value_t
AudioAmp 8 Click profile assign scheme value data.
Definition: audioamp8.h:302
audioamp8_t
AudioAmp 8 Click context object.
Definition: audioamp8.h:163
audioamp8_monitor_channel_t::cfly1_mon
uint8_t cfly1_mon
Definition: audioamp8.h:237
audioamp8_set_dc_protection
err_t audioamp8_set_dc_protection(audioamp8_t *ctx, uint8_t eh_dcshdn)
AudioAmp 8 set DC protection function.
audioamp8_clr_opl
err_t audioamp8_clr_opl(audioamp8_t *ctx)
AudioAmp 8 over-current protection latch clear function.
audioamp8_pwr_mon_cfg_t::manual_pm
uint8_t manual_pm
Definition: audioamp8.h:203
AUDIOAMP8_PM_PROFILE_4
@ AUDIOAMP8_PM_PROFILE_4
Definition: audioamp8.h:293
AUDIOAMP8_AUDIO_IN_MODE_EXT_DISABLE
@ AUDIOAMP8_AUDIO_IN_MODE_EXT_DISABLE
Definition: audioamp8.h:327
audioamp8_set_mute
err_t audioamp8_set_mute(audioamp8_t *ctx, uint8_t en_mute)
AudioAmp 8 mute function.
audioamp8_cfg_setup
void audioamp8_cfg_setup(audioamp8_cfg_t *cfg)
AudioAmp 8 configuration object setup function.
audioamp8_start_up
err_t audioamp8_start_up(audioamp8_t *ctx)
AudioAmp 8 start-up procedure function.
AUDIOAMP8_PM_MAN_1
@ AUDIOAMP8_PM_MAN_1
Definition: audioamp8.h:277
AUDIOAMP8_PM_PROFILE_2
@ AUDIOAMP8_PM_PROFILE_2
Definition: audioamp8.h:291
audioamp8_pwr_mon_cfg_t::mthr_2to1
uint8_t mthr_2to1
Definition: audioamp8.h:206
audioamp8_set_audio_imode_ow
err_t audioamp8_set_audio_imode_ow(audioamp8_t *ctx, uint8_t audio_in_mode_ext)
AudioAmp 8 set audio IN mode overwrite function.
audioamp8_cfg_t::ms1
pin_name_t ms1
Definition: audioamp8.h:190
audioamp8_pwr_mon_cfg_t
AudioAmp 8 Click power mode configuration object.
Definition: audioamp8.h:202
audioamp8_init
err_t audioamp8_init(audioamp8_t *ctx, audioamp8_cfg_t *cfg)
AudioAmp 8 initialization function.
audioamp8_set_audio_imode
err_t audioamp8_set_audio_imode(audioamp8_t *ctx, uint8_t audio_in_mode)
AudioAmp 8 set audio IN mode function.
audioamp8_error_status_t
AudioAmp 8 Click monitor channel object.
Definition: audioamp8.h:248
audioamp8_default_cfg
err_t audioamp8_default_cfg(audioamp8_t *ctx)
AudioAmp 8 default configuration function.
audioamp8_error_status_t::ov_curr_prot
uint8_t ov_curr_prot
Definition: audioamp8.h:250
audioamp8_error_status_t::dc_prot
uint8_t dc_prot
Definition: audioamp8.h:256
audioamp8_error_status_t::pll_err
uint8_t pll_err
Definition: audioamp8.h:251
audioamp8_pwr_mon_cfg_t::pm_man
uint8_t pm_man
Definition: audioamp8.h:204