Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
63 #define AMFM2_CMD_POWER_UP 0x01
64 #define AMFM2_CMD_GET_REV 0x10
65 #define AMFM2_CMD_POWER_DOWN 0x11
66 #define AMFM2_CMD_SET_PROPERTY 0x12
67 #define AMFM2_CMD_GET_PROPERTY 0x13
68 #define AMFM2_CMD_GET_INT_STATUS 0x14
69 #define AMFM2_CMD_PATCH_ARGS 0x15
70 #define AMFM2_CMD_PATCH_DATA 0x16
71 #define AMFM2_CMD_TX_TUNE_FREQ 0x30
72 #define AMFM2_CMD_TX_TUNE_POWER 0x31
73 #define AMFM2_CMD_TX_TUNE_MEASURE 0x32
74 #define AMFM2_CMD_TX_TUNE_STATUS 0x33
75 #define AMFM2_CMD_TX_ASQ_STATUS 0x34
76 #define AMFM2_CMD_TX_RDS_BUFF 0x35
77 #define AMFM2_CMD_TX_TX_RDS_PS 0x36
78 #define AMFM2_CMD_GPIO_CTL 0x80
79 #define AMFM2_CMD_GPIO_SET 0x81
85 #define AMFM2_CMD_AM_TUNE_FREQ 0x40
86 #define AMFM2_CMD_AM_SEEK_START 0x41
87 #define AMFM2_CMD_AM_TUNE_STATUS 0x42
88 #define AMFM2_CMD_AM_RSQ_STATUS 0x43
89 #define AMFM2_CMD_AM_AGC_STATUS 0x47
90 #define AMFM2_CMD_AM_AGC_OVERRIDE 0x48
96 #define AMFM2_CMD_FM_TUNE_FREQ 0x20
97 #define AMFM2_CMD_FM_SEEK_START 0x21
98 #define AMFM2_CMD_FM_TUNE_STATUS 0x22
99 #define AMFM2_CMD_FM_RSQ_STATUS 0x23
100 #define AMFM2_CMD_FM_RDS_STATUS 0x24
101 #define AMFM2_CMD_FM_AGC_STATUS 0x27
102 #define AMFM2_CMD_FM_AGC_OVERRIDE 0x28
120 #define AMFM2_RSP_STATUS_CTS 0x80
121 #define AMFM2_RSP_STATUS_ERROR 0x40
122 #define AMFM2_RSP_STATUS_RDSINT 0x04
123 #define AMFM2_RSP_STATUS_ASQINT 0x02
124 #define AMFM2_RSP_STATUS_STCINT 0x01
130 #define AMFM2_PWRUP_ARG_CTSIEN 0x80
131 #define AMFM2_PWRUP_ARG_GPO2OEN 0x40
132 #define AMFM2_PWRUP_ARG_PATCH 0x20
133 #define AMFM2_PWRUP_ARG_XOSCEN 0x10
134 #define AMFM2_PWRUP_ARG_FUNC_FMRECEIVE 0x00
135 #define AMFM2_PWRUP_ARG_FUNC_QUERYLIBID 0x0F
136 #define AMFM2_PWRUP_ARG_OPMODE_ANALOGOUT 0x05
137 #define AMFM2_PWRUP_ARG_OPMODE_DIGITALOUT 0x0B
138 #define AMFM2_PWRUP_ARG_OPMODE_DIGITALOUTS 0xB0
139 #define AMFM2_FMTUNEFREQ_ARG_FREEZE 0x02
140 #define AMFM2_FMTUNEFREQ_ARG_FAST 0x01
141 #define AMFM2_FMSEEKSTART_ARG_SEEKUP 0x08
142 #define AMFM2_FMSEEKSTART_ARG_WRAP 0x04
143 #define AMFM2_FMTUNESTATUS_ARG_CANCEL 0x02
144 #define AMFM2_FMTUNESTATUS_ARG_INTACK 0x01
145 #define AMFM2_FMRSQSTATUS_ARG_INTACK 0x01
146 #define AMFM2_FMRDSSTATUS_ARG_STATUSONLY 0x04
147 #define AMFM2_FMRDSSTATUS_ARG_MTFIFO 0x02
148 #define AMFM2_FMRDSSTATUS_ARG_INTACK 0x01
149 #define AMFM2_FMAGCOVERRIDE_ARG_RFAGCDIS 0x01
150 #define AMFM2_GPIOCTL_ARG_GPO3OEN 0x08
151 #define AMFM2_GPIOCTL_ARG_GPO2OEN 0x04
152 #define AMFM2_GPIOCTL_ARG_GPO1OEN 0x02
153 #define AMFM2_GPIOSET_ARG_GPO3LEVEL 0x08
154 #define AMFM2_GPIOSET_ARG_GPO2LEVEL 0x04
155 #define AMFM2_GPIOSET_ARG_GPO1LEVEL 0x02
161 #define AMFM2_SET_VOLUME_MUTE 0
162 #define AMFM2_SET_VOLUME_MAX 63
168 #define AMFM2_PROP_GPOIEN_H 0x00
169 #define AMFM2_PROP_GPOIEN_L 0x01
170 #define AMFM2_PROP_DIGITALOUTFORMAT_H 0x01
171 #define AMFM2_PROP_DIGITALOUTFORMAT_L 0x02
172 #define AMFM2_PROP_DIGITALOUTSAMPLERATE_H 0x01
173 #define AMFM2_PROP_DIGITALOUTSAMPLERATE_L 0x04
174 #define AMFM2_PROP_REFCLKFREQ_H 0x02
175 #define AMFM2_PROP_REFCLKFREQ_L 0x01
176 #define AMFM2_PROP_REFCLKPRESCALE_H 0x02
177 #define AMFM2_PROP_REFCLKPRESCALE_L 0x02
178 #define AMFM2_PROP_RXVOLUME_H 0x40
179 #define AMFM2_PROP_RXVOLUME_L 0x00
180 #define AMFM2_PROP_RXHMUTE_H 0x40
181 #define AMFM2_PROP_RXHMUTE_L 0x01
187 #define AMFM2_PROP_FMDEEMPHASIS_H 0x11
188 #define AMFM2_PROP_FMDEEMPHASIS_L 0x00
189 #define AMFM2_PROP_AMDEEMPHASIS_H 0x31
190 #define AMFM2_PROP_AMDEEMPHASIS_L 0x00
191 #define AMFM2_PROP_FMCHANFILTER_H 0x11
192 #define AMFM2_PROP_FMCHANFILTER_L 0x02
193 #define AMFM2_PROP_AMCHANFILTER_H 0x31
194 #define AMFM2_PROP_AMCHANFILTER_L 0x02
195 #define AMFM2_PROP_AMRSQINTS_H 0x32
196 #define AMFM2_PROP_AMRSQINTS_L 0x00
197 #define AMFM2_PROP_AMNBRATE_H 0x39
198 #define AMFM2_PROP_AMNBRATE_L 0x02
199 #define AMFM2_PROP_AMNBIIRFILTER_H 0x39
200 #define AMFM2_PROP_AMNBIIRFILTER_L 0x03
201 #define AMFM2_PROP_AMNBDELAY_H 0x39
202 #define AMFM2_PROP_AMNBDELAY_L 0x04
208 #define AMFM2_PROP_FMBLENDSTEREOTHS_H 0x11
209 #define AMFM2_PROP_FMBLENDSTEREOTHS_L 0x05
210 #define AMFM2_PROP_FMBLENDMONOTHS_H 0x11
211 #define AMFM2_PROP_FMBLENDMONOTHS_L 0x06
212 #define AMFM2_PROP_FMNBDETECTTHS_H 0x19
213 #define AMFM2_PROP_FMNBDETECTTHS_L 0x00
214 #define AMFM2_PROP_FMNBINTERVAL_H 0x19
215 #define AMFM2_PROP_FMNBINTERVAL_L 0x01
216 #define AMFM2_PROP_FMNBRATE_H 0x19
217 #define AMFM2_PROP_FMNBRATE_L 0x02
218 #define AMFM2_PROP_FMNBIIRFILTER_H 0x19
219 #define AMFM2_PROP_FMNBIIRFILTER_L 0x03
220 #define AMFM2_PROP_FMNBDELAY_H 0x19
221 #define AMFM2_PROP_FMNBDELAY_L 0x04
227 #define AMFM2_PROPVALH_RSQREP 0x08
228 #define AMFM2_PROPVALH_RDSREP 0x04
229 #define AMFM2_PROPVALH_STCREP 0x01
230 #define AMFM2_PROPVALL_CTSIEN 0x80
231 #define AMFM2_PROPVALL_ERRIEN 0x40
232 #define AMFM2_PROPVALL_RSQIEN 0x08
233 #define AMFM2_PROPVALL_RDSIEN 0x04
234 #define AMFM2_PROPVALL_STCIEN 0x01
235 #define AMFM2_PROPVALL_OFALL 0x80
236 #define AMFM2_PROPVALL_LMUTE 0x02
237 #define AMFM2_PROPVALL_RMUTE 0x01
244 #define AMFM2_DEVICE_ADDRESS_GND 0x11
245 #define AMFM2_DEVICE_ADDRESS_VCC 0x63
263 #define AMFM2_MAP_MIKROBUS( cfg, mikrobus ) \
264 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
265 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
266 cfg.ema = MIKROBUS( mikrobus, MIKROBUS_AN ); \
267 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
268 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
269 cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_INT )
527 uint8_t arg_len, uint8_t *rsp, uint8_t rsp_len );
uint8_t chiprev
Definition: amfm2.h:327
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:320
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:323
@ AMFM2_OK
Definition: amfm2.h:337
uint32_t i2c_speed
Definition: amfm2.h:310
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:301
amfm2_return_value_t
AM/FM 2 Click return value data.
Definition: amfm2.h:336
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:325
pin_name_t ema
Definition: amfm2.h:305
uint8_t fwmajor
Definition: amfm2.h:322
pin_name_t gp2
Definition: amfm2.h:308
err_t amfm2_check_seek_tune_complete(amfm2_t *ctx)
AM/FM 2 check CTS function.
digital_out_t rst
Definition: amfm2.h:282
pin_name_t scl
Definition: amfm2.h:302
AM/FM 2 Click context object.
Definition: amfm2.h:279
err_t amfm2_default_cfg(amfm2_t *ctx)
AM/FM 2 default configuration function.
pin_name_t gp1
Definition: amfm2.h:307
i2c_master_t i2c
Definition: amfm2.h:289
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:321
uint8_t slave_address
Definition: amfm2.h:292
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:326
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:338
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:324
pin_name_t sda
Definition: amfm2.h:303
uint8_t i2c_address
Definition: amfm2.h:311
digital_in_t gp1
Definition: amfm2.h:285
pin_name_t rst
Definition: amfm2.h:306
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:281
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:286
err_t amfm2_generic_read(amfm2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
AM/FM 2 I2C reading function.