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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
53 #define AMFM_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56  cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
57  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
58  cfg.sen = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_INT ); \
60  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM);
61 
67 #define AMFM_RETVAL uint8_t
68 
69 #define AMFM_OK 0x00
70 #define AMFM_INIT_ERROR 0xFF
71 
77 #define AMFM_DEVICE_ADDRESS 0x11
78 
84 #define AMFM_CMD_PWRUP 0x01
85 #define AMFM_CMD_GETREV 0x10
86 #define AMFM_CMD_PWRDOWN 0x11
87 #define AMFM_CMD_SETPROP 0x12
88 #define AMFM_CMD_GETPROP 0x13
89 #define AMFM_CMD_GETINTSTATUS 0x14
90 #define AMFM_CMD_PATCHARGS 0x15
91 #define AMFM_CMD_PATCHDATA 0x16
92 #define AMFM_CMD_GPIOCTL 0x80
93 #define AMFM_CMD_GPIOSET 0x81
94 
100 #define AMFM_CMD_AMTUNEFREQ 0x40
101 #define AMFM_CMD_AMSEEKSTART 0x41
102 #define AMFM_CMD_AMTUNESTATUS 0x42
103 #define AMFM_CMD_AMRSQSTATUS 0x43
104 #define AMFM_CMD_AMAGCSTATUS 0x47
105 #define AMFM_CMD_AMAGCOVERRIDE 0x48
106 
112 #define AMFM_CMD_FMTUNEFREQ 0x20
113 #define AMFM_CMD_FMSEEKSTART 0x21
114 #define AMFM_CMD_FMTUNESTATUS 0x22
115 #define AMFM_CMD_FMRSQSTATUS 0x23
116 #define AMFM_CMD_FMRDSSTATUS 0x24
117 #define AMFM_CMD_FMAGCSTATUS 0x27
118 #define AMFM_CMD_FMAGCOVERRIDE 0x28
119 
125 #define AMFM_PWRUP_ARG1_CTSIEN 0x80
126 #define AMFM_PWRUP_ARG1_GPO2OEN 0x40
127 #define AMFM_PWRUP_ARG1_PATCH 0x20
128 #define AMFM_PWRUP_ARG1_XOSCEN 0x10
129 #define AMFM_PWRUP_ARG1_FUNC_FMRECEIVE 0x00
130 #define AMFM_PWRUP_ARG1_FUNC_QUERYLIBID 0x0F
131 #define AMFM_PWRUP_ARG2_OPMODE_ANALOGOUT 0x05
132 #define AMFM_PWRUP_ARG2_OPMODE_DIGITALOUT 0x0B
133 #define AMFM_PWRUP_ARG2_OPMODE_DIGITALOUTS 0xB0
134 #define AMFM_PWRUP_ARG2_OPMODE_ANALOGDIGITALOUTS 0xB5
135 #define AMFM_FMTUNEFREQ_ARG1_FREEZE 0x02
136 #define AMFM_FMTUNEFREQ_ARG1_FAST 0x01
137 #define AMFM_FMSEEKSTART_ARG1_SEEKUP 0x08
138 #define AMFM_FMSEEKSTART_ARG1_WRAP 0x04
139 #define AMFM_FMTUNESTATUS_ARG1_CANCEL 0x02
140 #define AMFM_FMTUNESTATUS_ARG1_INTACK 0x01
141 #define AMFM_FMRSQSTATUS_ARG1_INTACK 0x01
142 #define AMFM_FMRDSSTATUS_ARG1_STATUSONLY 0x04
143 #define AMFM_FMRDSSTATUS_ARG1_MTFIFO 0x02
144 #define AMFM_FMRDSSTATUS_ARG1_INTACK 0x01
145 #define AMFM_FMAGCOVERRIDE_ARG1_RFAGCDIS 0x01
146 #define AMFM_GPIOCTL_ARG1_GPO3OEN 0x08
147 #define AMFM_GPIOCTL_ARG1_GPO2OEN 0x04
148 #define AMFM_GPIOCTL_ARG1_GPO1OEN 0x02
149 #define AMFM_GPIOSET_ARG1_GPO3LEVEL 0x08
150 #define AMFM_GPIOSET_ARG1_GPO2LEVEL 0x04
151 #define AMFM_GPIOSET_ARG1_GPO1LEVEL 0x02
152 
158 #define AMFM_PROP_GPOIEN_H 0x00
159 #define AMFM_PROP_GPOIEN_L 0x01
160 #define AMFM_PROP_DIGITALOUTFORMAT_H 0x01
161 #define AMFM_PROP_DIGITALOUTFORMAT_L 0x02
162 #define AMFM_PROP_DIGITALOUTSAMPLERATE_H 0x01
163 #define AMFM_PROP_DIGITALOUTSAMPLERATE_L 0x04
164 #define AMFM_PROP_REFCLKFREQ_H 0x02
165 #define AMFM_PROP_REFCLKFREQ_L 0x01
166 #define AMFM_PROP_REFCLKPRESCALE_H 0x02
167 #define AMFM_PROP_REFCLKPRESCALE_L 0x02
168 #define AMFM_PROP_RXVOLUME_H 0x40
169 #define AMFM_PROP_RXVOLUME_L 0x00
170 #define AMFM_PROP_RXHMUTE_H 0x40
171 #define AMFM_PROP_RXHMUTE_L 0x01
172 
178 #define AMFM_PROP_FMDEEMPHASIS_H 0x11
179 #define AMFM_PROP_FMDEEMPHASIS_L 0x00
180 #define AMFM_PROP_AMDEEMPHASIS_H 0x31
181 #define AMFM_PROP_AMDEEMPHASIS_L 0x00
182 #define AMFM_PROP_FMCHANFILTER_H 0x11
183 #define AMFM_PROP_FMCHANFILTER_L 0x02
184 #define AMFM_PROP_AMCHANFILTER_H 0x31
185 #define AMFM_PROP_AMCHANFILTER_L 0x02
186 #define AMFM_PROP_AMAUTOVOLCTRLMAXGAIN_H 0x31
187 #define AMFM_PROP_AMAUTOVOLCTRLMAXGAIN_L 0x03
188 #define AMFM_PROP_AMMODEAFCSWPULLINRANGE_H 0x31
189 #define AMFM_PROP_AMMODEAFCSWPULLINRANGE_L 0x04
190 #define AMFM_PROP_AMMODEAFCSWLOCKINRANGE_H 0x31
191 #define AMFM_PROP_AMMODEAFCSWLOCKINRANGE_L 0x05
192 #define AMFM_PROP_AMRSQINTS_H 0x32
193 #define AMFM_PROP_AMRSQINTS_L 0x00
194 #define AMFM_PROP_AMRSQSNRHITHS_H 0x32
195 #define AMFM_PROP_AMRSQSNRHITHS_L 0x01
196 #define AMFM_PROP_AMRSQSNRLOTHS_H 0x32
197 #define AMFM_PROP_AMRSQSNRLOTHS_L 0x02
198 #define AMFM_PROP_AMRSQRSSIHITHS_H 0x32
199 #define AMFM_PROP_AMRSQRSSIHITHS_L 0x03
200 #define AMFM_PROP_AMRSQRSSILOTHS_H 0x32
201 #define AMFM_PROP_AMRSQRSSILOTHS_L 0x04
202 #define AMFM_PROP_AMSMUTERATE_H 0x33
203 #define AMFM_PROP_AMSMUTERATE_L 0x00
204 #define AMFM_PROP_AMSMUTESLOPE_H 0x33
205 #define AMFM_PROP_AMSMUTESLOPE_L 0x01
206 #define AMFM_PROP_AMSMUTEMAXATTENUATION_H 0x33
207 #define AMFM_PROP_AMSMUTEMAXATTENUATION_L 0x02
208 #define AMFM_PROP_AMSMUTESNRTHS_H 0x33
209 #define AMFM_PROP_AMSMUTESNRTHS_L 0x03
210 #define AMFM_PROP_AMSMUTERELEASERATE_H 0x33
211 #define AMFM_PROP_AMSMUTERELEASERATE_L 0x04
212 #define AMFM_PROP_AMSMUTEATTACKRATE_H 0x33
213 #define AMFM_PROP_AMSMUTEATTACKRATE_L 0x05
214 #define AMFM_PROP_AMSEEKBANDBOT_H 0x34
215 #define AMFM_PROP_AMSEEKBANDBOT_L 0x00
216 #define AMFM_PROP_AMSEEKBANDTOP_H 0x34
217 #define AMFM_PROP_AMSEEKBANDTOP_L 0x01
218 #define AMFM_PROP_AMSEEKFREQSPACING_H 0x34
219 #define AMFM_PROP_AMSEEKFREQSPACING_L 0x02
220 #define AMFM_PROP_AMSEEKTUNESNRTHS_H 0x34
221 #define AMFM_PROP_AMSEEKTUNESNRTHS_L 0x03
222 #define AMFM_PROP_AMSEEKTUNERSSITHS_H 0x34
223 #define AMFM_PROP_AMSEEKTUNERSSITHS_L 0x04
224 #define AMFM_PROP_AMAGCATTACKRATE_H 0x37
225 #define AMFM_PROP_AMAGCATTACKRATE_L 0x02
226 #define AMFM_PROP_AMAGCRELEASERATE_H 0x37
227 #define AMFM_PROP_AMAGCRELEASERATE_L 0x03
228 #define AMFM_PROP_AMFRONTENDAGCCTRL_H 0x37
229 #define AMFM_PROP_AMFRONTENDAGCCTRL_L 0x05
230 #define AMFM_PROP_AMNBDETECTTHS_H 0x39
231 #define AMFM_PROP_AMNBDETECTTHS_L 0x00
232 #define AMFM_PROP_AMNBINTERVAL_H 0x39
233 #define AMFM_PROP_AMNBINTERVAL_L 0x01
234 #define AMFM_PROP_AMNBRATE_H 0x39
235 #define AMFM_PROP_AMNBRATE_L 0x02
236 #define AMFM_PROP_AMNBIIRFILTER_H 0x39
237 #define AMFM_PROP_AMNBIIRFILTER_L 0x03
238 #define AMFM_PROP_AMNBDELAY_H 0x39
239 #define AMFM_PROP_AMNBDELAY_L 0x04
240 
246 #define AMFM_PROP_FMBLENDSTEREOTHS_H 0x11
247 #define AMFM_PROP_FMBLENDSTEREOTHS_L 0x05
248 #define AMFM_PROP_FMBLENDMONOTHS_H 0x11
249 #define AMFM_PROP_FMBLENDMONOTHS_L 0x06
250 #define AMFM_PROP_FMANTENNAIN_H 0x11
251 #define AMFM_PROP_FMANTENNAIN_L 0x07
252 #define AMFM_PROP_FMMAXTUNEERR_H 0x11
253 #define AMFM_PROP_FMMAXTUNEERR_L 0x08
254 #define AMFM_PROP_FMRSQINTSRC_H 0x12
255 #define AMFM_PROP_FMRSQINTSRC_L 0x00
256 #define AMFM_PROP_FMRSQSNRHITHS_H 0x12
257 #define AMFM_PROP_FMRSQSNRHITHS_L 0x01
258 #define AMFM_PROP_FMRSQSNRLOTHS_H 0x12
259 #define AMFM_PROP_FMRSQSNRLOTHS_L 0x02
260 #define AMFM_PROP_FMRSQRSSIHITHS_H 0x12
261 #define AMFM_PROP_FMRSQRSSIHITHS_L 0x03
262 #define AMFM_PROP_FMRSQRSSILOTHS_H 0x12
263 #define AMFM_PROP_FMRSQRSSILOTHS_L 0x04
264 #define AMFM_PROP_FMRSQMULTIPATHHITHS_H 0x12
265 #define AMFM_PROP_FMRSQMULTIPATHHITHS_L 0x05
266 #define AMFM_PROP_FMRSQMULTIPATHLOTHS_H 0x12
267 #define AMFM_PROP_FMRSQMULTIPATHLOTHS_L 0x06
268 #define AMFM_PROP_FMRSQBLENDTHS_H 0x12
269 #define AMFM_PROP_FMRSQBLENDTHS_L 0x07
270 #define AMFM_PROP_FMSMUTERATE_H 0x13
271 #define AMFM_PROP_FMSMUTERATE_L 0x00
272 #define AMFM_PROP_FMSMUTESLOPE_H 0x13
273 #define AMFM_PROP_FMSMUTESLOPE_L 0x01
274 #define AMFM_PROP_FMSMUTEMAXATTENUATION_H 0x13
275 #define AMFM_PROP_FMSMUTEMAXATTENUATION_L 0x02
276 #define AMFM_PROP_FMSMUTESNRTHS_H 0x13
277 #define AMFM_PROP_FMSMUTESNRTHS_L 0x03
278 #define AMFM_PROP_FMSMUTERELEASERATE_H 0x13
279 #define AMFM_PROP_FMSMUTERELEASERATE_L 0x04
280 #define AMFM_PROP_FMSMUTEATTACKRATE_H 0x13
281 #define AMFM_PROP_FMSMUTEATTACKRATE_L 0x05
282 #define AMFM_PROP_FMSEEKBANDBOT_H 0x14
283 #define AMFM_PROP_FMSEEKBANDBOT_L 0x00
284 #define AMFM_PROP_FMSEEKBANDTOP_H 0x14
285 #define AMFM_PROP_FMSEEKBANDTOP_L 0x01
286 #define AMFM_PROP_FMSEEKFREQSPACING_H 0x14
287 #define AMFM_PROP_FMSEEKFREQSPACING_L 0x02
288 #define AMFM_PROP_FMSEEKTUNESNRTHS_H 0x14
289 #define AMFM_PROP_FMSEEKTUNESNRTHS_L 0x03
290 #define AMFM_PROP_FMSEEKTUNERSSITHS_H 0x14
291 #define AMFM_PROP_FMSEEKTUNERSSITHS_L 0x04
292 #define AMFM_PROP_FMRDSINTSRC_H 0x15
293 #define AMFM_PROP_FMRDSINTSRC_L 0x00
294 #define AMFM_PROP_FMRDSINTFIFOCOUNT_H 0x15
295 #define AMFM_PROP_FMRDSINTFIFOCOUNT_L 0x01
296 #define AMFM_PROP_FMRDSCFG_H 0x15
297 #define AMFM_PROP_FMRDSCFG_L 0x02
298 #define AMFM_PROP_FMRDSCONFIDENCE_H 0x15
299 #define AMFM_PROP_FMRDSCONFIDENCE_L 0x03
300 #define AMFM_PROP_FMAGCATTACKRATE_H 0x17
301 #define AMFM_PROP_FMAGCATTACKRATE_L 0x00
302 #define AMFM_PROP_FMAGCRELEASERATE_H 0x17
303 #define AMFM_PROP_FMAGCRELEASERATE_L 0x01
304 #define AMFM_PROP_FMBLENDRSSISTEREOTHS_H 0x18
305 #define AMFM_PROP_FMBLENDRSSISTEREOTHS_L 0x00
306 #define AMFM_PROP_FMBLENDRSSIMONOTHS_H 0x18
307 #define AMFM_PROP_FMBLENDRSSIMONOTHS_L 0x01
308 #define AMFM_PROP_FMBLENDRSSIATTACKRATE_H 0x18
309 #define AMFM_PROP_FMBLENDRSSIATTACKRATE_L 0x02
310 #define AMFM_PROP_FMBLENDRSSIRELEASERATE_H 0x18
311 #define AMFM_PROP_FMBLENDRSSIRELEASERATE_L 0x03
312 #define AMFM_PROP_FMBLENDSNRSTEREOTHS_H 0x18
313 #define AMFM_PROP_FMBLENDSNRSTEREOTHS_L 0x04
314 #define AMFM_PROP_FMBLENDSNRMONOTHS_H 0x18
315 #define AMFM_PROP_FMBLENDSNRMONOTHS_L 0x05
316 #define AMFM_PROP_FMBLENDSNRATTACKRATE_H 0x18
317 #define AMFM_PROP_FMBLENDSNRATTACKRATE_L 0x06
318 #define AMFM_PROP_FMBLENDSNRRELEASERATE_H 0x18
319 #define AMFM_PROP_FMBLENDSNRRELEASERATE_L 0x07
320 #define AMFM_PROP_FMBLENDMULTIPATHSTEREOTHS_H 0x18
321 #define AMFM_PROP_FMBLENDMULTIPATHSTEREOTHS_L 0x08
322 #define AMFM_PROP_FMBLENDMULTIPATHMONOTHS_H 0x18
323 #define AMFM_PROP_FMBLENDMULTIPATHMONOTHS_L 0x09
324 #define AMFM_PROP_FMBLENDMULTIPATHATTACKRATE_H 0x18
325 #define AMFM_PROP_FMBLENDMULTIPATHATTACKRATE_L 0x0A
326 #define AMFM_PROP_FMBLENDMULTIPATHRELEASERATE_H 0x18
327 #define AMFM_PROP_FMBLENDMULTIPATHRELEASERATE_L 0x0B
328 #define AMFM_PROP_FMBLENDMAXSTEREOSEPARATION_H 0x18
329 #define AMFM_PROP_FMBLENDMAXSTEREOSEPARATION_L 0x0C
330 #define AMFM_PROP_FMNBDETECTTHS_H 0x19
331 #define AMFM_PROP_FMNBDETECTTHS_L 0x00
332 #define AMFM_PROP_FMNBINTERVAL_H 0x19
333 #define AMFM_PROP_FMNBINTERVAL_L 0x01
334 #define AMFM_PROP_FMNBRATE_H 0x19
335 #define AMFM_PROP_FMNBRATE_L 0x02
336 #define AMFM_PROP_FMNBIIRFILTER_H 0x19
337 #define AMFM_PROP_FMNBIIRFILTER_L 0x03
338 #define AMFM_PROP_FMNBDELAY_H 0x19
339 #define AMFM_PROP_FMNBDELAY_L 0x04
340 #define AMFM_PROP_FMHICUTSNRHITHS_H 0x1A
341 #define AMFM_PROP_FMHICUTSNRHITHS_L 0x00
342 #define AMFM_PROP_FMHICUTSNRLOTHS_H 0x1A
343 #define AMFM_PROP_FMHICUTSNRLOTHS_L 0x01
344 #define AMFM_PROP_FMHICUTATTACKRATE_H 0x1A
345 #define AMFM_PROP_FMHICUTATTACKRATE_L 0x02
346 #define AMFM_PROP_FMHICUTRELEASERATE_H 0x1A
347 #define AMFM_PROP_FMHICUTRELEASERATE_L 0x03
348 #define AMFM_PROP_FMHICUTMULTIPATHTRIGGERTHRESHOLD_H 0x1A
349 #define AMFM_PROP_FMHICUTMULTIPATHTRIGGERTHRESHOLD_L 0x04
350 #define AMFM_PROP_FMHICUTMULTIPATHENDTHS_H 0x1A
351 #define AMFM_PROP_FMHICUTMULTIPATHENDTHS_L 0x05
352 #define AMFM_PROP_FMHICUTCUTOFFFREQ_H 0x1A
353 #define AMFM_PROP_FMHICUTCUTOFFFREQ_L 0x06
354 
360 #define AMFM_PROPVALH_RSQREP 0x08
361 #define AMFM_PROPVALH_RDSREP 0x04
362 #define AMFM_PROPVALH_STCREP 0x01
363 #define AMFM_PROPVALL_CTSIEN 0x80
364 #define AMFM_PROPVALL_ERRIEN 0x40
365 #define AMFM_PROPVALL_RSQIEN 0x08
366 #define AMFM_PROPVALL_RDSIEN 0x04
367 #define AMFM_PROPVALL_STCIEN 0x01
368 #define AMFM_PROPVALL_OFALL 0x80
369 #define AMFM_PROPVALL_OMODE_I2S 0x00
370 #define AMFM_PROPVALL_OMODE_LEFTJUST 0x30
371 #define AMFM_PROPVALL_OMODE_MSBATSECONDDCLK 0x40
372 #define AMFM_PROPVALL_OMODE_MSBATFIRSTDCLK 0x60
373 #define AMFM_PROPVALL_OMONO 0x04
374 #define AMFM_PROPVALL_OSIZE_16b 0x00
375 #define AMFM_PROPVALL_OSIZE_20b 0x01
376 #define AMFM_PROPVALL_OSIZE_24b 0x02
377 #define AMFM_PROPVALL_OSIZE_08b 0x03
378 #define AMFM_PROPVALL_DEEMPH_75uS 0x02
379 #define AMFM_PROPVALL_DEEMPH_50uS 0x01
380 #define AMFM_PROPVALL_AUTO 0x00
381 #define AMFM_PROPVALL_WIDE 0x01
382 #define AMFM_PROPVALL_NARROW 0x02
383 #define AMFM_PROPVALL_NARROWER 0x03
384 #define AMFM_PROPVALL_NARROWEST 0x04
385 #define AMFM_PROPVALL_FMTXO 0x01
386 #define AMFM_PROPVALL_BLENDIEN 0x80
387 #define AMFM_PROPVALL_MULTHIEN 0x20
388 #define AMFM_PROPVALL_MULTLIEN 0x10
389 #define AMFM_PROPVALL_SNRHIEN 0x08
390 #define AMFM_PROPVALL_SNRLIEN 0x04
391 #define AMFM_PROPVALL_RSSIHIEN 0x02
392 #define AMFM_PROPVALL_RSSILIEN 0x01
393 #define AMFM_PROPVALL_RDSNEWBLOCKB 0x20
394 #define AMFM_PROPVALL_RDSNEWBLOCKA 0x10
395 #define AMFM_PROPVALL_RDSSYNCFOUND 0x04
396 #define AMFM_PROPVALL_RDSSYNCLOST 0x02
397 #define AMFM_PROPVALL_RDSRECV 0x01
398 #define AMFM_PROPVALH_BLETHA_NOERRORS 0x00
399 #define AMFM_PROPVALH_BLETHA_1TO2ERRORS 0x40
400 #define AMFM_PROPVALH_BLETHA_3TO5ERRORS 0x80
401 #define AMFM_PROPVALH_BLETHA_UNCORRECTABLE 0xC0
402 #define AMFM_PROPVALH_BLETHB_NOERRORS 0x00
403 #define AMFM_PROPVALH_BLETHB_1TO2ERRORS 0x10
404 #define AMFM_PROPVALH_BLETHB_3TO5ERRORS 0x20
405 #define AMFM_PROPVALH_BLETHB_UNCORRECTABLE 0x30
406 #define AMFM_PROPVALH_BLETHC_NOERRORS 0x00
407 #define AMFM_PROPVALH_BLETHC_1TO2ERRORS 0x04
408 #define AMFM_PROPVALH_BLETHC_3TO5ERRORS 0x08
409 #define AMFM_PROPVALH_BLETHC_UNCORRECTABLE 0x0C
410 #define AMFM_PROPVALH_BLETHD_NOERRORS 0x00
411 #define AMFM_PROPVALH_BLETHD_1TO2ERRORS 0x01
412 #define AMFM_PROPVALH_BLETHD_3TO5ERRORS 0x02
413 #define AMFM_PROPVALH_BLETHD_UNCORRECTABLE 0x03
414 #define AMFM_PROPVALL_RDSEN 0x01
415 #define AMFM_PROPVALL_MAXAUDIOFREQ_MAX 0x00
416 #define AMFM_PROPVALL_MAXAUDIOFREQ_2 0x10
417 #define AMFM_PROPVALL_MAXAUDIOFREQ_3 0x20
418 #define AMFM_PROPVALL_MAXAUDIOFREQ_4 0x30
419 #define AMFM_PROPVALL_MAXAUDIOFREQ_5 0x40
420 #define AMFM_PROPVALL_MAXAUDIOFREQ_6 0x50
421 #define AMFM_PROPVALL_MAXAUDIOFREQ_8 0x60
422 #define AMFM_PROPVALL_MAXAUDIOFREQ_11 0x70
423 #define AMFM_PROPVALL_HICUTTRANSFREQ_DISABLED 0x00
424 #define AMFM_PROPVALL_HICUTTRANSFREQ_2 0x01
425 #define AMFM_PROPVALL_HICUTTRANSFREQ_3 0x02
426 #define AMFM_PROPVALL_HICUTTRANSFREQ_4 0x03
427 #define AMFM_PROPVALL_HICUTTRANSFREQ_5 0x04
428 #define AMFM_PROPVALL_HICUTTRANSFREQ_6 0x05
429 #define AMFM_PROPVALL_HICUTTRANSFREQ_8 0x06
430 #define AMFM_PROPVALL_HICUTTRANSFREQ_11 0x07
431 #define AMFM_PROPVALL_LMUTE 0x02
432 #define AMFM_PROPVALL_RMUTE 0x01
433  // End group macro
436 // --------------------------------------------------------------- PUBLIC TYPES
445 typedef struct
446 {
447  // Output pins
448 
449  digital_out_t rst;
450  digital_out_t sen;
451 
452  // Input pins
453  digital_in_t pwm;
454  digital_in_t gp1;
455  digital_in_t gp2;
456 
457  // Modules
458 
459  i2c_master_t i2c;
460 
461  // ctx variable
462 
463  uint8_t slave_address;
464 
465  uint8_t command_and_arguments_buffer[ 6 ];
466  uint16_t aux_variable;
467  uint8_t response_buffer[ 8 ];
468  uint8_t n_bytes;
469 
470 } amfm_t;
471 
475 typedef struct
476 {
477  // Communication gpio pins
478 
479  pin_name_t scl;
480  pin_name_t sda;
481 
482  // Additional gpio pins
483 
484  pin_name_t gp1;
485  pin_name_t rst;
486  pin_name_t sen;
487  pin_name_t gp2;
488  pin_name_t pwm;
489 
490  // static variable
491 
492  uint32_t i2c_speed;
493  uint8_t i2c_address;
494 
495 } amfm_cfg_t;
496  // End types group
498 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
499 
505 #ifdef __cplusplus
506 extern "C"{
507 #endif
508 
517 void amfm_cfg_setup ( amfm_cfg_t *cfg );
518 
527 AMFM_RETVAL amfm_init ( amfm_t *ctx, amfm_cfg_t *cfg );
528 
536 void amfm_default_cfg ( amfm_t *ctx );
537 
548 void amfm_generic_write ( amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
549 
560 void amfm_generic_read ( amfm_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
561 
569 uint8_t amfm_an_get ( amfm_t *ctx );
570 
578 uint8_t amfm_int_get ( amfm_t *ctx );
579 
588 void amfm_rst_set ( amfm_t *ctx, uint8_t pin_state );
589 
598 void amfm_cs_set ( amfm_t *ctx, uint8_t pin_state );
599 
608 uint8_t amfm_send_command ( amfm_t *ctx, uint8_t *cmd_and_args_buf );
609 
617 uint8_t amfm_get_cts ( amfm_t *ctx );
618 
626 uint8_t amfm_get_stc ( amfm_t *ctx );
627 
635 uint8_t amfm_get_rsq ( amfm_t *ctx );
636 
644 uint8_t amfm_get_rds ( amfm_t *ctx );
645 
655 uint8_t amfm_get_response ( amfm_t *ctx, uint8_t *resp_buf, uint8_t n_bytes );
656 
665 uint8_t amfm_init_device ( amfm_t *ctx );
666 
675 uint8_t amfm_seek ( amfm_t *ctx );
676 
685 uint8_t amfm_set_volume ( amfm_t *ctx, uint8_t volume );
686 
695 uint8_t amfm_mute ( amfm_t *ctx );
696 
705 uint8_t amfm_unmute ( amfm_t *ctx );
706 
714 uint8_t amfm_tune_up ( amfm_t *ctx );
715 
723 uint8_t amfm_tune_down ( amfm_t *ctx );
724 
733 uint8_t amfm_tune_frequency ( amfm_t *ctx, uint16_t frequency );
734 
742 uint16_t amfm_get_channel ( amfm_t *ctx );
743 
744 #ifdef __cplusplus
745 }
746 #endif
747 #endif // _AMFM_H_
748  // End public_function group
751 
752 // ------------------------------------------------------------------------- END
amfm_t::aux_variable
uint16_t aux_variable
Definition: amfm.h:466
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:487
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_t::gp2
digital_in_t gp2
Definition: amfm.h:455
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:486
amfm_get_rsq
uint8_t amfm_get_rsq(amfm_t *ctx)
Function for checking RSQ bit.
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:445
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:484
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::pwm
digital_in_t pwm
Definition: amfm.h:453
amfm_t::sen
digital_out_t sen
Definition: amfm.h:450
amfm_cfg_t::scl
pin_name_t scl
Definition: amfm.h:479
amfm_t::i2c
i2c_master_t i2c
Definition: amfm.h:459
amfm_t::n_bytes
uint8_t n_bytes
Definition: amfm.h:468
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:463
amfm_t::rst
digital_out_t rst
Definition: amfm.h:449
amfm_set_volume
uint8_t amfm_set_volume(amfm_t *ctx, uint8_t volume)
Function for setting volume level.
amfm_init
AMFM_RETVAL 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_RETVAL
#define AMFM_RETVAL
Definition: amfm.h:67
amfm_cfg_t::pwm
pin_name_t pwm
Definition: amfm.h:488
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:475
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:480
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:492
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:493
amfm_t::gp1
digital_in_t gp1
Definition: amfm.h:454
amfm_cfg_t::rst
pin_name_t rst
Definition: amfm.h:485