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 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
63 #define AMFM_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66  cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68  cfg.sen = MIKROBUS( mikrobus, MIKROBUS_CS ); \
69  cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_INT ); \
70  cfg.shd = MIKROBUS( mikrobus, MIKROBUS_PWM);
71 
77 #define AMFM_OK 0
78 #define AMFM_ERROR -1
79 
85 #define AMFM_DEVICE_ADDRESS 0x11
86 
92 #define AMFM_CMD_PWRUP 0x01
93 #define AMFM_CMD_GETREV 0x10
94 #define AMFM_CMD_PWRDOWN 0x11
95 #define AMFM_CMD_SETPROP 0x12
96 #define AMFM_CMD_GETPROP 0x13
97 #define AMFM_CMD_GETINTSTATUS 0x14
98 #define AMFM_CMD_PATCHARGS 0x15
99 #define AMFM_CMD_PATCHDATA 0x16
100 #define AMFM_CMD_GPIOCTL 0x80
101 #define AMFM_CMD_GPIOSET 0x81
102 
108 #define AMFM_CMD_AMTUNEFREQ 0x40
109 #define AMFM_CMD_AMSEEKSTART 0x41
110 #define AMFM_CMD_AMTUNESTATUS 0x42
111 #define AMFM_CMD_AMRSQSTATUS 0x43
112 #define AMFM_CMD_AMAGCSTATUS 0x47
113 #define AMFM_CMD_AMAGCOVERRIDE 0x48
114 
120 #define AMFM_CMD_FMTUNEFREQ 0x20
121 #define AMFM_CMD_FMSEEKSTART 0x21
122 #define AMFM_CMD_FMTUNESTATUS 0x22
123 #define AMFM_CMD_FMRSQSTATUS 0x23
124 #define AMFM_CMD_FMRDSSTATUS 0x24
125 #define AMFM_CMD_FMAGCSTATUS 0x27
126 #define AMFM_CMD_FMAGCOVERRIDE 0x28
127 
133 #define AMFM_PWRUP_ARG1_CTSIEN 0x80
134 #define AMFM_PWRUP_ARG1_GPO2OEN 0x40
135 #define AMFM_PWRUP_ARG1_PATCH 0x20
136 #define AMFM_PWRUP_ARG1_XOSCEN 0x10
137 #define AMFM_PWRUP_ARG1_FUNC_FMRECEIVE 0x00
138 #define AMFM_PWRUP_ARG1_FUNC_QUERYLIBID 0x0F
139 #define AMFM_PWRUP_ARG2_OPMODE_ANALOGOUT 0x05
140 #define AMFM_PWRUP_ARG2_OPMODE_DIGITALOUT 0x0B
141 #define AMFM_PWRUP_ARG2_OPMODE_DIGITALOUTS 0xB0
142 #define AMFM_PWRUP_ARG2_OPMODE_ANALOGDIGITALOUTS 0xB5
143 #define AMFM_FMTUNEFREQ_ARG1_FREEZE 0x02
144 #define AMFM_FMTUNEFREQ_ARG1_FAST 0x01
145 #define AMFM_FMSEEKSTART_ARG1_SEEKUP 0x08
146 #define AMFM_FMSEEKSTART_ARG1_WRAP 0x04
147 #define AMFM_FMTUNESTATUS_ARG1_CANCEL 0x02
148 #define AMFM_FMTUNESTATUS_ARG1_INTACK 0x01
149 #define AMFM_FMRSQSTATUS_ARG1_INTACK 0x01
150 #define AMFM_FMRDSSTATUS_ARG1_STATUSONLY 0x04
151 #define AMFM_FMRDSSTATUS_ARG1_MTFIFO 0x02
152 #define AMFM_FMRDSSTATUS_ARG1_INTACK 0x01
153 #define AMFM_FMAGCOVERRIDE_ARG1_RFAGCDIS 0x01
154 #define AMFM_GPIOCTL_ARG1_GPO3OEN 0x08
155 #define AMFM_GPIOCTL_ARG1_GPO2OEN 0x04
156 #define AMFM_GPIOCTL_ARG1_GPO1OEN 0x02
157 #define AMFM_GPIOSET_ARG1_GPO3LEVEL 0x08
158 #define AMFM_GPIOSET_ARG1_GPO2LEVEL 0x04
159 #define AMFM_GPIOSET_ARG1_GPO1LEVEL 0x02
160 
166 #define AMFM_PROP_GPOIEN_H 0x00
167 #define AMFM_PROP_GPOIEN_L 0x01
168 #define AMFM_PROP_DIGITALOUTFORMAT_H 0x01
169 #define AMFM_PROP_DIGITALOUTFORMAT_L 0x02
170 #define AMFM_PROP_DIGITALOUTSAMPLERATE_H 0x01
171 #define AMFM_PROP_DIGITALOUTSAMPLERATE_L 0x04
172 #define AMFM_PROP_REFCLKFREQ_H 0x02
173 #define AMFM_PROP_REFCLKFREQ_L 0x01
174 #define AMFM_PROP_REFCLKPRESCALE_H 0x02
175 #define AMFM_PROP_REFCLKPRESCALE_L 0x02
176 #define AMFM_PROP_RXVOLUME_H 0x40
177 #define AMFM_PROP_RXVOLUME_L 0x00
178 #define AMFM_PROP_RXHMUTE_H 0x40
179 #define AMFM_PROP_RXHMUTE_L 0x01
180 
186 #define AMFM_PROP_FMDEEMPHASIS_H 0x11
187 #define AMFM_PROP_FMDEEMPHASIS_L 0x00
188 #define AMFM_PROP_AMDEEMPHASIS_H 0x31
189 #define AMFM_PROP_AMDEEMPHASIS_L 0x00
190 #define AMFM_PROP_FMCHANFILTER_H 0x11
191 #define AMFM_PROP_FMCHANFILTER_L 0x02
192 #define AMFM_PROP_AMCHANFILTER_H 0x31
193 #define AMFM_PROP_AMCHANFILTER_L 0x02
194 #define AMFM_PROP_AMAUTOVOLCTRLMAXGAIN_H 0x31
195 #define AMFM_PROP_AMAUTOVOLCTRLMAXGAIN_L 0x03
196 #define AMFM_PROP_AMMODEAFCSWPULLINRANGE_H 0x31
197 #define AMFM_PROP_AMMODEAFCSWPULLINRANGE_L 0x04
198 #define AMFM_PROP_AMMODEAFCSWLOCKINRANGE_H 0x31
199 #define AMFM_PROP_AMMODEAFCSWLOCKINRANGE_L 0x05
200 #define AMFM_PROP_AMRSQINTS_H 0x32
201 #define AMFM_PROP_AMRSQINTS_L 0x00
202 #define AMFM_PROP_AMRSQSNRHITHS_H 0x32
203 #define AMFM_PROP_AMRSQSNRHITHS_L 0x01
204 #define AMFM_PROP_AMRSQSNRLOTHS_H 0x32
205 #define AMFM_PROP_AMRSQSNRLOTHS_L 0x02
206 #define AMFM_PROP_AMRSQRSSIHITHS_H 0x32
207 #define AMFM_PROP_AMRSQRSSIHITHS_L 0x03
208 #define AMFM_PROP_AMRSQRSSILOTHS_H 0x32
209 #define AMFM_PROP_AMRSQRSSILOTHS_L 0x04
210 #define AMFM_PROP_AMSMUTERATE_H 0x33
211 #define AMFM_PROP_AMSMUTERATE_L 0x00
212 #define AMFM_PROP_AMSMUTESLOPE_H 0x33
213 #define AMFM_PROP_AMSMUTESLOPE_L 0x01
214 #define AMFM_PROP_AMSMUTEMAXATTENUATION_H 0x33
215 #define AMFM_PROP_AMSMUTEMAXATTENUATION_L 0x02
216 #define AMFM_PROP_AMSMUTESNRTHS_H 0x33
217 #define AMFM_PROP_AMSMUTESNRTHS_L 0x03
218 #define AMFM_PROP_AMSMUTERELEASERATE_H 0x33
219 #define AMFM_PROP_AMSMUTERELEASERATE_L 0x04
220 #define AMFM_PROP_AMSMUTEATTACKRATE_H 0x33
221 #define AMFM_PROP_AMSMUTEATTACKRATE_L 0x05
222 #define AMFM_PROP_AMSEEKBANDBOT_H 0x34
223 #define AMFM_PROP_AMSEEKBANDBOT_L 0x00
224 #define AMFM_PROP_AMSEEKBANDTOP_H 0x34
225 #define AMFM_PROP_AMSEEKBANDTOP_L 0x01
226 #define AMFM_PROP_AMSEEKFREQSPACING_H 0x34
227 #define AMFM_PROP_AMSEEKFREQSPACING_L 0x02
228 #define AMFM_PROP_AMSEEKTUNESNRTHS_H 0x34
229 #define AMFM_PROP_AMSEEKTUNESNRTHS_L 0x03
230 #define AMFM_PROP_AMSEEKTUNERSSITHS_H 0x34
231 #define AMFM_PROP_AMSEEKTUNERSSITHS_L 0x04
232 #define AMFM_PROP_AMAGCATTACKRATE_H 0x37
233 #define AMFM_PROP_AMAGCATTACKRATE_L 0x02
234 #define AMFM_PROP_AMAGCRELEASERATE_H 0x37
235 #define AMFM_PROP_AMAGCRELEASERATE_L 0x03
236 #define AMFM_PROP_AMFRONTENDAGCCTRL_H 0x37
237 #define AMFM_PROP_AMFRONTENDAGCCTRL_L 0x05
238 #define AMFM_PROP_AMNBDETECTTHS_H 0x39
239 #define AMFM_PROP_AMNBDETECTTHS_L 0x00
240 #define AMFM_PROP_AMNBINTERVAL_H 0x39
241 #define AMFM_PROP_AMNBINTERVAL_L 0x01
242 #define AMFM_PROP_AMNBRATE_H 0x39
243 #define AMFM_PROP_AMNBRATE_L 0x02
244 #define AMFM_PROP_AMNBIIRFILTER_H 0x39
245 #define AMFM_PROP_AMNBIIRFILTER_L 0x03
246 #define AMFM_PROP_AMNBDELAY_H 0x39
247 #define AMFM_PROP_AMNBDELAY_L 0x04
248 
254 #define AMFM_PROP_FMBLENDSTEREOTHS_H 0x11
255 #define AMFM_PROP_FMBLENDSTEREOTHS_L 0x05
256 #define AMFM_PROP_FMBLENDMONOTHS_H 0x11
257 #define AMFM_PROP_FMBLENDMONOTHS_L 0x06
258 #define AMFM_PROP_FMANTENNAIN_H 0x11
259 #define AMFM_PROP_FMANTENNAIN_L 0x07
260 #define AMFM_PROP_FMMAXTUNEERR_H 0x11
261 #define AMFM_PROP_FMMAXTUNEERR_L 0x08
262 #define AMFM_PROP_FMRSQINTSRC_H 0x12
263 #define AMFM_PROP_FMRSQINTSRC_L 0x00
264 #define AMFM_PROP_FMRSQSNRHITHS_H 0x12
265 #define AMFM_PROP_FMRSQSNRHITHS_L 0x01
266 #define AMFM_PROP_FMRSQSNRLOTHS_H 0x12
267 #define AMFM_PROP_FMRSQSNRLOTHS_L 0x02
268 #define AMFM_PROP_FMRSQRSSIHITHS_H 0x12
269 #define AMFM_PROP_FMRSQRSSIHITHS_L 0x03
270 #define AMFM_PROP_FMRSQRSSILOTHS_H 0x12
271 #define AMFM_PROP_FMRSQRSSILOTHS_L 0x04
272 #define AMFM_PROP_FMRSQMULTIPATHHITHS_H 0x12
273 #define AMFM_PROP_FMRSQMULTIPATHHITHS_L 0x05
274 #define AMFM_PROP_FMRSQMULTIPATHLOTHS_H 0x12
275 #define AMFM_PROP_FMRSQMULTIPATHLOTHS_L 0x06
276 #define AMFM_PROP_FMRSQBLENDTHS_H 0x12
277 #define AMFM_PROP_FMRSQBLENDTHS_L 0x07
278 #define AMFM_PROP_FMSMUTERATE_H 0x13
279 #define AMFM_PROP_FMSMUTERATE_L 0x00
280 #define AMFM_PROP_FMSMUTESLOPE_H 0x13
281 #define AMFM_PROP_FMSMUTESLOPE_L 0x01
282 #define AMFM_PROP_FMSMUTEMAXATTENUATION_H 0x13
283 #define AMFM_PROP_FMSMUTEMAXATTENUATION_L 0x02
284 #define AMFM_PROP_FMSMUTESNRTHS_H 0x13
285 #define AMFM_PROP_FMSMUTESNRTHS_L 0x03
286 #define AMFM_PROP_FMSMUTERELEASERATE_H 0x13
287 #define AMFM_PROP_FMSMUTERELEASERATE_L 0x04
288 #define AMFM_PROP_FMSMUTEATTACKRATE_H 0x13
289 #define AMFM_PROP_FMSMUTEATTACKRATE_L 0x05
290 #define AMFM_PROP_FMSEEKBANDBOT_H 0x14
291 #define AMFM_PROP_FMSEEKBANDBOT_L 0x00
292 #define AMFM_PROP_FMSEEKBANDTOP_H 0x14
293 #define AMFM_PROP_FMSEEKBANDTOP_L 0x01
294 #define AMFM_PROP_FMSEEKFREQSPACING_H 0x14
295 #define AMFM_PROP_FMSEEKFREQSPACING_L 0x02
296 #define AMFM_PROP_FMSEEKTUNESNRTHS_H 0x14
297 #define AMFM_PROP_FMSEEKTUNESNRTHS_L 0x03
298 #define AMFM_PROP_FMSEEKTUNERSSITHS_H 0x14
299 #define AMFM_PROP_FMSEEKTUNERSSITHS_L 0x04
300 #define AMFM_PROP_FMRDSINTSRC_H 0x15
301 #define AMFM_PROP_FMRDSINTSRC_L 0x00
302 #define AMFM_PROP_FMRDSINTFIFOCOUNT_H 0x15
303 #define AMFM_PROP_FMRDSINTFIFOCOUNT_L 0x01
304 #define AMFM_PROP_FMRDSCFG_H 0x15
305 #define AMFM_PROP_FMRDSCFG_L 0x02
306 #define AMFM_PROP_FMRDSCONFIDENCE_H 0x15
307 #define AMFM_PROP_FMRDSCONFIDENCE_L 0x03
308 #define AMFM_PROP_FMAGCATTACKRATE_H 0x17
309 #define AMFM_PROP_FMAGCATTACKRATE_L 0x00
310 #define AMFM_PROP_FMAGCRELEASERATE_H 0x17
311 #define AMFM_PROP_FMAGCRELEASERATE_L 0x01
312 #define AMFM_PROP_FMBLENDRSSISTEREOTHS_H 0x18
313 #define AMFM_PROP_FMBLENDRSSISTEREOTHS_L 0x00
314 #define AMFM_PROP_FMBLENDRSSIMONOTHS_H 0x18
315 #define AMFM_PROP_FMBLENDRSSIMONOTHS_L 0x01
316 #define AMFM_PROP_FMBLENDRSSIATTACKRATE_H 0x18
317 #define AMFM_PROP_FMBLENDRSSIATTACKRATE_L 0x02
318 #define AMFM_PROP_FMBLENDRSSIRELEASERATE_H 0x18
319 #define AMFM_PROP_FMBLENDRSSIRELEASERATE_L 0x03
320 #define AMFM_PROP_FMBLENDSNRSTEREOTHS_H 0x18
321 #define AMFM_PROP_FMBLENDSNRSTEREOTHS_L 0x04
322 #define AMFM_PROP_FMBLENDSNRMONOTHS_H 0x18
323 #define AMFM_PROP_FMBLENDSNRMONOTHS_L 0x05
324 #define AMFM_PROP_FMBLENDSNRATTACKRATE_H 0x18
325 #define AMFM_PROP_FMBLENDSNRATTACKRATE_L 0x06
326 #define AMFM_PROP_FMBLENDSNRRELEASERATE_H 0x18
327 #define AMFM_PROP_FMBLENDSNRRELEASERATE_L 0x07
328 #define AMFM_PROP_FMBLENDMULTIPATHSTEREOTHS_H 0x18
329 #define AMFM_PROP_FMBLENDMULTIPATHSTEREOTHS_L 0x08
330 #define AMFM_PROP_FMBLENDMULTIPATHMONOTHS_H 0x18
331 #define AMFM_PROP_FMBLENDMULTIPATHMONOTHS_L 0x09
332 #define AMFM_PROP_FMBLENDMULTIPATHATTACKRATE_H 0x18
333 #define AMFM_PROP_FMBLENDMULTIPATHATTACKRATE_L 0x0A
334 #define AMFM_PROP_FMBLENDMULTIPATHRELEASERATE_H 0x18
335 #define AMFM_PROP_FMBLENDMULTIPATHRELEASERATE_L 0x0B
336 #define AMFM_PROP_FMBLENDMAXSTEREOSEPARATION_H 0x18
337 #define AMFM_PROP_FMBLENDMAXSTEREOSEPARATION_L 0x0C
338 #define AMFM_PROP_FMNBDETECTTHS_H 0x19
339 #define AMFM_PROP_FMNBDETECTTHS_L 0x00
340 #define AMFM_PROP_FMNBINTERVAL_H 0x19
341 #define AMFM_PROP_FMNBINTERVAL_L 0x01
342 #define AMFM_PROP_FMNBRATE_H 0x19
343 #define AMFM_PROP_FMNBRATE_L 0x02
344 #define AMFM_PROP_FMNBIIRFILTER_H 0x19
345 #define AMFM_PROP_FMNBIIRFILTER_L 0x03
346 #define AMFM_PROP_FMNBDELAY_H 0x19
347 #define AMFM_PROP_FMNBDELAY_L 0x04
348 #define AMFM_PROP_FMHICUTSNRHITHS_H 0x1A
349 #define AMFM_PROP_FMHICUTSNRHITHS_L 0x00
350 #define AMFM_PROP_FMHICUTSNRLOTHS_H 0x1A
351 #define AMFM_PROP_FMHICUTSNRLOTHS_L 0x01
352 #define AMFM_PROP_FMHICUTATTACKRATE_H 0x1A
353 #define AMFM_PROP_FMHICUTATTACKRATE_L 0x02
354 #define AMFM_PROP_FMHICUTRELEASERATE_H 0x1A
355 #define AMFM_PROP_FMHICUTRELEASERATE_L 0x03
356 #define AMFM_PROP_FMHICUTMULTIPATHTRIGGERTHRESHOLD_H 0x1A
357 #define AMFM_PROP_FMHICUTMULTIPATHTRIGGERTHRESHOLD_L 0x04
358 #define AMFM_PROP_FMHICUTMULTIPATHENDTHS_H 0x1A
359 #define AMFM_PROP_FMHICUTMULTIPATHENDTHS_L 0x05
360 #define AMFM_PROP_FMHICUTCUTOFFFREQ_H 0x1A
361 #define AMFM_PROP_FMHICUTCUTOFFFREQ_L 0x06
362 
368 #define AMFM_PROPVALH_RSQREP 0x08
369 #define AMFM_PROPVALH_RDSREP 0x04
370 #define AMFM_PROPVALH_STCREP 0x01
371 #define AMFM_PROPVALL_CTSIEN 0x80
372 #define AMFM_PROPVALL_ERRIEN 0x40
373 #define AMFM_PROPVALL_RSQIEN 0x08
374 #define AMFM_PROPVALL_RDSIEN 0x04
375 #define AMFM_PROPVALL_STCIEN 0x01
376 #define AMFM_PROPVALL_OFALL 0x80
377 #define AMFM_PROPVALL_OMODE_I2S 0x00
378 #define AMFM_PROPVALL_OMODE_LEFTJUST 0x30
379 #define AMFM_PROPVALL_OMODE_MSBATSECONDDCLK 0x40
380 #define AMFM_PROPVALL_OMODE_MSBATFIRSTDCLK 0x60
381 #define AMFM_PROPVALL_OMONO 0x04
382 #define AMFM_PROPVALL_OSIZE_16b 0x00
383 #define AMFM_PROPVALL_OSIZE_20b 0x01
384 #define AMFM_PROPVALL_OSIZE_24b 0x02
385 #define AMFM_PROPVALL_OSIZE_08b 0x03
386 #define AMFM_PROPVALL_DEEMPH_75uS 0x02
387 #define AMFM_PROPVALL_DEEMPH_50uS 0x01
388 #define AMFM_PROPVALL_AUTO 0x00
389 #define AMFM_PROPVALL_WIDE 0x01
390 #define AMFM_PROPVALL_NARROW 0x02
391 #define AMFM_PROPVALL_NARROWER 0x03
392 #define AMFM_PROPVALL_NARROWEST 0x04
393 #define AMFM_PROPVALL_FMTXO 0x01
394 #define AMFM_PROPVALL_BLENDIEN 0x80
395 #define AMFM_PROPVALL_MULTHIEN 0x20
396 #define AMFM_PROPVALL_MULTLIEN 0x10
397 #define AMFM_PROPVALL_SNRHIEN 0x08
398 #define AMFM_PROPVALL_SNRLIEN 0x04
399 #define AMFM_PROPVALL_RSSIHIEN 0x02
400 #define AMFM_PROPVALL_RSSILIEN 0x01
401 #define AMFM_PROPVALL_RDSNEWBLOCKB 0x20
402 #define AMFM_PROPVALL_RDSNEWBLOCKA 0x10
403 #define AMFM_PROPVALL_RDSSYNCFOUND 0x04
404 #define AMFM_PROPVALL_RDSSYNCLOST 0x02
405 #define AMFM_PROPVALL_RDSRECV 0x01
406 #define AMFM_PROPVALH_BLETHA_NOERRORS 0x00
407 #define AMFM_PROPVALH_BLETHA_1TO2ERRORS 0x40
408 #define AMFM_PROPVALH_BLETHA_3TO5ERRORS 0x80
409 #define AMFM_PROPVALH_BLETHA_UNCORRECTABLE 0xC0
410 #define AMFM_PROPVALH_BLETHB_NOERRORS 0x00
411 #define AMFM_PROPVALH_BLETHB_1TO2ERRORS 0x10
412 #define AMFM_PROPVALH_BLETHB_3TO5ERRORS 0x20
413 #define AMFM_PROPVALH_BLETHB_UNCORRECTABLE 0x30
414 #define AMFM_PROPVALH_BLETHC_NOERRORS 0x00
415 #define AMFM_PROPVALH_BLETHC_1TO2ERRORS 0x04
416 #define AMFM_PROPVALH_BLETHC_3TO5ERRORS 0x08
417 #define AMFM_PROPVALH_BLETHC_UNCORRECTABLE 0x0C
418 #define AMFM_PROPVALH_BLETHD_NOERRORS 0x00
419 #define AMFM_PROPVALH_BLETHD_1TO2ERRORS 0x01
420 #define AMFM_PROPVALH_BLETHD_3TO5ERRORS 0x02
421 #define AMFM_PROPVALH_BLETHD_UNCORRECTABLE 0x03
422 #define AMFM_PROPVALL_RDSEN 0x01
423 #define AMFM_PROPVALL_MAXAUDIOFREQ_MAX 0x00
424 #define AMFM_PROPVALL_MAXAUDIOFREQ_2 0x10
425 #define AMFM_PROPVALL_MAXAUDIOFREQ_3 0x20
426 #define AMFM_PROPVALL_MAXAUDIOFREQ_4 0x30
427 #define AMFM_PROPVALL_MAXAUDIOFREQ_5 0x40
428 #define AMFM_PROPVALL_MAXAUDIOFREQ_6 0x50
429 #define AMFM_PROPVALL_MAXAUDIOFREQ_8 0x60
430 #define AMFM_PROPVALL_MAXAUDIOFREQ_11 0x70
431 #define AMFM_PROPVALL_HICUTTRANSFREQ_DISABLED 0x00
432 #define AMFM_PROPVALL_HICUTTRANSFREQ_2 0x01
433 #define AMFM_PROPVALL_HICUTTRANSFREQ_3 0x02
434 #define AMFM_PROPVALL_HICUTTRANSFREQ_4 0x03
435 #define AMFM_PROPVALL_HICUTTRANSFREQ_5 0x04
436 #define AMFM_PROPVALL_HICUTTRANSFREQ_6 0x05
437 #define AMFM_PROPVALL_HICUTTRANSFREQ_8 0x06
438 #define AMFM_PROPVALL_HICUTTRANSFREQ_11 0x07
439 #define AMFM_PROPVALL_LMUTE 0x02
440 #define AMFM_PROPVALL_RMUTE 0x01
441  // End group macro
444 // --------------------------------------------------------------- PUBLIC TYPES
453 typedef struct
454 {
455  // Output pins
456  digital_out_t rst;
457  digital_out_t sen;
458  digital_out_t shd;
459 
460  // Input pins
461  digital_in_t gp1;
462  digital_in_t gp2;
463 
464  pin_name_t gp1_pin;
465  pin_name_t gp2_pin;
466 
467  // Modules
468  i2c_master_t i2c;
469 
470  // ctx variable
471  uint8_t slave_address;
472  uint8_t command_and_arguments_buffer[ 6 ];
473  uint16_t aux_variable;
474  uint8_t response_buffer[ 8 ];
475  uint8_t n_bytes;
476 
477 } amfm_t;
478 
482 typedef struct
483 {
484  // Communication gpio pins
485  pin_name_t scl;
486  pin_name_t sda;
487 
488  // Additional gpio pins
489  pin_name_t gp1;
490  pin_name_t rst;
491  pin_name_t sen;
492  pin_name_t gp2;
493  pin_name_t shd;
494 
495  // static variable
496  uint32_t i2c_speed;
497  uint8_t i2c_address;
498 
499 } amfm_cfg_t;
500  // End types group
502 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
503 
509 #ifdef __cplusplus
510 extern "C"{
511 #endif
512 
522 
531 err_t amfm_init ( amfm_t *ctx, amfm_cfg_t *cfg );
532 
540 void amfm_default_cfg ( amfm_t *ctx );
541 
552 void amfm_generic_write ( amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
553 
564 void amfm_generic_read ( amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
565 
573 uint8_t amfm_an_get ( amfm_t *ctx );
574 
582 uint8_t amfm_int_get ( amfm_t *ctx );
583 
592 void amfm_rst_set ( amfm_t *ctx, uint8_t pin_state );
593 
602 void amfm_cs_set ( amfm_t *ctx, uint8_t pin_state );
603 
612 uint8_t amfm_send_command ( amfm_t *ctx, uint8_t *cmd_and_args_buf );
613 
621 uint8_t amfm_get_cts ( amfm_t *ctx );
622 
630 uint8_t amfm_get_stc ( amfm_t *ctx );
631 
639 uint8_t amfm_get_rsq ( amfm_t *ctx );
640 
648 uint8_t amfm_get_rds ( amfm_t *ctx );
649 
659 uint8_t amfm_get_response ( amfm_t *ctx, uint8_t *resp_buf, uint8_t n_bytes );
660 
669 uint8_t amfm_init_device ( amfm_t *ctx );
670 
679 uint8_t amfm_seek ( amfm_t *ctx );
680 
689 uint8_t amfm_set_volume ( amfm_t *ctx, uint8_t volume );
690 
699 uint8_t amfm_mute ( amfm_t *ctx );
700 
709 uint8_t amfm_unmute ( amfm_t *ctx );
710 
718 uint8_t amfm_tune_up ( amfm_t *ctx );
719 
727 uint8_t amfm_tune_down ( amfm_t *ctx );
728 
737 uint8_t amfm_tune_frequency ( amfm_t *ctx, uint16_t frequency );
738 
746 uint16_t amfm_get_channel ( amfm_t *ctx );
747 
748 #ifdef __cplusplus
749 }
750 #endif
751 #endif // _AMFM_H_
752  // End public_function group
755 
756 // ------------------------------------------------------------------------- END
amfm_t::aux_variable
uint16_t aux_variable
Definition: amfm.h:473
amfm_mute
uint8_t amfm_mute(amfm_t *ctx)
Function for muting device.
amfm_int_get
uint8_t amfm_int_get(amfm_t *ctx)
Function for checking INT pin state.
amfm_send_command
uint8_t amfm_send_command(amfm_t *ctx, uint8_t *cmd_and_args_buf)
Function for sending command and command arguments to device.
amfm_tune_down
uint8_t amfm_tune_down(amfm_t *ctx)
Function for tune down current frequency.
amfm_cfg_t::gp2
pin_name_t gp2
Definition: amfm.h:492
amfm_generic_read
void amfm_generic_read(amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
amfm_get_channel
uint16_t amfm_get_channel(amfm_t *ctx)
Function for getting current channel value.
amfm_cfg_t::shd
pin_name_t shd
Definition: amfm.h:493
amfm_t::gp2_pin
pin_name_t gp2_pin
Definition: amfm.h:465
amfm_t::gp2
digital_in_t gp2
Definition: amfm.h:462
amfm_get_rds
uint8_t amfm_get_rds(amfm_t *ctx)
Function for checking RDS bit.
amfm_cfg_t::sen
pin_name_t sen
Definition: amfm.h:491
amfm_get_rsq
uint8_t amfm_get_rsq(amfm_t *ctx)
Function for checking RSQ bit.
amfm_t::shd
digital_out_t shd
Definition: amfm.h:458
amfm_an_get
uint8_t amfm_an_get(amfm_t *ctx)
Function for checking AN pin state.
amfm_t
Click ctx object definition.
Definition: amfm.h:454
amfm_unmute
uint8_t amfm_unmute(amfm_t *ctx)
Function for unmuting device.
volume
uint8_t volume
Definition: main.c:31
amfm_get_response
uint8_t amfm_get_response(amfm_t *ctx, uint8_t *resp_buf, uint8_t n_bytes)
Function for getting device response.
amfm_get_cts
uint8_t amfm_get_cts(amfm_t *ctx)
Function for checking CTS bit.
amfm_cfg_t::gp1
pin_name_t gp1
Definition: amfm.h:489
amfm_get_stc
uint8_t amfm_get_stc(amfm_t *ctx)
Function for checking STC bit.
amfm_generic_write
void amfm_generic_write(amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
amfm_t::sen
digital_out_t sen
Definition: amfm.h:457
amfm_cfg_t::scl
pin_name_t scl
Definition: amfm.h:485
amfm_t::i2c
i2c_master_t i2c
Definition: amfm.h:468
amfm_t::n_bytes
uint8_t n_bytes
Definition: amfm.h:475
amfm_rst_set
void amfm_rst_set(amfm_t *ctx, uint8_t pin_state)
Function for setting RST pin state.
amfm_t::slave_address
uint8_t slave_address
Definition: amfm.h:471
amfm_t::rst
digital_out_t rst
Definition: amfm.h:456
amfm_t::gp1_pin
pin_name_t gp1_pin
Definition: amfm.h:464
amfm_set_volume
uint8_t amfm_set_volume(amfm_t *ctx, uint8_t volume)
Function for setting volume level.
amfm_init
err_t amfm_init(amfm_t *ctx, amfm_cfg_t *cfg)
Initialization function.
amfm_cfg_setup
void amfm_cfg_setup(amfm_cfg_t *cfg)
Config Object Initialization function.
amfm_default_cfg
void amfm_default_cfg(amfm_t *ctx)
Click Default Configuration function.
amfm_tune_frequency
uint8_t amfm_tune_frequency(amfm_t *ctx, uint16_t frequency)
Function for tuning frequency.
amfm_cfg_t
Click configuration structure definition.
Definition: amfm.h:483
amfm_init_device
uint8_t amfm_init_device(amfm_t *ctx)
Device initialization.
amfm_tune_up
uint8_t amfm_tune_up(amfm_t *ctx)
Function for tune up current frequency.
amfm_cfg_t::sda
pin_name_t sda
Definition: amfm.h:486
amfm_cs_set
void amfm_cs_set(amfm_t *ctx, uint8_t pin_state)
Function for setting CS pin state.
amfm_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: amfm.h:496
amfm_seek
uint8_t amfm_seek(amfm_t *ctx)
Function for seeking next station.
amfm_cfg_t::i2c_address
uint8_t i2c_address
Definition: amfm.h:497
amfm_t::gp1
digital_in_t gp1
Definition: amfm.h:461
amfm_cfg_t::rst
pin_name_t rst
Definition: amfm.h:490