39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
76#define AUDIOAMP11_REG_REGGAIN 0x04
77#define AUDIOAMP11_REG_VOLCTRL 0x1B
95#define AUDIOAMP11_GS_0dB_VOLCTRL_0dB 0x00
96#define AUDIOAMP11_GS_0dB_VOLCTRL_m2dB 0x01
97#define AUDIOAMP11_GS_0dB_VOLCTRL_m4dB 0x02
98#define AUDIOAMP11_GS_0dB_VOLCTRL_m6dB 0x03
99#define AUDIOAMP11_GS_0dB_VOLCTRL_m8dB 0x04
100#define AUDIOAMP11_GS_0dB_VOLCTRL_m10dB 0x05
101#define AUDIOAMP11_GS_0dB_VOLCTRL_m12dB 0x06
102#define AUDIOAMP11_GS_0dB_VOLCTRL_m14dB 0x07
103#define AUDIOAMP11_GS_0dB_VOLCTRL_m16dB 0x08
104#define AUDIOAMP11_GS_0dB_VOLCTRL_m18dB 0x09
105#define AUDIOAMP11_GS_0dB_VOLCTRL_m20dB 0x0A
106#define AUDIOAMP11_GS_0dB_VOLCTRL_m22dB 0x0B
107#define AUDIOAMP11_GS_0dB_VOLCTRL_m24dB 0x0C
108#define AUDIOAMP11_GS_0dB_VOLCTRL_m26dB 0x0D
109#define AUDIOAMP11_GS_0dB_VOLCTRL_m28dB 0x0E
110#define AUDIOAMP11_GS_0dB_VOLCTRL_m30dB 0x0F
111#define AUDIOAMP11_GS_0dB_VOLCTRL_m32dB 0x10
112#define AUDIOAMP11_GS_0dB_VOLCTRL_m34dB 0x11
113#define AUDIOAMP11_GS_0dB_VOLCTRL_m36dB 0x12
114#define AUDIOAMP11_GS_0dB_VOLCTRL_m38dB 0x13
115#define AUDIOAMP11_GS_0dB_VOLCTRL_m40dB 0x14
116#define AUDIOAMP11_GS_0dB_VOLCTRL_m42dB 0x15
117#define AUDIOAMP11_GS_0dB_VOLCTRL_m44dB 0x16
118#define AUDIOAMP11_GS_0dB_VOLCTRL_m46dB 0x17
119#define AUDIOAMP11_GS_0dB_VOLCTRL_m48dB 0x18
120#define AUDIOAMP11_GS_0dB_VOLCTRL_m50dB 0x19
121#define AUDIOAMP11_GS_0dB_VOLCTRL_m52dB 0x1A
122#define AUDIOAMP11_GS_0dB_VOLCTRL_m54dB 0x1B
123#define AUDIOAMP11_GS_0dB_VOLCTRL_m56dB 0x1C
124#define AUDIOAMP11_GS_0dB_VOLCTRL_m58dB 0x1D
125#define AUDIOAMP11_GS_0dB_VOLCTRL_m60dB 0x1E
126#define AUDIOAMP11_GS_0dB_VOLCTRL_m62dB 0x1F
127#define AUDIOAMP11_GS_6dB_VOLCTRL_6dB 0x00
128#define AUDIOAMP11_GS_6dB_VOLCTRL_4_1dB 0x01
129#define AUDIOAMP11_GS_6dB_VOLCTRL_2_2dB 0x02
130#define AUDIOAMP11_GS_6dB_VOLCTRL_0_4dB 0x03
131#define AUDIOAMP11_GS_6dB_VOLCTRL_m1_6dB 0x04
132#define AUDIOAMP11_GS_6dB_VOLCTRL_m3_5dB 0x05
133#define AUDIOAMP11_GS_6dB_VOLCTRL_m5_6dB 0x06
134#define AUDIOAMP11_GS_6dB_VOLCTRL_m7_5dB 0x07
135#define AUDIOAMP11_GS_6dB_VOLCTRL_m9_5dB 0x08
136#define AUDIOAMP11_GS_6dB_VOLCTRL_m11_4dB 0x09
137#define AUDIOAMP11_GS_6dB_VOLCTRL_m13_4dB 0x0A
138#define AUDIOAMP11_GS_6dB_VOLCTRL_m15_4dB 0x0B
139#define AUDIOAMP11_GS_6dB_VOLCTRL_m17_3dB 0x0C
140#define AUDIOAMP11_GS_6dB_VOLCTRL_m19_3dB 0x0D
141#define AUDIOAMP11_GS_6dB_VOLCTRL_m21_3dB 0x0E
142#define AUDIOAMP11_GS_6dB_VOLCTRL_m23_3dB 0x0F
143#define AUDIOAMP11_GS_6dB_VOLCTRL_m25_3dB 0x10
144#define AUDIOAMP11_GS_6dB_VOLCTRL_m27_3dB 0x11
145#define AUDIOAMP11_GS_6dB_VOLCTRL_m29_1dB 0x12
146#define AUDIOAMP11_GS_6dB_VOLCTRL_m30_7dB 0x13
147#define AUDIOAMP11_GS_6dB_VOLCTRL_m32_2dB 0x14
148#define AUDIOAMP11_GS_6dB_VOLCTRL_m33_7dB 0x15
149#define AUDIOAMP11_GS_6dB_VOLCTRL_m35_1dB 0x16
150#define AUDIOAMP11_GS_6dB_VOLCTRL_m36_6dB 0x17
151#define AUDIOAMP11_GS_6dB_VOLCTRL_m36dB 0x18
152#define AUDIOAMP11_GS_6dB_VOLCTRL_m35_2dB 0x19
153#define AUDIOAMP11_GS_6dB_VOLCTRL_m34_6dB 0x1A
154#define AUDIOAMP11_GS_6dB_VOLCTRL_m33_9dB 0x1B
155#define AUDIOAMP11_GS_6dB_VOLCTRL_m33_5dB 0x1D
156#define AUDIOAMP11_GS_6dB_VOLCTRL_m33_4dB 0x1E
157#define AUDIOAMP11_GS_6dB_VOLCTRL_m62dB 0x1F
158#define AUDIOAMP11_GS_12dB_VOLCTRL_12dB 0x00
159#define AUDIOAMP11_GS_12dB_VOLCTRL_10_4dB 0x01
160#define AUDIOAMP11_GS_12dB_VOLCTRL_8_8dB 0x02
161#define AUDIOAMP11_GS_12dB_VOLCTRL_7_1dB 0x03
162#define AUDIOAMP11_GS_12dB_VOLCTRL_5_4dB 0x04
163#define AUDIOAMP11_GS_12dB_VOLCTRL_3_6dB 0x05
164#define AUDIOAMP11_GS_12dB_VOLCTRL_1_7dB 0x06
165#define AUDIOAMP11_GS_12dB_VOLCTRL_m0_2dB 0x07
166#define AUDIOAMP11_GS_12dB_VOLCTRL_m2dB 0x08
167#define AUDIOAMP11_GS_12dB_VOLCTRL_m3_9dB 0x09
168#define AUDIOAMP11_GS_12dB_VOLCTRL_m5_8dB 0x0A
169#define AUDIOAMP11_GS_12dB_VOLCTRL_m7_8dB 0x0B
170#define AUDIOAMP11_GS_12dB_VOLCTRL_m9_7dB 0x0C
171#define AUDIOAMP11_GS_12dB_VOLCTRL_m11_7dB 0x0D
172#define AUDIOAMP11_GS_12dB_VOLCTRL_m13_6dB 0x0E
173#define AUDIOAMP11_GS_12dB_VOLCTRL_m15_6dB 0x0F
174#define AUDIOAMP11_GS_12dB_VOLCTRL_m17_6dB 0x10
175#define AUDIOAMP11_GS_12dB_VOLCTRL_m19_3dB 0x11
176#define AUDIOAMP11_GS_12dB_VOLCTRL_m20_4dB 0x12
177#define AUDIOAMP11_GS_12dB_VOLCTRL_m20_5dB 0x13
178#define AUDIOAMP11_GS_12dB_VOLCTRL_m20_2dB 0x14
179#define AUDIOAMP11_GS_12dB_VOLCTRL_m20dB 0x15
180#define AUDIOAMP11_GS_12dB_VOLCTRL_m19_8dB 0x16
181#define AUDIOAMP11_GS_12dB_VOLCTRL_m19_7dB 0x17
182#define AUDIOAMP11_GS_12dB_VOLCTRL_m19_6dB 0x18
183#define AUDIOAMP11_GS_12dB_VOLCTRL_m19_5dB 0x19
184#define AUDIOAMP11_GS_12dB_VOLCTRL_m19_4dB 0x1B
185#define AUDIOAMP11_GS_18dB_VOLCTRL_18dB 0x00
186#define AUDIOAMP11_GS_18dB_VOLCTRL_17dB 0x01
187#define AUDIOAMP11_GS_18dB_VOLCTRL_16dB 0x02
188#define AUDIOAMP11_GS_18dB_VOLCTRL_15dB 0x03
189#define AUDIOAMP11_GS_18dB_VOLCTRL_13_7dB 0x04
190#define AUDIOAMP11_GS_18dB_VOLCTRL_12_4dB 0x05
191#define AUDIOAMP11_GS_18dB_VOLCTRL_10_9dB 0x06
192#define AUDIOAMP11_GS_18dB_VOLCTRL_9_4dB 0x07
193#define AUDIOAMP11_GS_18dB_VOLCTRL_7_9dB 0x08
194#define AUDIOAMP11_GS_18dB_VOLCTRL_6_2dB 0x09
195#define AUDIOAMP11_GS_18dB_VOLCTRL_4_5dB 0x0A
196#define AUDIOAMP11_GS_18dB_VOLCTRL_2_7dB 0x0B
197#define AUDIOAMP11_GS_18dB_VOLCTRL_0_9dB 0x0C
198#define AUDIOAMP11_GS_18dB_VOLCTRL_m0_9dB 0x0D
199#define AUDIOAMP11_GS_18dB_VOLCTRL_m2_8dB 0x0E
200#define AUDIOAMP11_GS_18dB_VOLCTRL_m4_7dB 0x0F
201#define AUDIOAMP11_GS_18dB_VOLCTRL_m6_6dB 0x10
202#define AUDIOAMP11_GS_18dB_VOLCTRL_m7_3dB 0x11
203#define AUDIOAMP11_GS_18dB_VOLCTRL_m7_1dB 0x14
204#define AUDIOAMP11_GS_18dB_VOLCTRL_m7_0dB 0x18
205#define AUDIOAMP11_GS_24dB_VOLCTRL_24dB 0x00
207#define AUDIOAMP11_VOLUME_LEVEL_31 0x00
208#define AUDIOAMP11_VOLUME_LEVEL_30 0x01
209#define AUDIOAMP11_VOLUME_LEVEL_29 0x02
210#define AUDIOAMP11_VOLUME_LEVEL_28 0x03
211#define AUDIOAMP11_VOLUME_LEVEL_27 0x04
212#define AUDIOAMP11_VOLUME_LEVEL_26 0x05
213#define AUDIOAMP11_VOLUME_LEVEL_25 0x06
214#define AUDIOAMP11_VOLUME_LEVEL_24 0x07
215#define AUDIOAMP11_VOLUME_LEVEL_23 0x08
216#define AUDIOAMP11_VOLUME_LEVEL_22 0x09
217#define AUDIOAMP11_VOLUME_LEVEL_21 0x0A
218#define AUDIOAMP11_VOLUME_LEVEL_20 0x0B
219#define AUDIOAMP11_VOLUME_LEVEL_19 0x0C
220#define AUDIOAMP11_VOLUME_LEVEL_18 0x0D
221#define AUDIOAMP11_VOLUME_LEVEL_17 0x0E
222#define AUDIOAMP11_VOLUME_LEVEL_16 0x0F
223#define AUDIOAMP11_VOLUME_LEVEL_15 0x10
224#define AUDIOAMP11_VOLUME_LEVEL_14 0x11
225#define AUDIOAMP11_VOLUME_LEVEL_13 0x12
226#define AUDIOAMP11_VOLUME_LEVEL_12 0x13
227#define AUDIOAMP11_VOLUME_LEVEL_11 0x14
228#define AUDIOAMP11_VOLUME_LEVEL_10 0x15
229#define AUDIOAMP11_VOLUME_LEVEL_9 0x16
230#define AUDIOAMP11_VOLUME_LEVEL_8 0x17
231#define AUDIOAMP11_VOLUME_LEVEL_7 0x18
232#define AUDIOAMP11_VOLUME_LEVEL_6 0x19
233#define AUDIOAMP11_VOLUME_LEVEL_5 0x1A
234#define AUDIOAMP11_VOLUME_LEVEL_4 0x1B
235#define AUDIOAMP11_VOLUME_LEVEL_3 0x1C
236#define AUDIOAMP11_VOLUME_LEVEL_2 0x1D
237#define AUDIOAMP11_VOLUME_LEVEL_1 0x1E
238#define AUDIOAMP11_VOLUME_LEVEL_0 0x1F
239#define AUDIOAMP11_VOLUME_MUTE 0x3F
241#define AUDIOAMP11_GAINDEC_0dB 0x01
242#define AUDIOAMP11_GAINDEC_6dB 0x02
243#define AUDIOAMP11_GAINDEC_12dB 0x04
244#define AUDIOAMP11_GAINDEC_18dB 0x08
245#define AUDIOAMP11_GAINDEC_24dB 0x10
252#define AUDIOAMP11_DEVICE_ADDRESS 0x2A
265#define AUDIOAMP11_CALC_GAIN_CONFIG(GAINDEC) (GAINDEC==1?0:(GAINDEC==2?6:(GAINDEC==4?12:(GAINDEC==8 ? 18:24))))
267#define OUTPUT_VOLUME_0dB 0.0, -2.0, -4.0, -6.0, -8.0, -10.0, -12.0, -14.0, -16.0, -18.0, \
268 -20.0, -22.0, -24.0, -26.0, -28.0, -30.0, -32.0, -34.0, -36.0, -38.0, \
269 -40.0, -42.0, -44.0, -46.0, -48.0, -50.0, -52.0, -54.0, -56.0, -58.0, -60.0, -62.0
271#define OUTPUT_VOLUME_6dB 6.0, 4.1, 2.2, 0.4, -1.6, -3.5, -5.6, -7.5, -29.5, -11.4 , \
272 -13.4, -15.4, -17.3, -19.3, -21.3, -23.3, -25.3, -27.3, -29.1, -30.7, \
273 -32.2, -33.7, -35.1, -36.6, -36.0, -35.2, -34.6, -34.2, -33.9, -33.7, -33.5, -33.4
275#define OUTPUT_VOLUME_12dB 12.0, 10.4, 8.8, 7.1, 5.4, 3.6, 1.7, -0.2, -2.0, -3.9, \
276 -5.8, -7.8, -9.7, -11.7, -13.6, -15.6, -17.6, -19.3, -20.4, -20.5, \
277 -20.2, -20.0, -19.8, -19.7, -19.6, -19.5, -19.5, -19.4, -19.4, -19.4, -19.4, -19.3
279#define OUTPUT_VOLUME_18dB 19.0, 17.0, 16.0, 15.0, 13.7, 12.4, 10.9, 9.4, 7.9, 6.2, \
280 4.5, 2.7, 0.9, -0.9, -2.8, -4.7, -6.6, -7.3, -7.3, -7.1, \
281 -7.1, -7.1, -7.1, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0, -7.0
283#define OUTPUT_VOLUME_24dB 24.0
301#define AUDIOAMP11_MAP_MIKROBUS( cfg, mikrobus ) \
302 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
303 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
304 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
audioamp11_return_value_t
AudioAMP 11 Click return value data.
Definition audioamp11.h:347
@ AUDIOAMP11_OK
Definition audioamp11.h:348
@ AUDIOAMP11_ERROR
Definition audioamp11.h:349
err_t audioamp11_generic_write(audioamp11_t *ctx, uint8_t reg, uint8_t data_in)
AudioAMP 11 I2C writing function.
err_t audioamp11_generic_read(audioamp11_t *ctx, uint8_t reg, uint8_t *data_out)
AudioAMP 11 I2C reading function.
err_t audioamp11_check_gain(audioamp11_t *ctx, uint8_t *gain)
AudioAMP 11 check gain function.
void audioamp11_disable_device(audioamp11_t *ctx)
AudioAMP 11 enable device function.
err_t audioamp11_default_cfg(audioamp11_t *ctx)
AudioAMP 11 default configuration function.
void audioamp11_enable_device(audioamp11_t *ctx)
AudioAMP 11 enable device function.
err_t audioamp11_set_output_volume_level(audioamp11_t *ctx, uint8_t volume_data)
AudioAMP 11 set output volume level function.
void audioamp11_cfg_setup(audioamp11_cfg_t *cfg)
AudioAMP 11 configuration object setup function.
err_t audioamp11_init(audioamp11_t *ctx, audioamp11_cfg_t *cfg)
AudioAMP 11 initialization function.
err_t audioamp11_get_output_volume_level(audioamp11_t *ctx, uint8_t *volume_data)
AudioAMP 11 get output volume level function.
AudioAMP 11 Click configuration object.
Definition audioamp11.h:331
uint32_t i2c_speed
Definition audioamp11.h:337
pin_name_t scl
Definition audioamp11.h:332
pin_name_t en
Definition audioamp11.h:335
pin_name_t sda
Definition audioamp11.h:333
uint8_t i2c_address
Definition audioamp11.h:338
AudioAMP 11 Click context object.
Definition audioamp11.h:314
i2c_master_t i2c
Definition audioamp11.h:319
digital_out_t en
Definition audioamp11.h:316
uint8_t slave_address
Definition audioamp11.h:322