amfm 2.0.0.0
amfm.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4 * All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef AMFM_H
36#define AMFM_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define AMFM_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
71 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
72 cfg.sen = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_INT ); \
74 cfg.shd = MIKROBUS( mikrobus, MIKROBUS_PWM);
81#define AMFM_OK 0
82#define AMFM_ERROR -1
89#define AMFM_DEVICE_ADDRESS 0x11
96#define AMFM_CMD_PWRUP 0x01
97#define AMFM_CMD_GETREV 0x10
98#define AMFM_CMD_PWRDOWN 0x11
99#define AMFM_CMD_SETPROP 0x12
100#define AMFM_CMD_GETPROP 0x13
101#define AMFM_CMD_GETINTSTATUS 0x14
102#define AMFM_CMD_PATCHARGS 0x15
103#define AMFM_CMD_PATCHDATA 0x16
104#define AMFM_CMD_GPIOCTL 0x80
105#define AMFM_CMD_GPIOSET 0x81
112#define AMFM_CMD_AMTUNEFREQ 0x40
113#define AMFM_CMD_AMSEEKSTART 0x41
114#define AMFM_CMD_AMTUNESTATUS 0x42
115#define AMFM_CMD_AMRSQSTATUS 0x43
116#define AMFM_CMD_AMAGCSTATUS 0x47
117#define AMFM_CMD_AMAGCOVERRIDE 0x48
124#define AMFM_CMD_FMTUNEFREQ 0x20
125#define AMFM_CMD_FMSEEKSTART 0x21
126#define AMFM_CMD_FMTUNESTATUS 0x22
127#define AMFM_CMD_FMRSQSTATUS 0x23
128#define AMFM_CMD_FMRDSSTATUS 0x24
129#define AMFM_CMD_FMAGCSTATUS 0x27
130#define AMFM_CMD_FMAGCOVERRIDE 0x28
137#define AMFM_PWRUP_ARG1_CTSIEN 0x80
138#define AMFM_PWRUP_ARG1_GPO2OEN 0x40
139#define AMFM_PWRUP_ARG1_PATCH 0x20
140#define AMFM_PWRUP_ARG1_XOSCEN 0x10
141#define AMFM_PWRUP_ARG1_FUNC_FMRECEIVE 0x00
142#define AMFM_PWRUP_ARG1_FUNC_QUERYLIBID 0x0F
143#define AMFM_PWRUP_ARG2_OPMODE_ANALOGOUT 0x05
144#define AMFM_PWRUP_ARG2_OPMODE_DIGITALOUT 0x0B
145#define AMFM_PWRUP_ARG2_OPMODE_DIGITALOUTS 0xB0
146#define AMFM_PWRUP_ARG2_OPMODE_ANALOGDIGITALOUTS 0xB5
147#define AMFM_FMTUNEFREQ_ARG1_FREEZE 0x02
148#define AMFM_FMTUNEFREQ_ARG1_FAST 0x01
149#define AMFM_FMSEEKSTART_ARG1_SEEKUP 0x08
150#define AMFM_FMSEEKSTART_ARG1_WRAP 0x04
151#define AMFM_FMTUNESTATUS_ARG1_CANCEL 0x02
152#define AMFM_FMTUNESTATUS_ARG1_INTACK 0x01
153#define AMFM_FMRSQSTATUS_ARG1_INTACK 0x01
154#define AMFM_FMRDSSTATUS_ARG1_STATUSONLY 0x04
155#define AMFM_FMRDSSTATUS_ARG1_MTFIFO 0x02
156#define AMFM_FMRDSSTATUS_ARG1_INTACK 0x01
157#define AMFM_FMAGCOVERRIDE_ARG1_RFAGCDIS 0x01
158#define AMFM_GPIOCTL_ARG1_GPO3OEN 0x08
159#define AMFM_GPIOCTL_ARG1_GPO2OEN 0x04
160#define AMFM_GPIOCTL_ARG1_GPO1OEN 0x02
161#define AMFM_GPIOSET_ARG1_GPO3LEVEL 0x08
162#define AMFM_GPIOSET_ARG1_GPO2LEVEL 0x04
163#define AMFM_GPIOSET_ARG1_GPO1LEVEL 0x02
170#define AMFM_PROP_GPOIEN_H 0x00
171#define AMFM_PROP_GPOIEN_L 0x01
172#define AMFM_PROP_DIGITALOUTFORMAT_H 0x01
173#define AMFM_PROP_DIGITALOUTFORMAT_L 0x02
174#define AMFM_PROP_DIGITALOUTSAMPLERATE_H 0x01
175#define AMFM_PROP_DIGITALOUTSAMPLERATE_L 0x04
176#define AMFM_PROP_REFCLKFREQ_H 0x02
177#define AMFM_PROP_REFCLKFREQ_L 0x01
178#define AMFM_PROP_REFCLKPRESCALE_H 0x02
179#define AMFM_PROP_REFCLKPRESCALE_L 0x02
180#define AMFM_PROP_RXVOLUME_H 0x40
181#define AMFM_PROP_RXVOLUME_L 0x00
182#define AMFM_PROP_RXHMUTE_H 0x40
183#define AMFM_PROP_RXHMUTE_L 0x01
190#define AMFM_PROP_FMDEEMPHASIS_H 0x11
191#define AMFM_PROP_FMDEEMPHASIS_L 0x00
192#define AMFM_PROP_AMDEEMPHASIS_H 0x31
193#define AMFM_PROP_AMDEEMPHASIS_L 0x00
194#define AMFM_PROP_FMCHANFILTER_H 0x11
195#define AMFM_PROP_FMCHANFILTER_L 0x02
196#define AMFM_PROP_AMCHANFILTER_H 0x31
197#define AMFM_PROP_AMCHANFILTER_L 0x02
198#define AMFM_PROP_AMAUTOVOLCTRLMAXGAIN_H 0x31
199#define AMFM_PROP_AMAUTOVOLCTRLMAXGAIN_L 0x03
200#define AMFM_PROP_AMMODEAFCSWPULLINRANGE_H 0x31
201#define AMFM_PROP_AMMODEAFCSWPULLINRANGE_L 0x04
202#define AMFM_PROP_AMMODEAFCSWLOCKINRANGE_H 0x31
203#define AMFM_PROP_AMMODEAFCSWLOCKINRANGE_L 0x05
204#define AMFM_PROP_AMRSQINTS_H 0x32
205#define AMFM_PROP_AMRSQINTS_L 0x00
206#define AMFM_PROP_AMRSQSNRHITHS_H 0x32
207#define AMFM_PROP_AMRSQSNRHITHS_L 0x01
208#define AMFM_PROP_AMRSQSNRLOTHS_H 0x32
209#define AMFM_PROP_AMRSQSNRLOTHS_L 0x02
210#define AMFM_PROP_AMRSQRSSIHITHS_H 0x32
211#define AMFM_PROP_AMRSQRSSIHITHS_L 0x03
212#define AMFM_PROP_AMRSQRSSILOTHS_H 0x32
213#define AMFM_PROP_AMRSQRSSILOTHS_L 0x04
214#define AMFM_PROP_AMSMUTERATE_H 0x33
215#define AMFM_PROP_AMSMUTERATE_L 0x00
216#define AMFM_PROP_AMSMUTESLOPE_H 0x33
217#define AMFM_PROP_AMSMUTESLOPE_L 0x01
218#define AMFM_PROP_AMSMUTEMAXATTENUATION_H 0x33
219#define AMFM_PROP_AMSMUTEMAXATTENUATION_L 0x02
220#define AMFM_PROP_AMSMUTESNRTHS_H 0x33
221#define AMFM_PROP_AMSMUTESNRTHS_L 0x03
222#define AMFM_PROP_AMSMUTERELEASERATE_H 0x33
223#define AMFM_PROP_AMSMUTERELEASERATE_L 0x04
224#define AMFM_PROP_AMSMUTEATTACKRATE_H 0x33
225#define AMFM_PROP_AMSMUTEATTACKRATE_L 0x05
226#define AMFM_PROP_AMSEEKBANDBOT_H 0x34
227#define AMFM_PROP_AMSEEKBANDBOT_L 0x00
228#define AMFM_PROP_AMSEEKBANDTOP_H 0x34
229#define AMFM_PROP_AMSEEKBANDTOP_L 0x01
230#define AMFM_PROP_AMSEEKFREQSPACING_H 0x34
231#define AMFM_PROP_AMSEEKFREQSPACING_L 0x02
232#define AMFM_PROP_AMSEEKTUNESNRTHS_H 0x34
233#define AMFM_PROP_AMSEEKTUNESNRTHS_L 0x03
234#define AMFM_PROP_AMSEEKTUNERSSITHS_H 0x34
235#define AMFM_PROP_AMSEEKTUNERSSITHS_L 0x04
236#define AMFM_PROP_AMAGCATTACKRATE_H 0x37
237#define AMFM_PROP_AMAGCATTACKRATE_L 0x02
238#define AMFM_PROP_AMAGCRELEASERATE_H 0x37
239#define AMFM_PROP_AMAGCRELEASERATE_L 0x03
240#define AMFM_PROP_AMFRONTENDAGCCTRL_H 0x37
241#define AMFM_PROP_AMFRONTENDAGCCTRL_L 0x05
242#define AMFM_PROP_AMNBDETECTTHS_H 0x39
243#define AMFM_PROP_AMNBDETECTTHS_L 0x00
244#define AMFM_PROP_AMNBINTERVAL_H 0x39
245#define AMFM_PROP_AMNBINTERVAL_L 0x01
246#define AMFM_PROP_AMNBRATE_H 0x39
247#define AMFM_PROP_AMNBRATE_L 0x02
248#define AMFM_PROP_AMNBIIRFILTER_H 0x39
249#define AMFM_PROP_AMNBIIRFILTER_L 0x03
250#define AMFM_PROP_AMNBDELAY_H 0x39
251#define AMFM_PROP_AMNBDELAY_L 0x04
258#define AMFM_PROP_FMBLENDSTEREOTHS_H 0x11
259#define AMFM_PROP_FMBLENDSTEREOTHS_L 0x05
260#define AMFM_PROP_FMBLENDMONOTHS_H 0x11
261#define AMFM_PROP_FMBLENDMONOTHS_L 0x06
262#define AMFM_PROP_FMANTENNAIN_H 0x11
263#define AMFM_PROP_FMANTENNAIN_L 0x07
264#define AMFM_PROP_FMMAXTUNEERR_H 0x11
265#define AMFM_PROP_FMMAXTUNEERR_L 0x08
266#define AMFM_PROP_FMRSQINTSRC_H 0x12
267#define AMFM_PROP_FMRSQINTSRC_L 0x00
268#define AMFM_PROP_FMRSQSNRHITHS_H 0x12
269#define AMFM_PROP_FMRSQSNRHITHS_L 0x01
270#define AMFM_PROP_FMRSQSNRLOTHS_H 0x12
271#define AMFM_PROP_FMRSQSNRLOTHS_L 0x02
272#define AMFM_PROP_FMRSQRSSIHITHS_H 0x12
273#define AMFM_PROP_FMRSQRSSIHITHS_L 0x03
274#define AMFM_PROP_FMRSQRSSILOTHS_H 0x12
275#define AMFM_PROP_FMRSQRSSILOTHS_L 0x04
276#define AMFM_PROP_FMRSQMULTIPATHHITHS_H 0x12
277#define AMFM_PROP_FMRSQMULTIPATHHITHS_L 0x05
278#define AMFM_PROP_FMRSQMULTIPATHLOTHS_H 0x12
279#define AMFM_PROP_FMRSQMULTIPATHLOTHS_L 0x06
280#define AMFM_PROP_FMRSQBLENDTHS_H 0x12
281#define AMFM_PROP_FMRSQBLENDTHS_L 0x07
282#define AMFM_PROP_FMSMUTERATE_H 0x13
283#define AMFM_PROP_FMSMUTERATE_L 0x00
284#define AMFM_PROP_FMSMUTESLOPE_H 0x13
285#define AMFM_PROP_FMSMUTESLOPE_L 0x01
286#define AMFM_PROP_FMSMUTEMAXATTENUATION_H 0x13
287#define AMFM_PROP_FMSMUTEMAXATTENUATION_L 0x02
288#define AMFM_PROP_FMSMUTESNRTHS_H 0x13
289#define AMFM_PROP_FMSMUTESNRTHS_L 0x03
290#define AMFM_PROP_FMSMUTERELEASERATE_H 0x13
291#define AMFM_PROP_FMSMUTERELEASERATE_L 0x04
292#define AMFM_PROP_FMSMUTEATTACKRATE_H 0x13
293#define AMFM_PROP_FMSMUTEATTACKRATE_L 0x05
294#define AMFM_PROP_FMSEEKBANDBOT_H 0x14
295#define AMFM_PROP_FMSEEKBANDBOT_L 0x00
296#define AMFM_PROP_FMSEEKBANDTOP_H 0x14
297#define AMFM_PROP_FMSEEKBANDTOP_L 0x01
298#define AMFM_PROP_FMSEEKFREQSPACING_H 0x14
299#define AMFM_PROP_FMSEEKFREQSPACING_L 0x02
300#define AMFM_PROP_FMSEEKTUNESNRTHS_H 0x14
301#define AMFM_PROP_FMSEEKTUNESNRTHS_L 0x03
302#define AMFM_PROP_FMSEEKTUNERSSITHS_H 0x14
303#define AMFM_PROP_FMSEEKTUNERSSITHS_L 0x04
304#define AMFM_PROP_FMRDSINTSRC_H 0x15
305#define AMFM_PROP_FMRDSINTSRC_L 0x00
306#define AMFM_PROP_FMRDSINTFIFOCOUNT_H 0x15
307#define AMFM_PROP_FMRDSINTFIFOCOUNT_L 0x01
308#define AMFM_PROP_FMRDSCFG_H 0x15
309#define AMFM_PROP_FMRDSCFG_L 0x02
310#define AMFM_PROP_FMRDSCONFIDENCE_H 0x15
311#define AMFM_PROP_FMRDSCONFIDENCE_L 0x03
312#define AMFM_PROP_FMAGCATTACKRATE_H 0x17
313#define AMFM_PROP_FMAGCATTACKRATE_L 0x00
314#define AMFM_PROP_FMAGCRELEASERATE_H 0x17
315#define AMFM_PROP_FMAGCRELEASERATE_L 0x01
316#define AMFM_PROP_FMBLENDRSSISTEREOTHS_H 0x18
317#define AMFM_PROP_FMBLENDRSSISTEREOTHS_L 0x00
318#define AMFM_PROP_FMBLENDRSSIMONOTHS_H 0x18
319#define AMFM_PROP_FMBLENDRSSIMONOTHS_L 0x01
320#define AMFM_PROP_FMBLENDRSSIATTACKRATE_H 0x18
321#define AMFM_PROP_FMBLENDRSSIATTACKRATE_L 0x02
322#define AMFM_PROP_FMBLENDRSSIRELEASERATE_H 0x18
323#define AMFM_PROP_FMBLENDRSSIRELEASERATE_L 0x03
324#define AMFM_PROP_FMBLENDSNRSTEREOTHS_H 0x18
325#define AMFM_PROP_FMBLENDSNRSTEREOTHS_L 0x04
326#define AMFM_PROP_FMBLENDSNRMONOTHS_H 0x18
327#define AMFM_PROP_FMBLENDSNRMONOTHS_L 0x05
328#define AMFM_PROP_FMBLENDSNRATTACKRATE_H 0x18
329#define AMFM_PROP_FMBLENDSNRATTACKRATE_L 0x06
330#define AMFM_PROP_FMBLENDSNRRELEASERATE_H 0x18
331#define AMFM_PROP_FMBLENDSNRRELEASERATE_L 0x07
332#define AMFM_PROP_FMBLENDMULTIPATHSTEREOTHS_H 0x18
333#define AMFM_PROP_FMBLENDMULTIPATHSTEREOTHS_L 0x08
334#define AMFM_PROP_FMBLENDMULTIPATHMONOTHS_H 0x18
335#define AMFM_PROP_FMBLENDMULTIPATHMONOTHS_L 0x09
336#define AMFM_PROP_FMBLENDMULTIPATHATTACKRATE_H 0x18
337#define AMFM_PROP_FMBLENDMULTIPATHATTACKRATE_L 0x0A
338#define AMFM_PROP_FMBLENDMULTIPATHRELEASERATE_H 0x18
339#define AMFM_PROP_FMBLENDMULTIPATHRELEASERATE_L 0x0B
340#define AMFM_PROP_FMBLENDMAXSTEREOSEPARATION_H 0x18
341#define AMFM_PROP_FMBLENDMAXSTEREOSEPARATION_L 0x0C
342#define AMFM_PROP_FMNBDETECTTHS_H 0x19
343#define AMFM_PROP_FMNBDETECTTHS_L 0x00
344#define AMFM_PROP_FMNBINTERVAL_H 0x19
345#define AMFM_PROP_FMNBINTERVAL_L 0x01
346#define AMFM_PROP_FMNBRATE_H 0x19
347#define AMFM_PROP_FMNBRATE_L 0x02
348#define AMFM_PROP_FMNBIIRFILTER_H 0x19
349#define AMFM_PROP_FMNBIIRFILTER_L 0x03
350#define AMFM_PROP_FMNBDELAY_H 0x19
351#define AMFM_PROP_FMNBDELAY_L 0x04
352#define AMFM_PROP_FMHICUTSNRHITHS_H 0x1A
353#define AMFM_PROP_FMHICUTSNRHITHS_L 0x00
354#define AMFM_PROP_FMHICUTSNRLOTHS_H 0x1A
355#define AMFM_PROP_FMHICUTSNRLOTHS_L 0x01
356#define AMFM_PROP_FMHICUTATTACKRATE_H 0x1A
357#define AMFM_PROP_FMHICUTATTACKRATE_L 0x02
358#define AMFM_PROP_FMHICUTRELEASERATE_H 0x1A
359#define AMFM_PROP_FMHICUTRELEASERATE_L 0x03
360#define AMFM_PROP_FMHICUTMULTIPATHTRIGGERTHRESHOLD_H 0x1A
361#define AMFM_PROP_FMHICUTMULTIPATHTRIGGERTHRESHOLD_L 0x04
362#define AMFM_PROP_FMHICUTMULTIPATHENDTHS_H 0x1A
363#define AMFM_PROP_FMHICUTMULTIPATHENDTHS_L 0x05
364#define AMFM_PROP_FMHICUTCUTOFFFREQ_H 0x1A
365#define AMFM_PROP_FMHICUTCUTOFFFREQ_L 0x06
372#define AMFM_PROPVALH_RSQREP 0x08
373#define AMFM_PROPVALH_RDSREP 0x04
374#define AMFM_PROPVALH_STCREP 0x01
375#define AMFM_PROPVALL_CTSIEN 0x80
376#define AMFM_PROPVALL_ERRIEN 0x40
377#define AMFM_PROPVALL_RSQIEN 0x08
378#define AMFM_PROPVALL_RDSIEN 0x04
379#define AMFM_PROPVALL_STCIEN 0x01
380#define AMFM_PROPVALL_OFALL 0x80
381#define AMFM_PROPVALL_OMODE_I2S 0x00
382#define AMFM_PROPVALL_OMODE_LEFTJUST 0x30
383#define AMFM_PROPVALL_OMODE_MSBATSECONDDCLK 0x40
384#define AMFM_PROPVALL_OMODE_MSBATFIRSTDCLK 0x60
385#define AMFM_PROPVALL_OMONO 0x04
386#define AMFM_PROPVALL_OSIZE_16b 0x00
387#define AMFM_PROPVALL_OSIZE_20b 0x01
388#define AMFM_PROPVALL_OSIZE_24b 0x02
389#define AMFM_PROPVALL_OSIZE_08b 0x03
390#define AMFM_PROPVALL_DEEMPH_75uS 0x02
391#define AMFM_PROPVALL_DEEMPH_50uS 0x01
392#define AMFM_PROPVALL_AUTO 0x00
393#define AMFM_PROPVALL_WIDE 0x01
394#define AMFM_PROPVALL_NARROW 0x02
395#define AMFM_PROPVALL_NARROWER 0x03
396#define AMFM_PROPVALL_NARROWEST 0x04
397#define AMFM_PROPVALL_FMTXO 0x01
398#define AMFM_PROPVALL_BLENDIEN 0x80
399#define AMFM_PROPVALL_MULTHIEN 0x20
400#define AMFM_PROPVALL_MULTLIEN 0x10
401#define AMFM_PROPVALL_SNRHIEN 0x08
402#define AMFM_PROPVALL_SNRLIEN 0x04
403#define AMFM_PROPVALL_RSSIHIEN 0x02
404#define AMFM_PROPVALL_RSSILIEN 0x01
405#define AMFM_PROPVALL_RDSNEWBLOCKB 0x20
406#define AMFM_PROPVALL_RDSNEWBLOCKA 0x10
407#define AMFM_PROPVALL_RDSSYNCFOUND 0x04
408#define AMFM_PROPVALL_RDSSYNCLOST 0x02
409#define AMFM_PROPVALL_RDSRECV 0x01
410#define AMFM_PROPVALH_BLETHA_NOERRORS 0x00
411#define AMFM_PROPVALH_BLETHA_1TO2ERRORS 0x40
412#define AMFM_PROPVALH_BLETHA_3TO5ERRORS 0x80
413#define AMFM_PROPVALH_BLETHA_UNCORRECTABLE 0xC0
414#define AMFM_PROPVALH_BLETHB_NOERRORS 0x00
415#define AMFM_PROPVALH_BLETHB_1TO2ERRORS 0x10
416#define AMFM_PROPVALH_BLETHB_3TO5ERRORS 0x20
417#define AMFM_PROPVALH_BLETHB_UNCORRECTABLE 0x30
418#define AMFM_PROPVALH_BLETHC_NOERRORS 0x00
419#define AMFM_PROPVALH_BLETHC_1TO2ERRORS 0x04
420#define AMFM_PROPVALH_BLETHC_3TO5ERRORS 0x08
421#define AMFM_PROPVALH_BLETHC_UNCORRECTABLE 0x0C
422#define AMFM_PROPVALH_BLETHD_NOERRORS 0x00
423#define AMFM_PROPVALH_BLETHD_1TO2ERRORS 0x01
424#define AMFM_PROPVALH_BLETHD_3TO5ERRORS 0x02
425#define AMFM_PROPVALH_BLETHD_UNCORRECTABLE 0x03
426#define AMFM_PROPVALL_RDSEN 0x01
427#define AMFM_PROPVALL_MAXAUDIOFREQ_MAX 0x00
428#define AMFM_PROPVALL_MAXAUDIOFREQ_2 0x10
429#define AMFM_PROPVALL_MAXAUDIOFREQ_3 0x20
430#define AMFM_PROPVALL_MAXAUDIOFREQ_4 0x30
431#define AMFM_PROPVALL_MAXAUDIOFREQ_5 0x40
432#define AMFM_PROPVALL_MAXAUDIOFREQ_6 0x50
433#define AMFM_PROPVALL_MAXAUDIOFREQ_8 0x60
434#define AMFM_PROPVALL_MAXAUDIOFREQ_11 0x70
435#define AMFM_PROPVALL_HICUTTRANSFREQ_DISABLED 0x00
436#define AMFM_PROPVALL_HICUTTRANSFREQ_2 0x01
437#define AMFM_PROPVALL_HICUTTRANSFREQ_3 0x02
438#define AMFM_PROPVALL_HICUTTRANSFREQ_4 0x03
439#define AMFM_PROPVALL_HICUTTRANSFREQ_5 0x04
440#define AMFM_PROPVALL_HICUTTRANSFREQ_6 0x05
441#define AMFM_PROPVALL_HICUTTRANSFREQ_8 0x06
442#define AMFM_PROPVALL_HICUTTRANSFREQ_11 0x07
443#define AMFM_PROPVALL_LMUTE 0x02
444#define AMFM_PROPVALL_RMUTE 0x01
447 // End group macro
448// --------------------------------------------------------------- PUBLIC TYPES
457typedef struct
458{
459 // Output pins
460 digital_out_t rst;
461 digital_out_t sen;
462 digital_out_t shd;
463
464 // Input pins
465 digital_in_t gp1;
466 digital_in_t gp2;
467
468 pin_name_t gp1_pin;
469 pin_name_t gp2_pin;
470
471 // Modules
472 i2c_master_t i2c;
473
474 // ctx variable
476 uint8_t command_and_arguments_buffer[ 6 ];
477 uint16_t aux_variable;
478 uint8_t response_buffer[ 8 ];
479 uint8_t n_bytes;
480
481} amfm_t;
482
486typedef struct
487{
488 // Communication gpio pins
489 pin_name_t scl;
490 pin_name_t sda;
491
492 // Additional gpio pins
493 pin_name_t gp1;
494 pin_name_t rst;
495 pin_name_t sen;
496 pin_name_t gp2;
497 pin_name_t shd;
498
499 // static variable
500 uint32_t i2c_speed;
501 uint8_t i2c_address;
502
503} amfm_cfg_t;
504
505 // End types group
506// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
507
513#ifdef __cplusplus
514extern "C"{
515#endif
516
526
535err_t amfm_init ( amfm_t *ctx, amfm_cfg_t *cfg );
536
545
556void amfm_generic_write ( amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
557
568void amfm_generic_read ( amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
569
577uint8_t amfm_an_get ( amfm_t *ctx );
578
586uint8_t amfm_int_get ( amfm_t *ctx );
587
596void amfm_rst_set ( amfm_t *ctx, uint8_t pin_state );
597
606void amfm_cs_set ( amfm_t *ctx, uint8_t pin_state );
607
616uint8_t amfm_send_command ( amfm_t *ctx, uint8_t *cmd_and_args_buf );
617
625uint8_t amfm_get_cts ( amfm_t *ctx );
626
634uint8_t amfm_get_stc ( amfm_t *ctx );
635
643uint8_t amfm_get_rsq ( amfm_t *ctx );
644
652uint8_t amfm_get_rds ( amfm_t *ctx );
653
663uint8_t amfm_get_response ( amfm_t *ctx, uint8_t *resp_buf, uint8_t n_bytes );
664
673uint8_t amfm_init_device ( amfm_t *ctx );
674
683uint8_t amfm_seek ( amfm_t *ctx );
684
693uint8_t amfm_set_volume ( amfm_t *ctx, uint8_t volume );
694
703uint8_t amfm_mute ( amfm_t *ctx );
704
713uint8_t amfm_unmute ( amfm_t *ctx );
714
722uint8_t amfm_tune_up ( amfm_t *ctx );
723
731uint8_t amfm_tune_down ( amfm_t *ctx );
732
741uint8_t amfm_tune_frequency ( amfm_t *ctx, uint16_t frequency );
742
750uint16_t amfm_get_channel ( amfm_t *ctx );
751
752#ifdef __cplusplus
753}
754#endif
755#endif // _AMFM_H_
756
757 // End public_function group
759
760// ------------------------------------------------------------------------- END
uint8_t amfm_set_volume(amfm_t *ctx, uint8_t volume)
Function for setting volume level.
uint8_t amfm_seek(amfm_t *ctx)
Function for seeking next station.
uint8_t amfm_send_command(amfm_t *ctx, uint8_t *cmd_and_args_buf)
Function for sending command and command arguments to device.
void amfm_cfg_setup(amfm_cfg_t *cfg)
Config Object Initialization function.
uint8_t amfm_get_rsq(amfm_t *ctx)
Function for checking RSQ bit.
uint8_t amfm_an_get(amfm_t *ctx)
Function for checking AN pin state.
void amfm_rst_set(amfm_t *ctx, uint8_t pin_state)
Function for setting RST pin state.
uint8_t amfm_unmute(amfm_t *ctx)
Function for unmuting device.
void amfm_default_cfg(amfm_t *ctx)
Click Default Configuration function.
void amfm_cs_set(amfm_t *ctx, uint8_t pin_state)
Function for setting CS pin state.
void amfm_generic_read(amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t amfm_get_rds(amfm_t *ctx)
Function for checking RDS bit.
uint8_t amfm_int_get(amfm_t *ctx)
Function for checking INT pin state.
uint8_t amfm_get_response(amfm_t *ctx, uint8_t *resp_buf, uint8_t n_bytes)
Function for getting device response.
uint8_t amfm_tune_frequency(amfm_t *ctx, uint16_t frequency)
Function for tuning frequency.
uint8_t amfm_tune_down(amfm_t *ctx)
Function for tune down current frequency.
uint8_t amfm_init_device(amfm_t *ctx)
Device initialization.
void amfm_generic_write(amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t amfm_get_stc(amfm_t *ctx)
Function for checking STC bit.
err_t amfm_init(amfm_t *ctx, amfm_cfg_t *cfg)
Initialization function.
uint8_t amfm_tune_up(amfm_t *ctx)
Function for tune up current frequency.
uint8_t amfm_get_cts(amfm_t *ctx)
Function for checking CTS bit.
uint8_t amfm_mute(amfm_t *ctx)
Function for muting device.
uint16_t amfm_get_channel(amfm_t *ctx)
Function for getting current channel value.
uint8_t volume
Definition main.c:31
Click configuration structure definition.
Definition amfm.h:487
pin_name_t gp2
Definition amfm.h:496
uint32_t i2c_speed
Definition amfm.h:500
pin_name_t shd
Definition amfm.h:497
pin_name_t scl
Definition amfm.h:489
pin_name_t gp1
Definition amfm.h:493
pin_name_t sda
Definition amfm.h:490
pin_name_t sen
Definition amfm.h:495
pin_name_t rst
Definition amfm.h:494
uint8_t i2c_address
Definition amfm.h:501
Click ctx object definition.
Definition amfm.h:458
pin_name_t gp1_pin
Definition amfm.h:468
pin_name_t gp2_pin
Definition amfm.h:469
uint16_t aux_variable
Definition amfm.h:477
digital_in_t gp1
Definition amfm.h:465
uint8_t n_bytes
Definition amfm.h:479
digital_in_t gp2
Definition amfm.h:466
digital_out_t sen
Definition amfm.h:461
i2c_master_t i2c
Definition amfm.h:472
digital_out_t rst
Definition amfm.h:460
uint8_t slave_address
Definition amfm.h:475
digital_out_t shd
Definition amfm.h:462