Go to the documentation of this file.
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"
77 #define AMFM2_CMD_POWER_UP 0x01
78 #define AMFM2_CMD_GET_REV 0x10
79 #define AMFM2_CMD_POWER_DOWN 0x11
80 #define AMFM2_CMD_SET_PROPERTY 0x12
81 #define AMFM2_CMD_GET_PROPERTY 0x13
82 #define AMFM2_CMD_GET_INT_STATUS 0x14
83 #define AMFM2_CMD_PATCH_ARGS 0x15
84 #define AMFM2_CMD_PATCH_DATA 0x16
85 #define AMFM2_CMD_TX_TUNE_FREQ 0x30
86 #define AMFM2_CMD_TX_TUNE_POWER 0x31
87 #define AMFM2_CMD_TX_TUNE_MEASURE 0x32
88 #define AMFM2_CMD_TX_TUNE_STATUS 0x33
89 #define AMFM2_CMD_TX_ASQ_STATUS 0x34
90 #define AMFM2_CMD_TX_RDS_BUFF 0x35
91 #define AMFM2_CMD_TX_TX_RDS_PS 0x36
92 #define AMFM2_CMD_GPIO_CTL 0x80
93 #define AMFM2_CMD_GPIO_SET 0x81
99 #define AMFM2_CMD_AM_TUNE_FREQ 0x40
100 #define AMFM2_CMD_AM_SEEK_START 0x41
101 #define AMFM2_CMD_AM_TUNE_STATUS 0x42
102 #define AMFM2_CMD_AM_RSQ_STATUS 0x43
103 #define AMFM2_CMD_AM_AGC_STATUS 0x47
104 #define AMFM2_CMD_AM_AGC_OVERRIDE 0x48
110 #define AMFM2_CMD_FM_TUNE_FREQ 0x20
111 #define AMFM2_CMD_FM_SEEK_START 0x21
112 #define AMFM2_CMD_FM_TUNE_STATUS 0x22
113 #define AMFM2_CMD_FM_RSQ_STATUS 0x23
114 #define AMFM2_CMD_FM_RDS_STATUS 0x24
115 #define AMFM2_CMD_FM_AGC_STATUS 0x27
116 #define AMFM2_CMD_FM_AGC_OVERRIDE 0x28
134 #define AMFM2_RSP_STATUS_CTS 0x80
135 #define AMFM2_RSP_STATUS_ERROR 0x40
136 #define AMFM2_RSP_STATUS_RDSINT 0x04
137 #define AMFM2_RSP_STATUS_ASQINT 0x02
138 #define AMFM2_RSP_STATUS_STCINT 0x01
144 #define AMFM2_PWRUP_ARG_CTSIEN 0x80
145 #define AMFM2_PWRUP_ARG_GPO2OEN 0x40
146 #define AMFM2_PWRUP_ARG_PATCH 0x20
147 #define AMFM2_PWRUP_ARG_XOSCEN 0x10
148 #define AMFM2_PWRUP_ARG_FUNC_FMRECEIVE 0x00
149 #define AMFM2_PWRUP_ARG_FUNC_QUERYLIBID 0x0F
150 #define AMFM2_PWRUP_ARG_OPMODE_ANALOGOUT 0x05
151 #define AMFM2_PWRUP_ARG_OPMODE_DIGITALOUT 0x0B
152 #define AMFM2_PWRUP_ARG_OPMODE_DIGITALOUTS 0xB0
153 #define AMFM2_FMTUNEFREQ_ARG_FREEZE 0x02
154 #define AMFM2_FMTUNEFREQ_ARG_FAST 0x01
155 #define AMFM2_FMSEEKSTART_ARG_SEEKUP 0x08
156 #define AMFM2_FMSEEKSTART_ARG_WRAP 0x04
157 #define AMFM2_FMTUNESTATUS_ARG_CANCEL 0x02
158 #define AMFM2_FMTUNESTATUS_ARG_INTACK 0x01
159 #define AMFM2_FMRSQSTATUS_ARG_INTACK 0x01
160 #define AMFM2_FMRDSSTATUS_ARG_STATUSONLY 0x04
161 #define AMFM2_FMRDSSTATUS_ARG_MTFIFO 0x02
162 #define AMFM2_FMRDSSTATUS_ARG_INTACK 0x01
163 #define AMFM2_FMAGCOVERRIDE_ARG_RFAGCDIS 0x01
164 #define AMFM2_GPIOCTL_ARG_GPO3OEN 0x08
165 #define AMFM2_GPIOCTL_ARG_GPO2OEN 0x04
166 #define AMFM2_GPIOCTL_ARG_GPO1OEN 0x02
167 #define AMFM2_GPIOSET_ARG_GPO3LEVEL 0x08
168 #define AMFM2_GPIOSET_ARG_GPO2LEVEL 0x04
169 #define AMFM2_GPIOSET_ARG_GPO1LEVEL 0x02
175 #define AMFM2_SET_VOLUME_MUTE 0
176 #define AMFM2_SET_VOLUME_MAX 63
182 #define AMFM2_PROP_GPOIEN_H 0x00
183 #define AMFM2_PROP_GPOIEN_L 0x01
184 #define AMFM2_PROP_DIGITALOUTFORMAT_H 0x01
185 #define AMFM2_PROP_DIGITALOUTFORMAT_L 0x02
186 #define AMFM2_PROP_DIGITALOUTSAMPLERATE_H 0x01
187 #define AMFM2_PROP_DIGITALOUTSAMPLERATE_L 0x04
188 #define AMFM2_PROP_REFCLKFREQ_H 0x02
189 #define AMFM2_PROP_REFCLKFREQ_L 0x01
190 #define AMFM2_PROP_REFCLKPRESCALE_H 0x02
191 #define AMFM2_PROP_REFCLKPRESCALE_L 0x02
192 #define AMFM2_PROP_RXVOLUME_H 0x40
193 #define AMFM2_PROP_RXVOLUME_L 0x00
194 #define AMFM2_PROP_RXHMUTE_H 0x40
195 #define AMFM2_PROP_RXHMUTE_L 0x01
201 #define AMFM2_PROP_FMDEEMPHASIS_H 0x11
202 #define AMFM2_PROP_FMDEEMPHASIS_L 0x00
203 #define AMFM2_PROP_AMDEEMPHASIS_H 0x31
204 #define AMFM2_PROP_AMDEEMPHASIS_L 0x00
205 #define AMFM2_PROP_FMCHANFILTER_H 0x11
206 #define AMFM2_PROP_FMCHANFILTER_L 0x02
207 #define AMFM2_PROP_AMCHANFILTER_H 0x31
208 #define AMFM2_PROP_AMCHANFILTER_L 0x02
209 #define AMFM2_PROP_AMRSQINTS_H 0x32
210 #define AMFM2_PROP_AMRSQINTS_L 0x00
211 #define AMFM2_PROP_AMNBRATE_H 0x39
212 #define AMFM2_PROP_AMNBRATE_L 0x02
213 #define AMFM2_PROP_AMNBIIRFILTER_H 0x39
214 #define AMFM2_PROP_AMNBIIRFILTER_L 0x03
215 #define AMFM2_PROP_AMNBDELAY_H 0x39
216 #define AMFM2_PROP_AMNBDELAY_L 0x04
222 #define AMFM2_PROP_FMBLENDSTEREOTHS_H 0x11
223 #define AMFM2_PROP_FMBLENDSTEREOTHS_L 0x05
224 #define AMFM2_PROP_FMBLENDMONOTHS_H 0x11
225 #define AMFM2_PROP_FMBLENDMONOTHS_L 0x06
226 #define AMFM2_PROP_FMNBDETECTTHS_H 0x19
227 #define AMFM2_PROP_FMNBDETECTTHS_L 0x00
228 #define AMFM2_PROP_FMNBINTERVAL_H 0x19
229 #define AMFM2_PROP_FMNBINTERVAL_L 0x01
230 #define AMFM2_PROP_FMNBRATE_H 0x19
231 #define AMFM2_PROP_FMNBRATE_L 0x02
232 #define AMFM2_PROP_FMNBIIRFILTER_H 0x19
233 #define AMFM2_PROP_FMNBIIRFILTER_L 0x03
234 #define AMFM2_PROP_FMNBDELAY_H 0x19
235 #define AMFM2_PROP_FMNBDELAY_L 0x04
241 #define AMFM2_PROPVALH_RSQREP 0x08
242 #define AMFM2_PROPVALH_RDSREP 0x04
243 #define AMFM2_PROPVALH_STCREP 0x01
244 #define AMFM2_PROPVALL_CTSIEN 0x80
245 #define AMFM2_PROPVALL_ERRIEN 0x40
246 #define AMFM2_PROPVALL_RSQIEN 0x08
247 #define AMFM2_PROPVALL_RDSIEN 0x04
248 #define AMFM2_PROPVALL_STCIEN 0x01
249 #define AMFM2_PROPVALL_OFALL 0x80
250 #define AMFM2_PROPVALL_LMUTE 0x02
251 #define AMFM2_PROPVALL_RMUTE 0x01
258 #define AMFM2_DEVICE_ADDRESS_GND 0x11
259 #define AMFM2_DEVICE_ADDRESS_VCC 0x63
277 #define AMFM2_MAP_MIKROBUS( cfg, mikrobus ) \
278 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
279 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
280 cfg.ema = MIKROBUS( mikrobus, MIKROBUS_AN ); \
281 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
282 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
283 cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_INT )
541 uint8_t arg_len, uint8_t *rsp, uint8_t rsp_len );
uint8_t chiprev
Definition: amfm2.h:341
err_t amfm2_get_rev(amfm2_t *ctx, amfm2_device_info_t *rev)
AM/FM 2 get revision information function.
AM/FM 2 Click device information object.
Definition: amfm2.h:334
err_t amfm2_tuning_freq(amfm2_t *ctx, float frequency, uint8_t *rsp)
AM/FM 2 tuning frequency function.
err_t amfm2_sound_on(amfm2_t *ctx, uint8_t *rsp)
AM/FM 2 sound on function.
uint8_t fwminor
Definition: amfm2.h:337
@ AMFM2_OK
Definition: amfm2.h:351
uint32_t i2c_speed
Definition: amfm2.h:324
void amfm2_headphone_amp_disable(amfm2_t *ctx)
AM/FM 2 disable headphone amp function.
err_t amfm2_wait_rsp(amfm2_t *ctx)
AM/FM 2 wait response function.
void amfm2_headphone_amp_enable(amfm2_t *ctx)
AM/FM 2 enable headphone amp function.
AM/FM 2 Click configuration object.
Definition: amfm2.h:315
amfm2_return_value_t
AM/FM 2 Click return value data.
Definition: amfm2.h:350
err_t amfm2_get_response(amfm2_t *ctx, uint8_t *rsp, uint8_t rsp_len)
AM/FM 2 get response function.
uint8_t cmpmajor
Definition: amfm2.h:339
pin_name_t ema
Definition: amfm2.h:319
uint8_t fwmajor
Definition: amfm2.h:336
pin_name_t gp2
Definition: amfm2.h:322
err_t amfm2_check_seek_tune_complete(amfm2_t *ctx)
AM/FM 2 check CTS function.
digital_out_t rst
Definition: amfm2.h:296
pin_name_t scl
Definition: amfm2.h:316
AM/FM 2 Click context object.
Definition: amfm2.h:293
err_t amfm2_default_cfg(amfm2_t *ctx)
AM/FM 2 default configuration function.
pin_name_t gp1
Definition: amfm2.h:321
i2c_master_t i2c
Definition: amfm2.h:303
void amfm2_hw_reset(amfm2_t *ctx)
AM/FM 2 hardware reset function.
err_t amfm2_write_data(amfm2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
AM/FM 2 I2C writing function.
uint8_t pn
Definition: amfm2.h:335
uint8_t slave_address
Definition: amfm2.h:306
err_t amfm2_tuning_freq_down(amfm2_t *ctx, uint8_t *rsp)
AM/FM 2 tuning frequency down function.
uint8_t cmpminor
Definition: amfm2.h:340
err_t amfm2_get_tuning_freq(amfm2_t *ctx, float *frequency)
AM/FM 2 get tuning frequency function.
err_t amfm2_check_rds_interrupt(amfm2_t *ctx)
AM/FM 2 check RDS interrupt function.
err_t amfm2_sound_off(amfm2_t *ctx, uint8_t *rsp)
AM/FM 2 sound off function.
void amfm2_set_rst(amfm2_t *ctx, uint8_t pin_state)
AM/FM 2 set state of RST pin function.
uint8_t amfm2_get_gp2(amfm2_t *ctx)
AM/FM 2 get state of GP2 pin function.
@ AMFM2_ERROR
Definition: amfm2.h:352
void amfm2_cfg_setup(amfm2_cfg_t *cfg)
AM/FM 2 configuration object setup function.
err_t amfm2_seek_station(amfm2_t *ctx, uint8_t *rsp)
AM/FM 2 seek station function.
err_t amfm2_check_status_error(amfm2_t *ctx)
AM/FM 2 check status error function.
err_t amfm2_init(amfm2_t *ctx, amfm2_cfg_t *cfg)
AM/FM 2 initialization function.
uint16_t patch
Definition: amfm2.h:338
pin_name_t sda
Definition: amfm2.h:317
uint8_t i2c_address
Definition: amfm2.h:325
digital_in_t gp1
Definition: amfm2.h:299
pin_name_t rst
Definition: amfm2.h:320
err_t amfm2_tuning_freq_up(amfm2_t *ctx, uint8_t *rsp)
AM/FM 2 tuning frequency up function.
err_t amfm2_check_clear_to_send(amfm2_t *ctx)
AM/FM 2 check CTS function.
digital_out_t ema
Definition: amfm2.h:295
err_t amfm2_set_command(amfm2_t *ctx, uint8_t cmd, uint8_t *arg, uint8_t arg_len, uint8_t *rsp, uint8_t rsp_len)
AM/FM 2 set command function.
uint8_t amfm2_get_gp1(amfm2_t *ctx)
AM/FM 2 get state of GP1 pin function.
err_t amfm2_set_volume(amfm2_t *ctx, uint8_t volume, uint8_t *rsp)
AM/FM 2 set volume function.
digital_in_t gp2
Definition: amfm2.h:300
err_t amfm2_generic_read(amfm2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
AM/FM 2 I2C reading function.