PU2CLR Si4735 Arduino Library 2.1.4
Arduino Library for Si47XX Devices - By Ricardo Lima Caratti
SI4735.h
Go to the documentation of this file.
1/**
2 * @brief SI4735 ARDUINO LIBRARY
3 *
4 * @details This is an Arduino library for the SI473X and SI474X, BROADCAST AM/FM/SW RADIO RECEIVER, IC from Silicon Labs for the
5 * @details Arduino development environment
6 * @details The communication used by this library is I2C.
7 * @details This file contains: const (#define), Defined Data type and Methods declarations
8 * @details You can see a complete documentation on <https://github.com/pu2clr/SI4735>
9 * @details The are more than 30 examples on <https://github.com/pu2clr/SI4735/tree/master/examples>
10 *
11 * @see [General Documentation](https://pu2clr.github.io/SI4735/)
12 * @see [Schematics](https://pu2clr.github.io/SI4735/extras/schematic/)
13 * @see Si47XX PROGRAMMING GUIDE AN332 (Rev 1.0): https://www.silabs.com/documents/public/application-notes/AN332.pdf
14 * @see AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; AMENDMENT FOR SI4735-D60 SSB AND NBFM PATCHES
15 *
16 * @author PU2CLR - Ricardo Lima Caratti
17 * @date 2019-2022
18 */
19
20#ifndef _SI4735_H // Prevent this file from being compiled more than once
21#define _SI4735_H
22
23#include <Arduino.h>
24#include <Wire.h>
25
26#define POWER_UP_FM 0 // FM
27#define POWER_UP_AM 1 // AM and SSB (if patch applyed)
28#define POWER_UP_WB 3 // Weather Band Receiver
29#define POWER_PATCH 15 //
30
31// SI473X commands (general)
32#define SI473X_ADDR_SEN_LOW 0x11 // SI473X I2C bus address when the SEN pin (16) is set to low 0V.
33#define SI473X_ADDR_SEN_HIGH 0x63 // SI473X I2C bus address when the SEN pin (16) is set to high +3.3V
34
35#define POWER_UP 0x01 // Power up device and mode selection.
36#define GET_REV 0x10 // Returns revision information on the device.
37#define POWER_DOWN 0x11 // Power down device.
38#define SET_PROPERTY 0x12 // Sets the value of a property.
39#define GET_PROPERTY 0x13 // Retrieves a property’s value.
40#define GET_INT_STATUS 0x14 // Read interrupt status bits.
41
42// FM
43#define FM_TUNE_FREQ 0x20
44#define FM_SEEK_START 0x21 // Begins searching for a valid FM frequency.
45#define FM_TUNE_STATUS 0x22
46#define FM_AGC_STATUS 0x27
47#define FM_AGC_OVERRIDE 0x28
48#define FM_RSQ_STATUS 0x23
49#define FM_RDS_STATUS 0x24 // Returns RDS information for current channel and reads an entry from the RDS FIFO.
50
51#define FM_NB_DETECT_THRESHOLD 0x1900 // Sets the threshold for detecting impulses in dB above the noise floor. Default value is 16.
52#define FM_NB_INTERVAL 0x1901 // Interval in micro-seconds that original samples are replaced by interpolated clean sam- ples. Default value is 24 μs.
53#define FM_NB_RATE 0x1902 // Noise blanking rate in 100 Hz units. Default value is 64.
54#define FM_NB_IIR_FILTER 0x1903 // Sets the bandwidth of the noise floor estimator Default value is 300.
55#define FM_NB_DELAY 0x1904 // Delay in micro-seconds before applying impulse blanking to the original sam- ples. Default value is 133.
56
57// FM RDS properties
58#define FM_RDS_INT_SOURCE 0x1500
59#define FM_RDS_INT_FIFO_COUNT 0x1501
60#define FM_RDS_CONFIG 0x1502
61#define FM_RDS_CONFIDENCE 0x1503
62
63#define FM_DEEMPHASIS 0x1100
64#define FM_BLEND_STEREO_THRESHOLD 0x1105
65#define FM_BLEND_MONO_THRESHOLD 0x1106
66#define FM_BLEND_RSSI_STEREO_THRESHOLD 0x1800
67#define FM_BLEND_RSSI_MONO_THRESHOLD 0x1801
68#define FM_BLEND_SNR_STEREO_THRESHOLD 0x1804
69#define FM_BLEND_SNR_MONO_THRESHOLD 0x1805
70#define FM_BLEND_MULTIPATH_STEREO_THRESHOLD 0x1808
71#define FM_BLEND_MULTIPATH_MONO_THRESHOLD 0x1809
72#define FM_CHANNEL_FILTER 0x1102
73#define FM_SOFT_MUTE_MAX_ATTENUATION 0x1302
74
75// FM SEEK Properties
76#define FM_SEEK_BAND_BOTTOM 0x1400 // Sets the bottom of the FM band for seek
77#define FM_SEEK_BAND_TOP 0x1401 // Sets the top of the FM band for seek
78#define FM_SEEK_FREQ_SPACING 0x1402 // Selects frequency spacing for FM seek
79#define FM_SEEK_TUNE_SNR_THRESHOLD 0x1403 // Sets the SNR threshold for a valid FM Seek/Tune
80#define FM_SEEK_TUNE_RSSI_THRESHOLD 0x1404 // Sets the RSSI threshold for a valid FM Seek/Tune
81
82
83// NBFM Commands
84#define NBFM_TUNE_FREQ 0x50
85#define NBFM_TUNE_STATUS 0x52
86#define NBFM_RSQ_STATUS 0x53
87#define NBFM_AGC_STATUS 0x57
88#define NBFM_AGC_OVERRIDE 0x58
89
90
91// NBFM Properties
92
93#define NBFM_MAX_TUNE_ERROR 0x5108
94#define NBFM_RSQ_INT_SOURCE 0x5200
95#define NBFM_RSQ_SNR_HI_THRESHOLD 0x5201
96#define NBFM_RSQ_SNR_LO_THRESHOLD 0x5202
97#define NBFM_RSQ_RSSI_HI_THRESHOLD 0x5203
98#define NBFM_RSQ_RSSI_LO_THRESHOLD 0x5204
99#define NBFM_VALID_SNR_THRESHOLD 0x5403
100#define NBFM_VALID_RSSI_THRESHOLD 0x5404
101
102
103// AM command
104#define AM_TUNE_FREQ 0x40 // Tunes to a given AM frequency.
105#define AM_SEEK_START 0x41 // Begins searching for a valid AM frequency.
106#define AM_TUNE_STATUS 0x42 // Queries the status of the already issued AM_TUNE_FREQ or AM_SEEK_START command.
107#define AM_RSQ_STATUS 0x43 // Queries the status of the Received Signal Quality (RSQ) for the current channel.
108#define AM_AGC_STATUS 0x47 // Queries the current AGC settings.
109#define AM_AGC_OVERRIDE 0x48 // Overrides AGC settings by disabling and forcing it to a fixed value.
110#define GPIO_CTL 0x80 // Configures GPO1, 2, and 3 as output or Hi-Z.
111#define GPIO_SET 0x81 // Sets GPO1, 2, and 3 output level (low or high).
112
113//SSB command (SAME AM CMD VALUES)
114// See AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; pages 4 and 5
115#define SSB_TUNE_FREQ 0x40 // Tunes to a given SSB frequency.
116#define SSB_TUNE_STATUS 0x42 // Queries the status of the already issued SSB_TUNE_FREQ or AM_SEEK_START command.
117#define SSB_RSQ_STATUS 0x43 // Queries the status of the Received Signal Quality (RSQ) for the current channel.
118#define SSB_AGC_STATUS 0x47 // Queries the current AGC settings.
119#define SSB_AGC_OVERRIDE 0x48 // Overrides AGC settings by disabling and forcing it to a fixed value.
120
121// AM/SW/LW Receiver Property Summary
122// See Si47XX PROGRAMMING GUIDE AN332 (REV 1.0); page 125
123#define DIGITAL_OUTPUT_FORMAT 0x0102 // Configure digital audio outputs.
124#define DIGITAL_OUTPUT_SAMPLE_RATE 0x0104 // Configure digital audio output sample rate
125#define REFCLK_FREQ 0x0201 //Sets frequency of reference clock in Hz. The range is 31130 to 34406 Hz, or 0 to disable the AFC. Default is 32768 Hz.
126#define REFCLK_PRESCALE 0x0202 // Sets the prescaler value for RCLK input.
127#define AM_DEEMPHASIS 0x3100 // Sets deemphasis time constant. Can be set to 50 μs. Deemphasis is disabled by default.
128#define AM_CHANNEL_FILTER 0x3102 // Selects the bandwidth of the channel filter for AM reception. The choices are 6, 4, 3, 2, 2.5, 1.8, or 1 (kHz). The default bandwidth is 2 kHz.
129#define AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN 0x3103 // Sets the maximum gain for automatic volume control.
130#define AM_MODE_AFC_SW_PULL_IN_RANGE 0x3104 // Sets the SW AFC pull-in range.
131#define AM_MODE_AFC_SW_LOCK_IN_RANGE 0x3105 // Sets the SW AFC lock-in.
132#define AM_RSQ_INTERRUPTS 0x3200 // Same SSB - Configures interrupt related to Received Signal Quality metrics. All interrupts are disabled by default.
133#define AM_RSQ_SNR_HIGH_THRESHOLD 0x3201 //Sets high threshold for SNR interrupt.
134#define AM_RSQ_SNR_LOW_THRESHOLD 0x3202 // Sets low threshold for SNR interrupt.
135#define AM_RSQ_RSSI_HIGH_THRESHOLD 0x3203 // Sets high threshold for RSSI interrupt.
136#define AM_RSQ_RSSI_LOW_THRESHOLD 0x3204 // Sets low threshold for RSSI interrupt.
137#define AM_SOFT_MUTE_RATE 0x3300 // Sets the attack and decay rates when entering or leaving soft mute. The default is 278 dB/s.
138#define AM_SOFT_MUTE_SLOPE 0x3301 // Sets the AM soft mute slope. Default value is a slope of 1.
139#define AM_SOFT_MUTE_MAX_ATTENUATION 0x3302 // Sets maximum attenuation during soft mute (dB). Set to 0 to disable soft mute. Default is 8 dB.
140#define AM_SOFT_MUTE_SNR_THRESHOLD 0x3303 // Sets SNR threshold to engage soft mute. Default is 8 dB.
141#define AM_SOFT_MUTE_RELEASE_RATE 0x3304 // Sets softmute release rate. Smaller values provide slower release, and larger values provide faster release.
142#define AM_SOFT_MUTE_ATTACK_RATE 0x3305 // Sets software attack rate. Smaller values provide slower attack, and larger values provide faster attack.
143#define AM_SEEK_BAND_BOTTOM 0x3400 // Sets the bottom of the AM band for seek. Default is 520.
144#define AM_SEEK_BAND_TOP 0x3401 // Sets the top of the AM band for seek. Default is 1710.
145#define AM_SEEK_FREQ_SPACING 0x3402 // Selects frequency spacing for AM seek. Default is 10 kHz spacing.
146#define AM_SEEK_SNR_THRESHOLD 0x3403 // Sets the SNR threshold for a valid AM Seek/Tune.
147#define AM_SEEK_RSSI_THRESHOLD 0x3404 // Sets the RSSI threshold for a valid AM Seek/Tune.
148#define AM_AGC_ATTACK_RATE 0x3702 // Sets the number of milliseconds the high peak detector must be exceeded before decreasing gain.
149#define AM_AGC_RELEASE_RATE 0x3703 // Sets the number of milliseconds the low peak detector must not be exceeded before increasing the gain.
150#define AM_FRONTEND_AGC_CONTROL 0x3705 // Adjusts AM AGC for frontend (external) attenuator and LNA.
151#define AM_NB_DETECT_THRESHOLD 0x3900 // Sets the threshold for detecting impulses in dB above the noise floor
152#define AM_NB_INTERVAL 0x3901 // Interval in micro-seconds that original samples are replaced by interpolated clean samples
153#define AM_NB_RATE 0x3902 // Noise blanking rate in 100 Hz units. Default value is 64.
154#define AM_NB_IIR_FILTER 0x3903 // Sets the bandwidth of the noise floor estimator. Default value is 300.
155#define AM_NB_DELAY 0x3904 // Delay in micro-seconds before applying impulse blanking to the original samples
156
157#define RX_VOLUME 0x4000
158#define RX_HARD_MUTE 0x4001
159
160// SSB properties
161// See AN332 REV 0.8 Universal Programming Guide (Amendment for SI4735-D60 SSN and NBFM Patches)
162
163#define GPO_IEN 0x0001 // AM and SSB - Enable interrupt source
164#define SSB_BFO 0x0100 // Sets the Beat Frequency Offset (BFO) under SSB mode.
165#define SSB_MODE 0x0101 // Sets number of properties of the SSB mode.
166#define SSB_RSQ_INTERRUPTS 0x3200 // Configure Interrupts related to RSQ
167#define SSB_RSQ_SNR_HI_THRESHOLD 0x3201 // Sets high threshold for SNR interrupt
168#define SSB_RSQ_SNR_LO_THRESHOLD 0x3202 // Sets low threshold for SNR interrupt
169#define SSB_RSQ_RSSI_HI_THRESHOLD 0x3203 // Sets high threshold for RSSI interrupt
170#define SSB_RSQ_RSSI_LO_THRESHOLD 0x3204 // Sets low threshold for RSSI interrupt
171#define SSB_SOFT_MUTE_RATE 0x3300 // Sets the attack and decay rates when entering or leaving soft mute
172#define SSB_SOFT_MUTE_MAX_ATTENUATION 0x3302 // Sets the maximum attenuation during soft mute (db); 0dB to disable soft mute; defaul 8dB;
173#define SSB_SOFT_MUTE_SNR_THRESHOLD 0x3303 // Sets SNR threshould to engage soft mute. Defaul 8dB
174#define SSB_RF_AGC_ATTACK_RATE 0x3700 // Sets the number of milliseconds the high RF peak detector must be exceeded before decreasing the gain. Defaul 4.
175#define SSB_RF_AGC_RELEASE_RATE 0x3701 // Sets the number of milliseconds the low RF peak detector must be exceeded before increasing the gain. Defaul 24.
176#define SSB_IF_AGC_RELEASE_RATE 0x3703 // Sets the number of milliseconds the low IF peak detector must not be exceeded before increasing the gain. Default value is 140 (approximately 40 dB / s).
177#define SSB_IF_AGC_ATTACK_RATE 0x3702 // Sets the number of milliseconds the high IF peak detector must be exceeded before decreasing gain. Default value is 4 (approximately 1400 dB / s).
178
179// SSB
180#define SSB_RF_IF_AGC_ATTACK_RATE 0x3702 // Sets the number of milliseconds the high IF peak detector must be exceeded before decreasing gain. Defaul 4.
181#define SSB_RF_IF_AGC_RELEASE_RATE 0x3703 // Sets the number of milliseconds the low IF peak detector must be exceeded before increasing the gain. Defaul 140.
182
183// See AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; pages 12 and 13
184#define LSB_MODE 1 // 01
185#define USB_MODE 2 // 10
186
187// Parameters
188#define SI473X_RDS_OUTPUT_ONLY 0b00000000 // RDS output only (no audio outputs) Si4749 only
189#define SI473X_ANALOG_AUDIO 0b00000101 // Analog Audio Inputs
190#define SI473X_DIGITAL_AUDIO1 0b00001011 // Digital audio output (DCLK, LOUT/DFS, ROUT/DIO)
191#define SI473X_DIGITAL_AUDIO2 0b10110000 // Digital audio outputs (DCLK, DFS, DIO)
192#define SI473X_ANALOG_DIGITAL_AUDIO 0b10110101 // Analog and digital audio outputs (LOUT/ROUT and DCLK, DFS,DIO)
193
194// Other parameters
195#define FM_CURRENT_MODE 0
196#define AM_CURRENT_MODE 1
197#define SSB_CURRENT_MODE 2
198#define NBFM_CURRENT_MODE 3
199
200#define SEEK_UP 1
201#define SEEK_DOWN 0
202
203#define MAX_DELAY_AFTER_SET_FREQUENCY 30 // In ms - This value helps to improve the precision during of getting frequency value
204#define MAX_DELAY_AFTER_POWERUP 10 // In ms - Max delay you have to setup after a power up command.
205#define MIN_DELAY_WAIT_SEND_LOOP 300 // In uS (Microsecond) - each loop of waitToSend sould wait this value in microsecond
206#define MAX_SEEK_TIME 8000 // defines the maximum seeking time 8s is default.
207
208#define DEFAULT_CURRENT_AVC_AM_MAX_GAIN 36
209
210#define XOSCEN_CRYSTAL 1 // Use crystal oscillator
211#define XOSCEN_RCLK 0 // Use external RCLK (crystal oscillator disabled).
212
213/** @defgroup group01 Union, Struct and Defined Data Types
214 * @section group01 Data Types
215 *
216 * @brief SI473X data representation
217 *
218 * @details The goal of this approach is separating data from code.
219 * The Si47XX family works with many internal data that can be represented by data structure
220 * or defined data type in C/C++. These C/C++ resources have been used widely here.
221 * This approach made the library easier to build and maintain. Each data structure created
222 * here has its reference (name of the document and page on which it was based).
223 * In other words, to make the SI47XX device easier to deal, some defined data types were
224 * created to handle byte and bits to process commands, properties and responses.
225 * These data types will be usefull to deal with SI473X
226 */
227
228/**
229 * @ingroup group01
230 *
231 * @brief Power Up arguments data type
232 *
233 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 64 and 65
234 */
235 typedef union
236{
237 struct
238 {
239 // ARG1
240 uint8_t FUNC : 4; //!< Function (0 = FM Receive; 1–14 = Reserved; 15 = Query Library ID)
241 uint8_t XOSCEN : 1; //!< Crystal Oscillator Enable (0 = crystal oscillator disabled; 1 = Use crystal oscillator and and OPMODE=ANALOG AUDIO) .
242 uint8_t PATCH : 1; //!< Patch Enable (0 = Boot normally; 1 = Copy non-volatile memory to RAM).
243 uint8_t GPO2OEN : 1; //!< GPO2 Output Enable (0 = GPO2 output disabled; 1 = GPO2 output enabled).
244 uint8_t CTSIEN : 1; //!< CTS Interrupt Enable (0 = CTS interrupt disabled; 1 = CTS interrupt enabled).
245 // ARG2
246 uint8_t OPMODE; //!< Application Setting. See page 65
247 } arg; //!< Refined powerup parameters
248 uint8_t raw[2]; //!< Raw powerup parameters data. Same arg memory position. So, same content.
249} si473x_powerup;
250
251/**
252 * @ingroup group01
253 *
254 * @brief Data type for Enables output for GPO1, GPO2 and GPO3
255 *
256 * @details GPO1, 2, and 3 can be configured for output (Hi-Z or active drive) by setting the GPO1OEN, GPO2OEN, and GPO3OEN bit.
257 *
258 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 82 and 144
259 */
260typedef union
261{
262 struct
263 {
264 uint8_t DUMMY1 : 1; //!< Always write 0.
265 uint8_t GPO1OEN : 1; //!< GPO1 Output Enable.
266 uint8_t GPO2OEN : 1; //!< GPO2 Output Enable.
267 uint8_t GPO3OEN : 1; //!< GPO3 Output Enable.
268 uint8_t DUMMY2 : 4; //!< Always write 0.
269 } arg; //!< Refined powerup parameters
271} si473x_gpio;
272
273/**
274 * @ingroup group01
275 *
276 * @brief Data type for Configuring the sources for the GPO2/INT interrupt pin
277 *
278 * @details Valid sources are the lower 8 bits of the STATUS byte, including CTS, ERR, RSQINT, and STCINT bits.
279 *
280 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 146
281 */
282typedef union
283{
284 struct
285 {
286 uint8_t STCIEN : 1; //!< Seek/Tune Complete Interrupt Enable (0 or 1).
287 uint8_t DUMMY1 : 2; //!< Always write 0.
288 uint8_t RSQIEN : 1; //!< RSQ Interrupt Enable (0 or 1).
289 uint8_t DUMMY2 : 2; //!< Always write 0.
290 uint8_t ERRIEN : 1; //!< ERR Interrupt Enable (0 or 1).
291 uint8_t CTSIEN : 1; //!< CTS Interrupt Enable (0 or 1).
292 uint8_t STCREP : 1; //!< STC Interrupt Repeat (0 or 1).
293 uint8_t DUMMY3 : 2; //!< Always write 0.
294 uint8_t RSQREP : 1; //!< RSQ Interrupt Repeat (0 or 1).
295 uint8_t DUMMY4 : 4; //!< Always write 0.
296 } arg;
298} si473x_gpio_ien;
299
300/**
301 * @ingroup group01
302 *
303 * @brief Represents how the frequency is stored in the si4735.
304 * @details It helps to convert frequency in uint16_t to two bytes (uint8_t) (FREQL and FREQH)
305 */
306typedef union
307{
308 struct
309 {
310 uint8_t FREQL; //!< Tune Frequency Low byte.
311 uint8_t FREQH; //!< Tune Frequency High byte.
312 } raw; //!< Raw data that represents the frequency stored in the Si47XX device.
313 uint16_t value; //!< frequency (integer value)
314} si47x_frequency;
315
316/**
317 * @ingroup group01
318 * @brief Antenna Tuning Capacitor data type manupulation
319 */
320typedef union
321{
322 struct
323 {
324 uint8_t ANTCAPL; //!< Antenna Tuning Capacitor High byte
325 uint8_t ANTCAPH; //!< Antenna Tuning Capacitor Low byte
326 } raw;
328} si47x_antenna_capacitor;
329
330/**
331 * @ingroup group01
332 *
333 * @brief AM Tune frequency data type command (AM_TUNE_FREQ command)
334 *
335 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 135
336 */
337typedef union
338{
339 struct
340 {
341 uint8_t FAST : 1; //!< ARG1 - FAST Tuning. If set, executes fast and invalidated tune. The tune status will not be accurate.
342 uint8_t FREEZE : 1; //!< Valid only for FM (Must be 0 to AM)
343 uint8_t DUMMY1 : 4; //!< Always set 0
344 uint8_t USBLSB : 2; //!< SSB Upper Side Band (USB) and Lower Side Band (LSB) Selection. 10 = USB is selected; 01 = LSB is selected.
345 uint8_t FREQH; //!< ARG2 - Tune Frequency High byte.
346 uint8_t FREQL; //!< ARG3 - Tune Frequency Low byte.
347 uint8_t ANTCAPH; //!< ARG4 - Antenna Tuning Capacitor High byte.
348 uint8_t ANTCAPL; //!< ARG5 - Antenna Tuning Capacitor Low byte. Note used for FM.
349 } arg;
351} si47x_set_frequency;
352
353/**
354 * @ingroup group01
355 *
356 * @brief Seek frequency (automatic tuning). ARG1
357 *
358 * @details Represents searching for a valid frequency data type AM and FM.
359 * @details When AM, the searching data have to be complemented by si47x_seek_am_complement.
360 *
361 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 72 and 137
362 * @see si47x_seek_am_complement
363 */
364typedef union
365{
366 struct
367 {
368 uint8_t RESERVED1 : 2;
369 uint8_t WRAP : 1; //!< Determines whether the seek should Wrap = 1, or Halt = 0 when it hits the band limit.
370 uint8_t SEEKUP : 1; //!< Determines the direction of the search, either UP = 1, or DOWN = 0.
371 uint8_t RESERVED2 : 4;
372 } arg;
374} si47x_seek;
375
376/**
377 * @ingroup group01
378 *
379 * @brief Seek frequency (automatic tuning) AM complement (ARG2, ARG3, ARG4 and ARG5)
380 *
381 * @details Represents AM complement searching information for a valid frequency data type.
382 *
383 * @see @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 72 and 137
384 */
385typedef struct
386{
387 uint8_t ARG2; // Always 0.
388 uint8_t ARG3; // Always 0.
391} si47x_seek_am_complement;
392
393/**
394 * @ingroup group01 status response structure
395 *
396 * @brief Status response data representation
397 *
398 * @details Represents searching for a valid frequency data type.
399 */
400typedef union
401{
402 struct
403 {
404 uint8_t STCINT : 1; //!< 1 = Tune complete has been triggered.
405 uint8_t DUMMY1 : 1; //!< Reserved (Values may vary).
406 uint8_t RDSINT : 1; //!< 1 = Radio data system interrupt has been triggered.
407 uint8_t RSQINT : 1; //!< 1 = Received Signal Quality measurement has been triggered.
408 uint8_t DUMMY2 : 2; //!< Reserved (Values may vary).
409 uint8_t ERR : 1; //!< 1 = Error.
410 uint8_t CTS : 1; //!< 0 = Wait before sending next command; 1 = Clear to send next command.
411 } refined;
413} si47x_status;
414
415/**
416 * @ingroup group01
417 *
418 * @brief Response status command
419 *
420 * @details Response data from a query status command
421 *
422 * @see Si47XX PROGRAMMING GUIDE; pages 73 and
423 */
424typedef union
425{
426 struct
427 {
428 // Status
429 uint8_t STCINT : 1; //!< Seek/Tune Complete Interrupt; 1 = Tune complete has been triggered.
430 uint8_t DUMMY1 : 1;
431 uint8_t RDSINT : 1; //!< Radio Data System (RDS) Interrup; 0 = interrupt has not been triggered.
432 uint8_t RSQINT : 1; //!< Received Signal Quality Interrupt; 0 = interrupt has not been triggered.
433 uint8_t DUMMY2 : 2;
434 uint8_t ERR : 1; //!< Error. 0 = No error 1 = Error
435 uint8_t CTS : 1; //!< Clear to Send.
436 // RESP1
437 uint8_t VALID : 1; //!< Valid Channel
438 uint8_t AFCRL : 1; //!< AFC Rail Indicator
439 uint8_t DUMMY3 : 5;
440 uint8_t BLTF : 1; //!< Reports if a seek hit the band limit
441 // RESP2
442 uint8_t READFREQH; //!< Read Frequency High byte.
443 // RESP3
444 uint8_t READFREQL; //!< Read Frequency Low byte.
445 // RESP4
446 uint8_t RSSI; //!< Received Signal Strength Indicator (dBμV)
447 // RESP5
448 uint8_t SNR; //!< This byte contains the SNR metric when tune is complete (dB).
449 // RESP6
450 uint8_t MULT; //!< If FM, contains the multipath metric when tune is complete; IF AM READANTCAPH (tuning capacitor value high byte)
451 // RESP7
452 uint8_t READANTCAP; //!< If FM, contains the current antenna tuning capacitor value; IF AM READANTCAPL (tuning capacitor value low byte)
453 } resp;
454 uint8_t raw[8]; //!< Check it
455} si47x_response_status;
456
457/**
458 * @ingroup group01
459 *
460 * @brief Data representation for Firmware Information (GET_REV)
461 *
462 * @details The part number, chip revision, firmware revision, patch revision and component revision numbers.
463 *
464 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 66 and 131
465 */
466typedef union
467{
468 struct
469 {
470 // status ("RESP0")
471 uint8_t STCINT : 1;
472 uint8_t DUMMY1 : 1;
473 uint8_t RDSINT : 1;
474 uint8_t RSQINT : 1;
475 uint8_t DUMMY2 : 2;
476 uint8_t ERR : 1;
477 uint8_t CTS : 1;
478 uint8_t PN; //!< RESP1 - Final 2 digits of Part Number (HEX).
479 uint8_t FWMAJOR; //!< RESP2 - Firmware Major Revision (ASCII).
480 uint8_t FWMINOR; //!< RESP3 - Firmware Minor Revision (ASCII).
481 uint8_t PATCHH; //!< RESP4 - Patch ID High byte (HEX).
482 uint8_t PATCHL; //!< RESP5 - Patch ID Low byte (HEX).
483 uint8_t CMPMAJOR; //!< RESP6 - Component Major Revision (ASCII).
484 uint8_t CMPMINOR; //!< RESP7 - Component Minor Revision (ASCII).
485 uint8_t CHIPREV; //!< RESP8 - Chip Revision (ASCII).
486 // RESP9 to RESP15 not used
487 } resp;
489} si47x_firmware_information;
490
491/**
492 * @ingroup group01
493 *
494 * @brief Firmware Query Library ID response.
495 *
496 * @details Used to represent the response of a power up command with FUNC = 15 (patch)
497 *
498 * To confirm that the patch is compatible with the internal device library revision, the library
499 * revision should be confirmed by issuing the POWER_UP command with Function = 15 (query library ID)
500 *
501 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 12
502 */
503typedef union
504{
505 struct
506 {
507 // status ("RESP0")
508 uint8_t STCINT : 1;
509 uint8_t DUMMY1 : 1;
510 uint8_t RDSINT : 1;
511 uint8_t RSQINT : 1;
512 uint8_t DUMMY2 : 2;
513 uint8_t ERR : 1;
514 uint8_t CTS : 1;
515 uint8_t PN; //!< RESP1 - Final 2 digits of Part Number (HEX).
516 uint8_t FWMAJOR; //!< RESP2 - Firmware Major Revision (ASCII).
517 uint8_t FWMINOR; //!< RESP3 - Firmware Minor Revision (ASCII).
518 uint8_t RESERVED1; //!< RESP4 - Reserved, various values.
519 uint8_t RESERVED2; //!< RESP5 - Reserved, various values.
520 uint8_t CHIPREV; //!< RESP6 - Chip Revision (ASCII).
521 uint8_t LIBRARYID; //!< RESP7 - Library Revision (HEX).
522 // RESP9 to RESP15 not used
523 } resp;
525} si47x_firmware_query_library;
526
527/**
528 * @ingroup group01
529 *
530 * @brief Seek station status
531 *
532 * @details Status of FM_TUNE_FREQ or FM_SEEK_START commands or Status of AM_TUNE_FREQ or AM_SEEK_START commands.
533 *
534 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 73 and 139
535 */
536typedef union
537{
538 struct
539 {
540 uint8_t INTACK : 1; //!< If set, clears the seek/tune complete interrupt status indicator.
541 uint8_t CANCEL : 1; //!< If set, aborts a seek currently in progress.
542 uint8_t RESERVED2 : 6;
543 } arg;
545} si47x_tune_status;
546
547/**
548 * @ingroup group01
549 *
550 * @brief Data type to deal with SET_PROPERTY command
551 *
552 * @details Property Data type (help to deal with SET_PROPERTY command on si473X)
553 */
554typedef union
555{
556 struct
557 {
558 uint8_t byteLow;
559 uint8_t byteHigh;
560 } raw;
562} si47x_property;
563
564/**
565 * @ingroup group01
566 *
567 * @brief Radio Signal Quality data representation
568 *
569 * @details Data type for status information about the received signal quality (FM_RSQ_STATUS and AM_RSQ_STATUS)
570 *
571 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 75 and
572 */
573typedef union
574{
575 struct
576 {
577 // status ("RESP0")
578 uint8_t STCINT : 1;
579 uint8_t DUMMY1 : 1;
580 uint8_t RDSINT : 1;
581 uint8_t RSQINT : 1;
582 uint8_t DUMMY2 : 2;
583 uint8_t ERR : 1;
584 uint8_t CTS : 1;
585 // RESP1
586 uint8_t RSSIILINT : 1; //!< RSSI Detect Low.
587 uint8_t RSSIHINT : 1; //!< RSSI Detect High.
588 uint8_t SNRLINT : 1; //!< SNR Detect Low.
589 uint8_t SNRHINT : 1; //!< SNR Detect High.
590 uint8_t MULTLINT : 1; //!< Multipath Detect Low
591 uint8_t MULTHINT : 1; //!< Multipath Detect High
592 uint8_t DUMMY3 : 1;
593 uint8_t BLENDINT : 1; //!< Blend Detect Interrupt.
594 // RESP2
595 uint8_t VALID : 1; //!< Valid Channel.
596 uint8_t AFCRL : 1; //!< AFC Rail Indicator.
597 uint8_t DUMMY4 : 1;
598 uint8_t SMUTE : 1; //!< Soft Mute Indicator. Indicates soft mute is engaged.
599 uint8_t DUMMY5 : 4;
600 // RESP3
601 uint8_t STBLEND : 7; //!< Indicates amount of stereo blend in% (100 = full stereo, 0 = full mono).
602 uint8_t PILOT : 1; //!< Indicates stereo pilot presence.
603 // RESP4 to RESP7
604 uint8_t RSSI; //!< RESP4 - Contains the current receive signal strength (0–127 dBμV).
605 uint8_t SNR; //!< RESP5 - Contains the current SNR metric (0–127 dB).
606 uint8_t MULT; //!< RESP6 - Contains the current multipath metric. (0 = no multipath; 100 = full multipath)
607 uint8_t FREQOFF; //!< RESP7 - Signed frequency offset (kHz).
608 } resp;
610} si47x_rqs_status;
611
612/**
613 * @ingroup group01
614 * @brief Adjusts the AM AGC for external front-end attenuator and external front-end cascode LNA.
615 * @see Si47XX PROAMMING GUIDE; AN332 (REV 1.0); page 168
616 */
617typedef union
618{
619 struct
620 {
621 uint8_t ATTN_BACKUP;
622 uint8_t MIN_GAIN_INDEX;
623 } field;
625} si47x_frontend_agc_control;
626
627/**
628 * @ingroup group01
629 *
630 * @brief Data type for RDS Status command and response information
631 *
632 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 77 and 78
633 * @see Also https://en.wikipedia.org/wiki/Radio_Data_System
634 */
635typedef union
636{
637 struct
638 {
639 uint8_t INTACK : 1; // Interrupt Acknowledge; 0 = RDSINT status preserved; 1 = Clears RDSINT.
640 uint8_t MTFIFO : 1; // Empty FIFO; 0 = If FIFO not empty; 1 = Clear RDS Receive FIFO.
641 uint8_t STATUSONLY : 1; // Determines if data should be removed from the RDS FIFO.
642 uint8_t dummy : 5;
643 } arg;
645} si47x_rds_command;
646
647/**
648 * @ingroup group01
649 *
650 * @brief Response data type for current channel and reads an entry from the RDS FIFO.
651 *
652 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 77 and 78
653 */
654typedef union
655{
656 struct
657 {
658 // status ("RESP0")
659 uint8_t STCINT : 1;
660 uint8_t DUMMY1 : 1;
661 uint8_t RDSINT : 1;
662 uint8_t RSQINT : 1;
663 uint8_t DUMMY2 : 2;
664 uint8_t ERR : 1;
665 uint8_t CTS : 1;
666 // RESP1
667 uint8_t RDSRECV : 1; //!< RDS Received; 1 = FIFO filled to minimum number of groups set by RDSFIFOCNT.
668 uint8_t RDSSYNCLOST : 1; //!< RDS Sync Lost; 1 = Lost RDS synchronization.
669 uint8_t RDSSYNCFOUND : 1; //!< RDS Sync Found; 1 = Found RDS synchronization.
670 uint8_t DUMMY3 : 1;
671 uint8_t RDSNEWBLOCKA : 1; //!< RDS New Block A; 1 = Valid Block A data has been received.
672 uint8_t RDSNEWBLOCKB : 1; //!< RDS New Block B; 1 = Valid Block B data has been received.
673 uint8_t DUMMY4 : 2;
674 // RESP2
675 uint8_t RDSSYNC : 1; //!< RDS Sync; 1 = RDS currently synchronized.
676 uint8_t DUMMY5 : 1;
677 uint8_t GRPLOST : 1; //!< Group Lost; 1 = One or more RDS groups discarded due to FIFO overrun.
678 uint8_t DUMMY6 : 5;
679 // RESP3 to RESP11
680 uint8_t RDSFIFOUSED; //!< RESP3 - RDS FIFO Used; Number of groups remaining in the RDS FIFO (0 if empty).
681 uint8_t BLOCKAH; //!< RESP4 - RDS Block A; HIGH byte
682 uint8_t BLOCKAL; //!< RESP5 - RDS Block A; LOW byte
683 uint8_t BLOCKBH; //!< RESP6 - RDS Block B; HIGH byte
684 uint8_t BLOCKBL; //!< RESP7 - RDS Block B; LOW byte
685 uint8_t BLOCKCH; //!< RESP8 - RDS Block C; HIGH byte
686 uint8_t BLOCKCL; //!< RESP9 - RDS Block C; LOW byte
687 uint8_t BLOCKDH; //!< RESP10 - RDS Block D; HIGH byte
688 uint8_t BLOCKDL; //!< RESP11 - RDS Block D; LOW byte
689 // RESP12 - Blocks A to D Corrected Errors.
690 // 0 = No errors;
691 // 1 = 1–2 bit errors detected and corrected;
692 // 2 = 3–5 bit errors detected and corrected.
693 // 3 = Uncorrectable.
694 uint8_t BLED : 2;
695 uint8_t BLEC : 2;
696 uint8_t BLEB : 2;
697 uint8_t BLEA : 2;
698 } resp;
700} si47x_rds_status;
701
702/**
703 * @ingroup group01
704 *
705 * @brief FM_RDS_INT_SOURCE property data type
706 *
707 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 103
708 * @see also https://en.wikipedia.org/wiki/Radio_Data_System
709 */
710typedef union
711{
712 struct
713 {
714 uint8_t RDSRECV : 1; //!< If set, generate RDSINT when RDS FIFO has at least FM_RDS_INT_FIFO_COUNT entries.
715 uint8_t RDSSYNCLOST : 1; //!< If set, generate RDSINT when RDS loses synchronization.
716 uint8_t RDSSYNCFOUND : 1; //!< f set, generate RDSINT when RDS gains synchronization.
717 uint8_t DUMMY1 : 1; //!< Always write to 0.
718 uint8_t RDSNEWBLOCKA : 1; //!< If set, generate an interrupt when Block A data is found or subsequently changed
719 uint8_t RDSNEWBLOCKB : 1; //!< If set, generate an interrupt when Block B data is found or subsequently changed
720 uint8_t DUMMY2 : 5; //!< Reserved - Always write to 0.
721 uint8_t DUMMY3 : 5; //!< Reserved - Always write to 0.
722 } refined;
724} si47x_rds_int_source;
725
726/**
727 * @ingroup group01
728 *
729 * @brief Data type for FM_RDS_CONFIG Property
730 *
731 * IMPORTANT: all block errors must be less than or equal the associated block error threshold for the group
732 * to be stored in the RDS FIFO.
733 * 0 = No errors; 1 = 1–2 bit errors detected and corrected; 2 = 3–5 bit errors detected and corrected; 3 = Uncorrectable.
734 * Recommended Block Error Threshold options:
735 * 2,2,2,2 = No group stored if any errors are uncorrected.
736 * 3,3,3,3 = Group stored regardless of errors.
737 * 0,0,0,0 = No group stored containing corrected or uncorrected errors.
738 * 3,2,3,3 = Group stored with corrected errors on B, regardless of errors on A, C, or D.
739 *
740 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 58 and 104
741 */
742typedef union
743{
744 struct
745 {
746 uint8_t RDSEN : 1; //!< 1 = RDS Processing Enable.
747 uint8_t DUMMY1 : 7;
748 uint8_t BLETHD : 2; //!< Block Error Threshold BLOCKD
749 uint8_t BLETHC : 2; //!< Block Error Threshold BLOCKC.
750 uint8_t BLETHB : 2; //!< Block Error Threshold BLOCKB.
751 uint8_t BLETHA : 2; //!< Block Error Threshold BLOCKA.
752 } arg;
754} si47x_rds_config;
755
756/**
757 * @ingroup group01
758 *
759 * @brief Block A data type
760 */
761typedef union
762{
763 struct
764 {
765 uint16_t pi;
766 } refined;
767 struct
768 {
769 uint8_t highValue; // Most Significant uint8_t first
770 uint8_t lowValue;
771 } raw;
772} si47x_rds_blocka;
773
774/**
775 * @ingroup group01
776 *
777 * @brief Block B data type
778 *
779 * @details For GCC on System-V ABI on 386-compatible (32-bit processors), the following stands:
780 *
781 * 1) Bit-fields are allocated from right to left (least to most significant).
782 * 2) A bit-field must entirely reside in a storage unit appropriate for its declared type.
783 * Thus a bit-field never crosses its unit boundary.
784 * 3) Bit-fields may share a storage unit with other struct/union members, including members that are not bit-fields.
785 * Of course, struct members occupy different parts of the storage unit.
786 * 4) Unnamed bit-fields' types do not affect the alignment of a structure or union, although individual
787 * bit-fields' member offsets obey the alignment constraints.
788 *
789 * @see also Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 78 and 79
790 * @see also https://en.wikipedia.org/wiki/Radio_Data_System
791 */
792typedef union
793{
794 struct
795 {
796 uint16_t address : 2; // Depends on Group Type and Version codes. If 0A or 0B it is the Text Segment Address.
797 uint16_t DI : 1; // Decoder Controll bit
798 uint16_t MS : 1; // Music/Speech
799 uint16_t TA : 1; // Traffic Announcement
800 uint16_t programType : 5; // PTY (Program Type) code
801 uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
802 uint16_t versionCode : 1; // (B0) => 0=A; 1=B
803 uint16_t groupType : 4; // Group Type code.
804 } group0;
805 struct
806 {
807 uint16_t address : 4; // Depends on Group Type and Version codes. If 2A or 2B it is the Text Segment Address.
808 uint16_t textABFlag : 1; // Do something if it chanhes from binary "0" to binary "1" or vice-versa
809 uint16_t programType : 5; // PTY (Program Type) code
810 uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
811 uint16_t versionCode : 1; // (B0) => 0=A; 1=B
812 uint16_t groupType : 4; // Group Type code.
813 } group2;
814 struct
815 {
816 uint16_t content : 4; // Depends on Group Type and Version codes.
817 uint16_t textABFlag : 1; // Do something if it chanhes from binary "0" to binary "1" or vice-versa
818 uint16_t programType : 5; // PTY (Program Type) code
819 uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
820 uint16_t versionCode : 1; // (B0) => 0=A; 1=B
821 uint16_t groupType : 4; // Group Type code.
822 } refined;
823 struct
824 {
825 uint8_t lowValue;
826 uint8_t highValue; // Most Significant byte first
827 } raw;
828} si47x_rds_blockb;
829
830/*
831 *
832 *
833 * Group type 4A ( RDS Date and Time)
834 * When group type 4A is used by the station, it shall be transmitted every minute according to EN 50067.
835 * This Structure uses blocks 2,3 and 5 (B,C,D)
836 *
837 * Commented due to “Crosses boundary” on GCC 32-bit plataform.
838 */
839/*
840typedef union {
841 struct
842 {
843 uint32_t offset : 5; // Local Time Offset
844 uint32_t offset_sense : 1; // Local Offset Sign ( 0 = + , 1 = - )
845 uint32_t minute : 6; // UTC Minutes
846 uint32_t hour : 5; // UTC Hours
847 uint32_t mjd : 17; // Modified Julian Day Code
848 } refined;
849 uint8_t raw[6];
850} si47x_rds_date_time;
851*/
852
853/**
854 * @ingroup group01
855 *
856 * Group type 4A ( RDS Date and Time)
857 * When group type 4A is used by the station, it shall be transmitted every minute according to EN 50067.
858 * This Structure uses blocks 2,3 and 5 (B,C,D)
859 *
860 * ATTENTION:
861 * To make it compatible with 8, 16 and 32 bits platforms and avoid Crosses boundary, it was necessary to
862 * split minute and hour representation.
863 */
864typedef union
865{
866 struct
867 {
868 uint8_t offset : 5; // Local Time Offset
869 uint8_t offset_sense : 1; // Local Offset Sign ( 0 = + , 1 = - )
870 uint8_t minute1 : 2; // UTC Minutes - 2 bits less significant (void “Crosses boundary”).
871 uint8_t minute2 : 4; // UTC Minutes - 4 bits more significant (void “Crosses boundary”)
872 uint8_t hour1 : 4; // UTC Hours - 4 bits less significant (void “Crosses boundary”)
873 uint8_t hour2 : 1; // UTC Hours - 4 bits more significant (void “Crosses boundary”)
874 uint16_t mjd1 : 15; // Modified Julian Day Code - 15 bits less significant (void “Crosses boundary”)
875 uint16_t mjd2 : 2; // Modified Julian Day Code - 2 bits more significant (void “Crosses boundary”)
876 } refined;
878} si47x_rds_date_time;
879
880/**
881 * @ingroup group01
882 *
883 * AGC data types
884 * FM / AM and SSB structure to AGC
885 *
886 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); For FM page 80; for AM page 142
887 * @see AN332 REV 0.8 Universal Programming Guide Amendment for SI4735-D60 SSB and NBFM patches; page 18.
888 */
889typedef union
890{
891 struct
892 {
893 // status ("RESP0")
894 uint8_t STCINT : 1;
895 uint8_t DUMMY1 : 1;
896 uint8_t RDSINT : 1; // Not used for AM/SSB
897 uint8_t RSQINT : 1;
898 uint8_t DUMMY2 : 2;
899 uint8_t ERR : 1;
900 uint8_t CTS : 1;
901 // RESP1
902 uint8_t AGCDIS : 1; // This bit indicates if the AGC is enabled or disabled. 0 = AGC enabled; 1 = AGC disabled.
903 uint8_t DUMMY : 7;
904 // RESP2
905 uint8_t AGCIDX; // For FM (5 bits - READ_LNA_GAIN_INDEX - 0 = Minimum attenuation (max gain)). For AM (8 bits). This byte reports the current AGC gain index.
906 } refined;
908} si47x_agc_status;
909
910/**
911 * @ingroup group01
912 *
913 * If FM, Overrides AGC setting by disabling the AGC and forcing the LNA to have a certain gain that ranges between 0
914 * (minimum attenuation) and 26 (maximum attenuation).
915 * If AM, overrides the AGC setting by disabling the AGC and forcing the gain index that ranges between 0
916 *
917 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); For FM page 81; for AM page 143
918 */
919typedef union
920{
921 struct
922 {
923 // ARG1
924 uint8_t AGCDIS : 1; // if set to 1 indicates if the AGC is disabled. 0 = AGC enabled; 1 = AGC disabled.
925 uint8_t DUMMY : 7;
926 // ARG2
927 uint8_t AGCIDX; // AGC Index; If AMAGCDIS = 1, this byte forces the AGC gain index; 0 = Minimum attenuation (max gain)
928 } arg;
930} si47x_agc_overrride;
931
932/**
933 * @ingroup group01
934 *
935 * The bandwidth of the AM channel filter data type
936 * AMCHFLT values: 0 = 6 kHz Bandwidth
937 * 1 = 4 kHz Bandwidth
938 * 2 = 3 kHz Bandwidth
939 * 3 = 2 kHz Bandwidth
940 * 4 = 1 kHz Bandwidth
941 * 5 = 1.8 kHz Bandwidth
942 * 6 = 2.5 kHz Bandwidth, gradual roll off
943 * 7–15 = Reserved (Do not use)
944 *
945 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 125 and 151
946 */
947typedef union
948{
949 struct
950 {
951 uint8_t AMCHFLT : 4; //!< Selects the bandwidth of the AM channel filter.
952 uint8_t DUMMY1 : 4;
953 uint8_t AMPLFLT : 1; //!< Enables the AM Power Line Noise Rejection Filter.
954 uint8_t DUMMY2 : 7;
955 } param;
957} si47x_bandwidth_config; // AM_CHANNEL_FILTER
958
959/**
960 * @ingroup group01
961 *
962 * SSB - datatype for SSB_MODE (property 0x0101)
963 *
964 * @see AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; page 24
965 */
966typedef union
967{
968 struct
969 {
970 uint8_t AUDIOBW : 4; //!< 0 = 1.2kHz (default); 1=2.2kHz; 2=3kHz; 3=4kHz; 4=500Hz; 5=1kHz
971 uint8_t SBCUTFLT : 4; //!< SSB side band cutoff filter for band passand low pass filter
972 uint8_t AVC_DIVIDER : 4; //!< set 0 for SSB mode; set 3 for SYNC mode;
973 uint8_t AVCEN : 1; //!< SSB Automatic Volume Control (AVC) enable; 0=disable; 1=enable (default);
974 uint8_t SMUTESEL : 1; //!< SSB Soft-mute Based on RSSI or SNR
975 uint8_t DUMMY1 : 1; //!< Always write 0;
976 uint8_t DSP_AFCDIS : 1; //!< 0=SYNC MODE, AFC enable; 1=SSB MODE, AFC disable.
977 } param;
979} si47x_ssb_mode;
980
981/**
982 * @ingroup group01
983 *
984 * @brief Digital audio output format data structure (Property 0x0102. DIGITAL_OUTPUT_FORMAT).
985 *
986 * @details Used to configure: DCLK edge, data format, force mono, and sample precision.
987 *
988 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 195.
989 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); chapter 9 - Digital Audio Interface
990 */
991typedef union
992{
993 struct
994 {
995 uint8_t OSIZE : 2; //!< Digital Output Audio Sample Precision (0=16 bits, 1=20 bits, 2=24 bits, 3=8bits).
996 uint8_t OMONO : 1; //!< Digital Output Mono Mode (0=Use mono/stereo blend ).
997 uint8_t OMODE : 4; //!< Digital Output Mode (0000=I2S, 0110 = Left-justified, 1000 = MSB at second DCLK after DFS pulse, 1100 = MSB at first DCLK after DFS pulse).
998 uint8_t OFALL : 1; //!< Digital Output DCLK Edge (0 = use DCLK rising edge, 1 = use DCLK falling edge)
999 uint8_t dummy : 8; //!< Always 0.
1000 } refined;
1002} si4735_digital_output_format;
1003
1004/**
1005 * @ingroup group01
1006 * @brief patch header stored in a eeprom
1007 * @details This data type represents o header of a eeprom with a patch content
1008 * @details This structure will be used to read an eeprom generated by leo sketch SI47XX_09_SAVE_SSB_PATCH_EEPROM.ino.
1009 * @details The sketch SI47XX_09_SAVE_SSB_PATCH_EEPROM can be found on Examples/SI47XX_TOOLS folder
1010 */
1011typedef union
1012{
1013 struct
1014 {
1015 uint8_t reserved[8]; // Not used
1016 uint8_t status[8]; // Note used
1017 uint8_t patch_id[14]; // Patch name
1018 uint16_t patch_size; // Patch size (in bytes)
1019 } refined;
1021} si4735_eeprom_patch_header;
1022
1023/**
1024 * @ingroup group01
1025 *
1026 * @brief Digital audio output sample structure (Property 0x0104. DIGITAL_OUTPUT_SAMPLE_RATE).
1027 *
1028 * @details Used to enable digital audio output and to configure the digital audio output sample rate in samples per second (sps).
1029 *
1030 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 196.
1031 */
1032typedef struct
1033{
1034 uint16_t DOSR; // Digital Output Sample Rate(32–48 ksps .0 to disable digital audio output).
1035} si4735_digital_output_sample_rate; // Maybe not necessary
1036
1037
1038/**********************************************************************
1039 * SI4735 Class definition
1040 **********************************************************************/
1041
1042/**
1043 * @brief SI4735 Class
1044 *
1045 * @details This class implements all functions to help you to control the Si47XX devices.
1046 * This library was built based on “Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0)”.
1047 * It also can be used on all members of the SI473X family respecting, of course, the features available
1048 * for each IC version. These functionalities can be seen in the comparison matrix shown in
1049 * table 1 (Product Family Function); pages 2 and 3 of the programming guide.
1050 *
1051 * @author PU2CLR - Ricardo Lima Caratti
1052 */
1054{
1055protected:
1056 char rds_buffer2A[65]; //!< RDS Radio Text buffer - Program Information
1057 char rds_buffer2B[33]; //!< RDS Radio Text buffer - Station Informaation
1058 char rds_buffer0A[9]; //!< RDS Basic tuning and switching information (Type 0 groups)
1059 char rds_time[25]; //!< RDS date time received information
1060
1061 int rdsTextAdress2A; //!< rds_buffer2A current position
1062 int rdsTextAdress2B; //!< rds_buffer2B current position
1063 int rdsTextAdress0A; //!< rds_buffer0A current position
1064
1065 bool rdsEndGroupA = false;
1066 bool rdsEndGroupB = false;
1067
1068 int16_t deviceAddress = SI473X_ADDR_SEN_LOW; //!< Stores the current I2C bus address.
1069
1070 // Delays
1071 uint16_t maxDelaySetFrequency = MAX_DELAY_AFTER_SET_FREQUENCY; //!< Stores the maximum delay after set frequency command (in ms).
1072 uint16_t maxDelayAfterPouwerUp = MAX_DELAY_AFTER_POWERUP; //!< Stores the maximum delay you have to setup after a power up command (in ms).
1073 unsigned long maxSeekTime = MAX_SEEK_TIME; //!< Stores the maximum time (ms) for a seeking process. Defines the maximum seeking time.
1074
1076 uint8_t resetPin; //!< pin used on Arduino Board to RESET the Si47XX device
1077
1078 uint8_t currentTune; //!< tell the current tune (FM, AM or SSB)
1079
1080 uint16_t currentMinimumFrequency; //!< minimum frequency of the current band
1081 uint16_t currentMaximumFrequency; //!< maximum frequency of the current band
1082 uint16_t currentWorkFrequency; //!< current frequency
1083
1084 uint16_t currentStep; //!< Stores the current step used to increment or decrement the frequency.
1085
1086 uint8_t lastMode = -1; //!< Stores the last mode used.
1087
1088 uint8_t currentAvcAmMaxGain = DEFAULT_CURRENT_AVC_AM_MAX_GAIN; //!< Stores the current Automatic Volume Control Gain for AM.
1089 uint8_t currentClockType = XOSCEN_CRYSTAL; //!< Stores the current clock type used (Crystal or REF CLOCK)
1092
1093 uint16_t refClock = 32768; //!< Frequency of Reference Clock in Hz.
1094 uint16_t refClockPrescale = 1; //!< Prescaler for Reference Clock (divider).
1095 uint8_t refClockSourcePin = 0; //!< 0 = RCLK pin is clock source; 1 = DCLK pin is clock source.
1096
1097 si47x_frequency currentFrequency; //!< data structure to get current frequency
1098 si47x_set_frequency currentFrequencyParams;
1099 si47x_rqs_status currentRqsStatus; //!< current Radio SIgnal Quality status
1100 si47x_response_status currentStatus; //!< current device status
1101 si47x_firmware_information firmwareInfo; //!< firmware information
1102 si47x_rds_status currentRdsStatus; //!< current RDS status
1103 si47x_agc_status currentAgcStatus; //!< current AGC status
1104 si47x_ssb_mode currentSSBMode; //!< indicates if USB or LSB
1105
1106 si473x_powerup powerUp;
1107
1108 uint8_t volume = 32; //!< Stores the current vlume setup (0-63).
1109
1110 uint8_t currentAudioMode = SI473X_ANALOG_AUDIO; //!< Current audio mode used (ANALOG or DIGITAL or both)
1113
1114 void waitInterrupr(void);
1115 si47x_status getInterruptStatus();
1116
1117 // void setGpioCtl(uint8_t GPO1OEN, uint8_t GPO2OEN, uint8_t GPO3OEN);
1118 // void setGpio(uint8_t GPO1LEVEL, uint8_t GPO2LEVEL, uint8_t GPO3LEVEL);
1119 // void setGpioIen(uint8_t STCIEN, uint8_t RSQIEN, uint8_t ERRIEN, uint8_t CTSIEN, uint8_t STCREP, uint8_t RSQREP);
1120
1121 void sendProperty(uint16_t propertyNumber, uint16_t param);
1122
1123 void sendSSBModeProperty();
1124 void disableFmDebug();
1125 void clearRdsBuffer2A();
1126 void clearRdsBuffer2B();
1127 void clearRdsBuffer0A();
1128 void getSsbAgcStatus();
1129
1130public:
1131 SI4735();
1132 void reset(void);
1133 void waitToSend(void);
1134
1135 void setGpioCtl(uint8_t GPO1OEN, uint8_t GPO2OEN, uint8_t GPO3OEN);
1136 void setGpio(uint8_t GPO1LEVEL, uint8_t GPO2LEVEL, uint8_t GPO3LEVEL);
1137 void setGpioIen(uint8_t STCIEN, uint8_t RSQIEN, uint8_t ERRIEN, uint8_t CTSIEN, uint8_t STCREP, uint8_t RSQREP);
1138
1139 void setup(uint8_t resetPin, uint8_t defaultFunction);
1140 void setup(uint8_t resetPin, uint8_t ctsIntEnable, uint8_t defaultFunction, uint8_t audioMode = SI473X_ANALOG_AUDIO, uint8_t clockType = XOSCEN_CRYSTAL, uint8_t gpo2Enable = 0);
1141
1142 void setRefClock(uint16_t refclk);
1143 void setRefClockPrescaler(uint16_t prescale, uint8_t rclk_sel = 0);
1144
1146
1147 /**
1148 * @ingroup group10 Generic set and get property
1149 *
1150 * @brief Sets a given SI47XX device property
1151 *
1152 * @details Sets the Si47XX device with a given attribute.
1153 * @details You might need to use the bit operations or some bit field structure to set right the values.
1154 * @details Used this function instead of the sendProperty.
1155 *
1156 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 55, 69, 124 and 134.
1157 * @see getProperty, sendProperty
1158 * @param propertyNumber
1159 * @param param pamameter value
1160 */
1161 inline void setProperty(uint16_t propertyNumber, uint16_t param)
1162 {
1163 sendProperty(propertyNumber, param);
1164 };
1165
1166 void sendCommand(uint8_t cmd, int parameter_size, const uint8_t *parameter);
1167 void getCommandResponse(int num_of_bytes, uint8_t *response);
1168 si47x_status getStatusResponse();
1169
1170 void setPowerUp(uint8_t CTSIEN, uint8_t GPO2OEN, uint8_t PATCH, uint8_t XOSCEN, uint8_t FUNC, uint8_t OPMODE);
1171 void radioPowerUp(void);
1172 void analogPowerUp(void);
1173 void powerDown(void);
1174
1175 void setFrequency(uint16_t);
1176
1177 void getStatus(uint8_t, uint8_t);
1178
1179 uint16_t getFrequency(void);
1180
1181 /**
1182 * STATUS RESPONSE
1183 * Set of methods to get current status information. Call them after getStatus or getFrequency or seekStation
1184 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 63
1185 */
1186
1187 /**
1188 * @ingroup group08
1189 * @brief Get the Signal Quality Interrupt status
1190 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 63
1191 * @return RDSINT status
1192 */
1194 {
1195 return currentStatus.resp.RSQINT;
1196 };
1197
1198 /**
1199 * @ingroup group08
1200 * @brief Get the Radio Data System (RDS) Interrupt status
1201 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 63
1202 * @return RDSINT status
1203 */
1205 {
1206 return currentStatus.resp.RDSINT;
1207 };
1208
1209 /**
1210 * @ingroup group08
1211 * @brief Get the Tune Complete status
1212 * @details Seek/Tune Complete Interrupt; 1 = Tune complete has been triggered.
1213 * @return STCINT status
1214 */
1216 {
1217 return currentStatus.resp.STCINT;
1218 };
1219
1220 /**
1221 * @ingroup group08
1222 * @brief Get the Status Error
1223 * @details Return the Error flag (true or false) of status of the least Tune or Seek
1224 * @return Error flag
1225 */
1226 inline bool getStatusError()
1227 {
1228 return currentStatus.resp.ERR;
1229 };
1230
1231 /**
1232 * @ingroup group08
1233 * @brief Gets the Error flag Clear to Send
1234 *
1235 * @return CTS
1236 */
1237 inline bool getStatusCTS() { return currentStatus.resp.CTS; };
1238
1239 /**
1240 * @ingroup group08
1241 * @brief Returns true if the AFC rails (AFC Rail Indicator).
1242 *
1243 * @return true
1244 */
1245 inline bool getACFIndicator()
1246 {
1247 return currentStatus.resp.AFCRL;
1248 };
1249
1250 /**
1251 * @ingroup group08
1252 * @brief Returns true if a seek hit the band limit
1253 *
1254 * @details (WRAP = 0 in FM_START_SEEK) or wrapped to the original frequency(WRAP = 1).
1255 *
1256 * @return BLTF
1257 */
1258 inline bool getBandLimit()
1259 {
1260 return currentStatus.resp.BLTF;
1261 };
1262
1263 /**
1264 * @ingroup group08
1265 * @brief Gets the channel status
1266 *
1267 * @details Returns true if the channel is currently valid as determined by the seek/tune properties (0x1403, 0x1404, 0x1108)
1268 *
1269 * @return true
1270 * @return false
1271 */
1272 inline bool getStatusValid()
1273 {
1274 return currentStatus.resp.VALID;
1275 };
1276
1277 /**
1278 * @ingroup group08
1279 * @brief Returns the value of Received Signal Strength Indicator (dBμV).
1280 *
1281 * @return uint8_t
1282 */
1284 {
1285 return currentStatus.resp.RSSI;
1286 };
1287
1288 /**
1289 * @ingroup group08
1290 * @brief Gets the SNR metric when tune is complete (dB)
1291 *
1292 * @details Returns the value of the SNR metric when tune is complete (dB).
1293 *
1294 * @return uint8_t
1295 */
1297 {
1298 return currentStatus.resp.SNR;
1299 };
1300
1301 /**
1302 * @ingroup group08
1303 * @brief Get the Status the M U L T
1304 *
1305 * @details Returns the value containing the multipath metric when tune is complete.
1306 *
1307 * @return uint8_t
1308 */
1310 {
1311 return currentStatus.resp.MULT;
1312 };
1313
1314 /**
1315 * @ingroup group17
1316 * @brief Get the Antenna Tuning Capacitor value
1317 * @details Returns the current antenna tuning capacitor value. The tuning capacitance is 95 fF x READANTCAP + 7 pF.
1318 * @details ON AM or SSB mode, the MULT attribute sotores the high byte of READANTCAP and the attribute READANTCAP by itself stores the low byte.
1319 *
1320 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 74,74, 140 and 141.
1321 * @return uint8_t capacitance
1322 */
1324 {
1325 si47x_antenna_capacitor cap;
1326
1327 if (currentTune == FM_TUNE_FREQ)
1328 return currentStatus.resp.READANTCAP;
1329 else
1330 {
1331 cap.raw.ANTCAPL = currentStatus.resp.READANTCAP; // On AM it is the low byte the READANTCAP value
1332 cap.raw.ANTCAPH = currentStatus.resp.MULT; // On AM it is the high byte the READANTCAP value
1333 return cap.value;
1334 }
1335 };
1336
1337 void getAutomaticGainControl(); //!< Queries Automatic Gain Control STATUS
1338
1339 /**
1340 * @ingroup group17
1341 * @brief Sets the Avc Am Max Gain to maximum gain (0x7800)
1342 */
1343 inline void setAvcAmMaxGain()
1344 {
1345 sendProperty(AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN, 0x7800);
1346 currentAvcAmMaxGain = 90;
1347 };
1348
1349 /**
1350 * @ingroup group17
1351 * @brief Sets the Avc Am Max Gain to minimal gain (0x1000)
1352 */
1353 inline void setAvcAmMinGain()
1354 {
1355 sendProperty(AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN, 0x1000);
1356 currentAvcAmMaxGain = 12;
1357 };
1358
1359 /**
1360 * @ingroup group17
1361 * @brief Sets the Avc Am Max Gain to default gain (0x2A80)
1362 */
1364 {
1365 sendProperty(AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN, 0x1543);
1366 currentAvcAmMaxGain = DEFAULT_CURRENT_AVC_AM_MAX_GAIN;
1367 };
1368
1369
1370 void setAvcAmMaxGain(uint8_t gain = 90); //!< Sets the maximum gain for automatic volume control.
1371
1372 /**
1373 * @ingroup group17
1374 * @brief Get the current Avc Am Max Gain
1375 *
1376 * @return uint8_t Current AVC gain index value
1377 */
1379 {
1380 return currentAvcAmMaxGain;
1381 };
1382
1383 /**
1384 * @ingroup group17
1385 * @brief Sets the Am Soft Mute Max Attenuation
1386 *
1387 * @details This function can be useful to disable Soft Mute. The value 0 disable soft mute.
1388 * @details Specified in units of dB. Default maximum attenuation is 8 dB. It works for AM and SSB.
1389 *
1390 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 158.
1391 *
1392 * @param smattn Maximum attenuation to apply when in soft mute
1393 */
1394 inline void setAmSoftMuteMaxAttenuation(uint8_t smattn = 0)
1395 {
1396 sendProperty(AM_SOFT_MUTE_MAX_ATTENUATION, smattn);
1397 };
1398
1399 /**
1400 * @ingroup group17
1401 * @brief Sets the SSB Soft Mute Max Attenuation object
1402 *
1403 * @details Sets maximum attenuation during soft mute (dB). Set to 0 to disable soft mute.
1404 * @details Specified in units of dB. Default maximum attenuation is 8 dB.
1405 * @details You can use setAmSoftMuteMaxAttenuation instead. Same AM property values.
1406 * @param smattn Maximum attenuation to apply when in soft mute.
1407 */
1408 inline void setSsbSoftMuteMaxAttenuation(uint8_t smattn = 0)
1409 {
1410 sendProperty(SSB_SOFT_MUTE_MAX_ATTENUATION, smattn);
1411 };
1412
1413 /**
1414 * @ingroup group17
1415 * @brief Sets the number of milliseconds the low IF peak detector
1416 *
1417 * @details Sets the number of milliseconds the low IF peak detector must not be exceeded before increasing the gain. Default value is 140 (approximately 40 dB / s).
1418 * @param param number of milliseconds ( from 4 to 248; step 4); default value 0x008C (140).
1419 */
1420 inline void setSsbIfAgcReleaseRate(uint8_t param = 140)
1421 {
1422 sendProperty(SSB_IF_AGC_RELEASE_RATE, param);
1423 };
1424
1425 /**
1426 * @ingroup group17
1427 * @brief Sets the IF AGC attack rate
1428 *
1429 * @details Large values provide slower attack, and smaller values provide faster attack
1430 * @param param number of milliseconds ( from 4 to 248; step 4); default value 4.
1431 */
1432 inline void setSsbIfAgcAttackRate(uint8_t param = 4)
1433 {
1434 sendProperty(SSB_IF_AGC_ATTACK_RATE, param);
1435 };
1436
1437 /**
1438 * @ingroup group08
1439 * @brief Checks if the AGC is enabled
1440 *
1441 * @return true if the AGC is enabled
1442 */
1443 inline bool isAgcEnabled()
1444 {
1445 return !currentAgcStatus.refined.AGCDIS;
1446 };
1447
1448 /**
1449 * @ingroup group08
1450 * @brief Gets the current AGC gain index
1451 *
1452 * @return uint8_t The current AGC gain index.
1453 */
1455 {
1456 return currentAgcStatus.refined.AGCIDX;
1457 };
1458
1459 void setAutomaticGainControl(uint8_t AGCDIS, uint8_t AGCIDX);
1460
1461 /**
1462 * @ingroup group08 AGC
1463 *
1464 * @brief Automatic Gain Control setup (alternative name for setAutomaticGainControl )
1465 *
1466 * @details If FM, overrides AGC setting by disabling the AGC and forcing the LNA to have a certain gain that ranges between 0
1467 * (minimum attenuation) and 26 (maximum attenuation).
1468 * @details If AM/SSB, Overrides the AGC setting by disabling the AGC and forcing the gain index that ranges between 0
1469 * (minimum attenuation) and 37+ATTN_BACKUP (maximum attenuation).
1470 *
1471 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); For FM page 81; for AM page 143
1472 * @see setAutomaticGainControl
1473 *
1474 * @param uint8_t AGCDIS This param selects whether the AGC is enabled or disabled (0 = AGC enabled; 1 = AGC disabled);
1475 * @param uint8_t AGCIDX AGC Index (0 = Minimum attenuation (max gain); 1 – 36 = Intermediate attenuation);
1476 * if >greater than 36 - Maximum attenuation (min gain) ).
1477 */
1478 inline void setAGC(uint8_t AGCDIS, uint8_t AGCIDX) { setAutomaticGainControl( AGCDIS, AGCIDX); };
1479
1480
1481 void setSsbAgcOverrite(uint8_t SSBAGCDIS, uint8_t SSBAGCNDX, uint8_t reserved = 0);
1482
1483 void getCurrentReceivedSignalQuality(uint8_t INTACK);
1485
1486 // AM and FM
1487
1488 /**
1489 * @ingroup group08
1490 * @brief Get the current receive signal strength (0–127 dBμV)
1491 *
1492 * @return uint8_t a value between 0 to 127
1493 */
1495 {
1496 return currentRqsStatus.resp.RSSI;
1497 };
1498
1499 /**
1500 * @ingroup group08
1501 * @brief Gets the current SNR metric (0–127 dB).
1502 *
1503 * @return uint8_t SNR value in dB (0-127)
1504 */
1506 {
1507 return currentRqsStatus.resp.SNR;
1508 };
1509
1510 /**
1511 * @ingroup group08
1512 * @brief Checks if RSSI detected is LOW.
1513 *
1514 * @return true if RSSI is low
1515 */
1517 {
1518 return currentRqsStatus.resp.RSSIILINT;
1519 };
1520
1521 /**
1522 * @ingroup group08
1523 * @brief Checks if RSSI detected is high
1524 *
1525 * @return true if RSSI detected is high
1526 */
1528 {
1529 return currentRqsStatus.resp.RSSIHINT;
1530 };
1531
1532 /**
1533 * @ingroup group08
1534 * @brief Checks if SNR detect is low
1535 *
1536 * @return true if SNR detected is low
1537 */
1539 {
1540 return currentRqsStatus.resp.SNRLINT;
1541 };
1542
1543 /**
1544 * @ingroup group08
1545 * @brief Checks if SNR detect is high
1546 *
1547 * @return true if SNR detect is high
1548 */
1550 {
1551 return currentRqsStatus.resp.SNRHINT;
1552 };
1553
1554 /**
1555 * @ingroup group08
1556 * @brief Checks if the current channel is valid
1557 *
1558 * @return true if the current channel is valid
1559 */
1561 {
1562 return currentRqsStatus.resp.VALID;
1563 };
1564
1565 /**
1566 * @ingroup group08
1567 * @brief AFC Rail Indicator
1568 *
1569 * @return true or false
1570 */
1572 {
1573 return currentRqsStatus.resp.AFCRL;
1574 };
1575
1576 /**
1577 * @ingroup group08
1578 * @brief Soft Mute Indicator.
1579 *
1580 * @details Indicates soft mute is engaged.
1581 *
1582 * @return true if soft mute indicates is engaged.
1583 */
1585 {
1586 return currentRqsStatus.resp.SMUTE;
1587 };
1588
1589 // Just FM
1590
1591 /**
1592 * @ingroup group08
1593 * @brief Gets the value of the amount of stereo blend in % (100 = full stereo, 0 = full mono).
1594 *
1595 * @return uint8_t value (0 to 100)
1596 */
1598 {
1599 return currentRqsStatus.resp.STBLEND;
1600 };
1601
1602 /**
1603 * @ingroup group08
1604 * @brief Checks the current pilot
1605 *
1606 * @details Indicates stereo pilot presence.
1607 *
1608 * @return true if stereo pilot presence has detected
1609 */
1610 inline bool getCurrentPilot()
1611 {
1612 return currentRqsStatus.resp.PILOT;
1613 };
1614
1615 /**
1616 * @ingroup group08
1617 * @brief Gets the current Multipath
1618 *
1619 * @details Contains the current multipath metric. (0 = no multipath; 100 = full multipath)
1620 *
1621 * @return uint8_t value (0 to 100)
1622 */
1624 {
1625 return currentRqsStatus.resp.MULT;
1626 };
1627
1628 /**
1629 * @ingroup group08
1630 * @brief Gets the Signed frequency offset (kHz).
1631 *
1632 * @return uint8_t
1633 */
1635 return currentRqsStatus.resp.FREQOFF;
1636 };
1637
1638 /**
1639 * @ingroup group08
1640 * @brief Get Multipath Detect Low
1641 *
1642 * @return true
1643 * @return false
1644 */
1646 return currentRqsStatus.resp.MULTLINT;
1647 };
1648
1649 /**
1650 * @ingroup group08
1651 * @brief Gets the Current Multipath Detect High
1652 *
1653 * @return true
1654 * @return false
1655 */
1657 return currentRqsStatus.resp.MULTHINT;
1658 };
1659
1660 /**
1661 * @ingroup group08
1662 * @brief Gets the Current Blend Detect Interrupt
1663 *
1664 * @return true
1665 * @return false
1666 */
1668 return currentRqsStatus.resp.BLENDINT;
1669 };
1670
1671 /*
1672 * FIRMWARE RESPONSE
1673 *
1674 * See Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 66
1675 */
1676
1677 /**
1678 * @ingroup group06
1679 * @brief Returns the Firmware Part Number
1680 *
1681 * @return uint8_t
1682 */
1684 return firmwareInfo.resp.PN;
1685 };
1686
1687 /**
1688 * @ingroup group06
1689 * @brief Returns the Firmware F W M A J O R
1690 *
1691 * @return uint8_t
1692 */
1694 return firmwareInfo.resp.FWMAJOR;
1695 };
1696
1697 /**
1698 * @ingroup group06
1699 * @brief Returns the Firmware F W M I N O R
1700 *
1701 * @return uint8_t
1702 */
1704 return firmwareInfo.resp.FWMINOR;
1705 };
1706
1707 /**
1708 * @ingroup group06
1709 * @brief Returns the Firmware P A T C H HIGH
1710 *
1711 * @return uint8_t
1712 */
1714 return firmwareInfo.resp.PATCHH;
1715 };
1716
1717 /**
1718 * @ingroup group06
1719 * @brief Returns the Firmware P A T C H LOW
1720 *
1721 * @return uint8_t
1722 */
1724 return firmwareInfo.resp.PATCHL;
1725 };
1726
1727 /**
1728 * @ingroup group06
1729 * @brief Get the Firmware C M P M A J O R object
1730 *
1731 * @return uint8_t
1732 */
1734 return firmwareInfo.resp.CMPMAJOR;
1735 }; //!< RESP6 - Returns the Component Major Revision (ASCII).
1736
1737 /**
1738 * @ingroup group06
1739 * @brief Returns the Component Minor Revision (ASCII) (RESP7)
1740 *
1741 * @return uint8_t
1742 */
1744 return firmwareInfo.resp.CMPMINOR;
1745 };
1746
1747 /**
1748 * @ingroup group06
1749 * @brief RESP8 - Returns the Chip Revision (ASCII)
1750 *
1751 * @return uint8_t
1752 */
1754 return firmwareInfo.resp.CHIPREV;
1755 };
1756
1757 void setVolume(uint8_t volume);
1759 void volumeDown();
1760 void volumeUp();
1761
1762 /**
1763 * @ingroup group13 Audio volume
1764 * @brief Get the Current Volume
1765 * @details Returns the current volume level.
1766 * @return uint8_t
1767 */
1768 inline uint8_t getCurrentVolume() { return volume; };
1769
1770 /**
1771 * @ingroup group13 Audio volume
1772 * @brief Set the Volume Up
1773 * @details Same volumeUp()
1774 * @see volumeUp
1775 */
1776 inline void setVolumeUp() { volumeUp(); };
1777 /**
1778 * @ingroup group13 Audio volume
1779 * @brief Set the Volume Down
1780 * @details Same volumeDown()
1781 * @return voi
1782 */
1783 inline void setVolumeDown() { volumeDown(); };
1784
1785 /**
1786 * @ingroup group13 Digital Audio setup
1787 * @brief Sets the Audio Mode. See table below.
1788 * @details If you want to change the audio mode, call this function before call setAM(), setFM() or setSSB().
1789 * @details Sets the Si47XX device to use ANALOG or DIGITAL audio output. The table below show the valid values.
1790 * @details This function will only take effect after calling setAM(), setFM() or setSSB().
1791 *
1792 *
1793 * | Macro | Value (Binary) | Description |
1794 * | ----- | ----- | ----------- |
1795 * | SI473X_ANALOG_AUDIO | 0b00000101 | Analog Audio Inputs |
1796 * | SI473X_DIGITAL_AUDIO1 | 0b00001011 | Digital audio output (DCLK, LOUT/DFS, ROUT/DIO) |
1797 * | SI473X_DIGITAL_AUDIO2 | 0b10110000 | Digital audio outputs (DCLK, DFS, DIO) |
1798 * | SI473X_DIGITAL_AUDIO3 | 0b10110101 | Analog and digital audio outputs (LOUT/ROUT and DCLK, DFS,DIO) |
1799 *
1800 * @see setAM(), setFM(), setSSB().
1801 * @param audioMode One of the values options above
1802 */
1803 inline void setAudioMode(uint8_t audioMode)
1804 {
1805 currentAudioMode = audioMode;
1806 };
1807
1808 /**
1809 * @ingroup group13 Audio Noise Blank Delay
1810 * @brief Sets the delay before applying impulse blanking
1811 * @details Delay in micro-seconds before applying impulse blanking to the original samples. Default value is 172.
1812 *
1813 * @param value Delay in micro-seconds
1814 */
1815 inline void setAmDelayNB(uint16_t value) {
1816 sendProperty(AM_NB_DELAY, value);
1817 }
1818
1819 void digitalOutputFormat(uint8_t OSIZE, uint8_t OMONO, uint8_t OMODE, uint8_t OFALL);
1820 void digitalOutputSampleRate(uint16_t DOSR);
1821
1822 void setAudioMute(bool off); // if true mute the audio; else unmute
1823
1824 void setAM();
1825 void setFM();
1826 void setAM(uint16_t fromFreq, uint16_t toFreq, uint16_t intialFreq, uint16_t step);
1827 void setFM(uint16_t fromFreq, uint16_t toFreq, uint16_t initialFreq, uint16_t step);
1828
1829 /**
1830 * @ingroup group08
1831 * @brief Sets the FM Receive de-emphasis to 50 or 75 μs.
1832 * @details valid parameters are 1 = 50 μs. Usedin Europe, Australia, Japan; 2 = 75 μs. Used in USA (default)
1833 *
1834 * @param parameter 1 or 2 (default 1 - USA)
1835 */
1836 inline void setFMDeEmphasis(uint8_t parameter)
1837 {
1838 sendProperty(FM_DEEMPHASIS, parameter);
1839 };
1840
1841 /**
1842 * @ingroup group08
1843 * @brief Sets the Fm Soft Mute Max Attenuation
1844 *
1845 * @details This function can be useful to disable Soft Mute on FM mode. The value 0 disable soft mute.
1846 * @details Specified in units of dB. Default maximum attenuation is 8 dB. It works for AM and SSB.
1847 *
1848 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 97.
1849 *
1850 * @param smattn Maximum attenuation to apply when in soft mute
1851 */
1852 inline void setFmSoftMuteMaxAttenuation(uint8_t smattn = 0)
1853 {
1854 sendProperty(FM_SOFT_MUTE_MAX_ATTENUATION, smattn);
1855 };
1856
1857 /**
1858 * @brief Set the Fm Noise Blank Threshold
1859 * @details Sets the threshold for detecting impulses in dB above the noise floor. The CTS bit (and optional interrupt) is set when it is safe to send the next command.
1860 * @param parameter (from 0 to 90. default is 10)
1861 */
1862 inline void setFmNoiseBlankThreshold(uint16_t parameter)
1863 {
1864 sendProperty(FM_NB_DETECT_THRESHOLD, parameter);
1865 };
1866
1867 /**
1868 * @brief Set the Fm Noise Blank
1869 * @details Sets Noise blanking rate in 100 Hz units
1870 * @details Sets the Interval in micro-seconds that original samples are replaced by sample-hold clean samples.
1871 * @details Sets the bandwidth of the noise floor estimator.
1872 *
1873 * @details ATTENTION: It works on SI474X. It may not work on SI473X devices.
1874 *
1875 * @param nb_rate Noise blanking rate in 100 Hz units. Default value is 64.
1876 * @param nb_interval Interval in micro-seconds that original samples are replaced by interpolated clean samples. Default value is 55 μs.
1877 * @param nb_irr_filter Sets the bandwidth of the noise floor estimator. Default value is 300.
1878 */
1879 inline void setFmNoiseBlank(uint16_t nb_rate = 64, uint16_t nb_interval = 55, uint16_t nb_irr_filter = 300)
1880 {
1881 sendProperty(FM_NB_RATE, nb_rate);
1882 sendProperty(FM_NB_INTERVAL, nb_interval);
1883 sendProperty(FM_NB_IIR_FILTER, nb_irr_filter);
1884 }
1885
1886 /**
1887 * @brief Set the Fm Noise Blank Interval
1888 * @details Interval in micro-seconds that original samples are replaced by interpolated clean samples.
1889 * @param parameter ( from 8 to 48. default value is 24)
1890 */
1891 inline void setFmNoiseBlankInterval(uint16_t parameter)
1892 {
1893 sendProperty(FM_NB_INTERVAL, parameter);
1894 };
1895
1896 /**
1897 * @brief Set the Fm Noise Blank Rate
1898 * @details Noise blanking rate in 100 Hz units.
1899 *
1900 * @param parameter ( from 1 to 64. default value is 64)
1901 */
1902 inline void setFmNoiseBlankRate(uint16_t parameter)
1903 {
1904 sendProperty(FM_NB_RATE, parameter);
1905 };
1906
1907 /**
1908 * @brief Set the Fm Noise Blank Delay
1909 * @details Delay in micro-seconds before applying impulse blanking to the original samples.
1910 * @param parameter ( from 125 to 219. default value is 170)
1911 */
1912 inline void setFmNoiseBlankDelay(uint16_t parameter)
1913 {
1914 sendProperty(FM_NB_DELAY, parameter);
1915 };
1916
1917 /**
1918 * @brief Set the FmNoiseBlank IIR Filter
1919 * @details Sets the bandwidth of the noise floor estimator.
1920 * @param parameter (from 300 to 1600. default value is 300)
1921 */
1922 inline void setFmNoiseBlank_IIR_Filter(uint16_t parameter)
1923 {
1924 sendProperty(FM_NB_IIR_FILTER, parameter);
1925 }
1926
1927 /**
1928 * @ingroup group08
1929 * @brief Sets the AM Receive de-emphasis to 50 or disable.
1930 * @details valid parameters are 1 = 50 μs. Usedin urope, Australia, Japan; 2 = 75 μs. Used in USA (default)
1931 *
1932 * @param parameter 1 = enable or 0 = disable
1933 */
1934 inline void setAMDeEmphasis(uint8_t parameter)
1935 {
1936 sendProperty(AM_DEEMPHASIS, parameter);
1937 };
1938
1939 /**
1940 * @ingroup group08
1941 * @brief Sets the AM attenuation slope during soft mute
1942 * @details Configures attenuation slope during soft mute in dB attenuation per dB SNR below the soft mute SNR threshold.
1943 * @details Soft mute attenuation is the minimum of SMSLOPEx(SMTHR–SNR) and SMATTN.
1944 * @details The default slope is 1 dB/dB for AMRX component 5.0 or later and 2 dB/dB for AMRX component 3.0 or earlier.
1945 *
1946 * @see setAmSoftMuteMaxAttenuation
1947 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0);
1948 * @param parameter the valid values are 1–5 (default 1).
1949 */
1950 inline void setAMSoftMuteSlop(uint8_t parameter)
1951 {
1952 sendProperty(AM_SOFT_MUTE_SLOPE, parameter);
1953 };
1954
1955
1956 /**
1957 * @ingroup group08
1958 * @brief Sets the attack and decay rates when entering or leaving soft mute.
1959 * @details The value specified is multiplied by 4.35 dB/s to come up with the actual attack rate
1960 * @details The default rate is 278 dB/s.
1961 * @see setAmSoftMuteMaxAttenuation
1962 * @see Si47XX PRORAMMING GUIDE; AN332 (REV 1.0);
1963 * @param parameter The valid values are 1-255 ( Default is ~64 - [64 x 4.35 = 278] )
1964 */
1965 inline void setAMSoftMuteRate(uint8_t parameter)
1966 {
1967 sendProperty(AM_SOFT_MUTE_RATE, parameter);
1968 };
1969
1970
1971 /**
1972 * @ingroup group08
1973 * @brief Sets the SNR threshold to engage soft mute
1974 * @details Whenever the SNR for a tuned frequency drops below this threshold the AM reception will go in soft mute,
1975 * @details provided soft mute max attenuation property is non-zero. The default value is 8dB
1976 * @see setAmSoftMuteMxAttenuation
1977 * @see Si47XX PROAMMING GUIDE; AN332 (REV 1.0);
1978 * @param parameter 0-63 (default is 8)
1979 */
1980 inline void setAMSoftMuteSnrThreshold(uint8_t parameter)
1981 {
1982 sendProperty(AM_SOFT_MUTE_SNR_THRESHOLD, parameter);
1983 };
1984
1985 /**
1986 * @ingroup group08
1987 * @brief Sets the soft mute release rate.
1988 * @details Smaller values provide slower release and larger values provide faster release. The default is 8192 (approximately 8000 dB/s).
1989 * @see setAmSoftMuteMxAttenuation
1990 * @see Si47XX PROAMMING GUIDE; AN332 (REV 1.0);
1991 * @param parameter 1–32767
1992 */
1993 inline void setAMSoftMuteReleaseRate(uint8_t parameter)
1994 {
1995 sendProperty(AM_SOFT_MUTE_RELEASE_RATE, parameter);
1996 };
1997
1998 /**
1999 * @ingroup group08
2000 * @brief Sets the soft mute attack rate.
2001 * @details Smaller values provide slower attack and larger values provide faster attack.
2002 * @see setAmSoftMuteMxAttenuation
2003 * @see Si47XX PROAMMING GUIDE; AN332 (REV 1.0);
2004 * @param parameter 1–32767 (The default is 8192 (approximately 8000 dB/s)
2005 */
2006 inline void setAMSoftMuteAttackRate(uint16_t parameter)
2007 {
2008 sendProperty(AM_SOFT_MUTE_ATTACK_RATE, parameter);
2009 };
2010
2011 /**
2012 * @ingroup group08
2013 * @brief Sets the AGC attack rate.
2014 * @details Large values provide slower attack, and smaller values provide faster attack..
2015 * @see setAmAgcAttackRate
2016 * @see Si47XX PROAMMING GUIDE; AN332 (REV 1.2); page 167
2017 * @param parameter Range: 4–248 (The default is 0x04)
2018 */
2019 inline void setAmAgcAttackRate(uint16_t parameter)
2020 {
2021 sendProperty(AM_AGC_ATTACK_RATE, parameter);
2022 };
2023
2024 /**
2025 * @ingroup group08
2026 * @brief Sets the AGC release rate.
2027 * @details Larger values provide slower release, and smaller values provide faster release.
2028 * @see setAmAgcReleaseRate
2029 * @see Si47XX PROAMMING GUIDE; AN332 (REV 1.2); page 168
2030 * @param parameter Range: 4–248 (The default is 0x8C)
2031 */
2032 inline void setAmAgcReleaseRate(uint16_t parameter)
2033 {
2034 sendProperty(AM_AGC_RELEASE_RATE, parameter);
2035 };
2036
2037 /**
2038 * @ingroup group17
2039 * @brief Sets the AGC attack rate on SSB mode.
2040 * @details Large values provide slower attack, and smaller values provide faster attack..
2041 * @see setSsbAgcAttackRate
2042 * @see AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; page 29
2043 * @param parameter Range: 4–248 (The default is 0x04)
2044 */
2045 inline void setSsbAgcAttackRate(uint16_t parameter)
2046 {
2047 sendProperty(SSB_RF_AGC_ATTACK_RATE, parameter);
2048 };
2049
2050 /**
2051 * @ingroup group17
2052 * @brief Sets the AGC Release rate on SSB mode.
2053 * @details Larger values provide slower release, and smaller values provide faster release.
2054 * @see setSsbAgcAttackRate
2055 * @see AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; page 29
2056 * @param parameter Range: 4–248 (The default is 0x18)
2057 */
2058 inline void setSsbAgcReleaseRate(uint16_t parameter)
2059 {
2060 sendProperty(SSB_RF_AGC_RELEASE_RATE, parameter);
2061 };
2062
2063 /**
2064 * @ingroup group08
2065 * @brief Adjusts the AM AGC for external front-end attenuator and external front-end cascode LNA.
2066 * @details This property contains two fields: MIN_GAIN_INDEX and ATTN_BACKUP.
2067 * @details MIN_GAIN_INDEX impacts sensitivity and U/D performance. Lower values improve sensitivity, but degrade
2068 * @details far away blocker U/D performance.
2069 * @details Higher values degrade sensitivity, but improve U/D. With MIN_GAIN_INDEX=19 and Si4743 EVB reference
2070 * @details design, the Si474x provides sensitivity of 28dBuV typical and U/D exceeding 55dB on far away blockers.
2071 * @details With MIN_GAIN_INDEX=24, the Si474x provides sensitivity of 34dBuV typical and U/D approaching 70dB on
2072 * @details far away blockers.
2073 * @see Si47XX PROAMMING GUIDE; AN332 (REV 1.0); page 168
2074 * @param MIN_GAIN_INDEX Values below 19 have minimal sensitivity improvement; Higher values degrade sensitivity, but improve U/D.
2075 * @param ATTN_BACKUP ???
2076 */
2077 inline void setAMFrontEndAgcControl(uint8_t MIN_GAIN_INDEX, uint8_t ATTN_BACKUP)
2078 {
2079 si47x_frontend_agc_control param;
2080
2081 param.field.MIN_GAIN_INDEX = MIN_GAIN_INDEX;
2082 param.field.ATTN_BACKUP = ATTN_BACKUP;
2083
2084 sendProperty(AM_FRONTEND_AGC_CONTROL, param.word);
2085 };
2086
2087 /**
2088 * @brief Set the Am Noise Blank
2089 *
2090 * @details Sets Noise blanking rate in 100 Hz units
2091 * @details Sets the Interval in micro-seconds that original samples are replaced by sample-hold clean samples.
2092 * @details Sets the bandwidth of the noise floor estimator.
2093 *
2094 * @details ATTENTION: It works on SI474X. It may not work on SI473X devices.
2095 *
2096 * @param nb_rate Noise blanking rate in 100 Hz units. Default value is 64.
2097 * @param nb_interval Interval in micro-seconds that original samples are replaced by interpolated clean samples. Default value is 55 μs.
2098 * @param nb_irr_filter Sets the bandwidth of the noise floor estimator. Default value is 300.
2099 *
2100 */
2101 inline void setAmNoiseBlank(uint16_t nb_rate = 64, uint16_t nb_interval = 55, uint16_t nb_irr_filter = 300)
2102 {
2103 sendProperty(AM_NB_RATE, nb_rate);
2104 sendProperty(AM_NB_INTERVAL, nb_interval);
2105 sendProperty(AM_NB_IIR_FILTER, nb_irr_filter);
2106 }
2107
2108 /* @ingroup group08 Check FM mode status
2109 * @brief Returns true if the current function is FM (FM_TUNE_FREQ).
2110 *
2111 * @return true if the current function is FM (FM_TUNE_FREQ).
2112 */
2113 inline bool isCurrentTuneFM()
2114 {
2115 return (currentTune == FM_TUNE_FREQ);
2116 }
2117
2118 /**
2119 * @ingroup group08 Check AM mode status
2120 *
2121 * @brief Returns true if the current function is AM (AM_TUNE_FREQ).
2122 *
2123 * @return true if the current function is AM (AM_TUNE_FREQ).
2124 */
2125 inline bool isCurrentTuneAM()
2126 {
2127 return (currentTune == AM_TUNE_FREQ);
2128 }
2129
2130 /**
2131 * @ingroup group08 Check SSB mode status
2132 *
2133 * @brief Returns true if the current function is SSB (SSB_TUNE_FREQ).
2134 *
2135 * @return true if the current function is SSB (SSB_TUNE_FREQ).
2136 */
2137 inline bool isCurrentTuneSSB()
2138 {
2139 return (currentTune == SSB_TUNE_FREQ);
2140 }
2141
2142 void setBandwidth(uint8_t AMCHFLT, uint8_t AMPLFLT);
2143
2144 /**
2145 * @brief Sets the Bandwith on FM mode
2146 * @details Selects bandwidth of channel filter applied at the demodulation stage. Default is automatic which means the device automatically selects proper channel filter. <BR>
2147 * @details | Filter | Description |
2148 * @details | ------- | -------------|
2149 * @details | 0 | Automatically select proper channel filter (Default) |
2150 * @details | 1 | Force wide (110 kHz) channel filter |
2151 * @details | 2 | Force narrow (84 kHz) channel filter |
2152 * @details | 3 | Force narrower (60 kHz) channel filter |
2153 * @details | 4 | Force narrowest (40 kHz) channel filter |
2154 *
2155 * @param filter_value
2156 */
2157 inline void setFmBandwidth(uint8_t filter_value = 0)
2158 {
2159 sendProperty(FM_CHANNEL_FILTER, filter_value);
2160 }
2161
2162 /**
2163 * @ingroup group08 Tune Frequency
2164 * @brief Returns the FAST tuning status
2165 *
2166 * @retrn uint8_t
2167 */
2169 return currentFrequencyParams.arg.FAST;
2170 };
2171
2172 /**
2173 * @ingroup group08 Tune Frequency
2174 * @brief Sets the FAST Tuning.
2175 * @details If set, excutes fast and invalidated tune. Theune status will not be accurate
2176 *
2177 * @param FAST
2178 */
2179 inline void setTuneFrequencyFast (uint8_t FAST) {
2180 currentFrequencyParams.arg.FAST = FAST;
2181 };
2182
2183 /**
2184 * @ingroup group08 Tune Frequency
2185 * @brief Returns the FREEZE status
2186 *
2187 * @return unt8_t
2188 */
2190 return currentFrequencyParams.arg.FREEZE;
2191 };
2192
2193 /**
2194 * @ingroup group08 Tune Frequency
2195 * @brief Sets Freeze Metrics During Alternate Frequency Jum.
2196 * @details Only on FM mode
2197 *
2198 * @param FREEZE
2199 */
2200 inline void setTuneFrequencyFreze(uint8_t FREEZE) {
2201 currentFrequencyParams.arg.FREEZE = FREEZE;
2202 };
2203
2204
2205 void setTuneFrequencyAntennaCapacitor(uint16_t capacitor);
2206
2207 void frequencyUp();
2208 void frequencyDown();
2209
2210 /**
2211 * @ingroup group08 Tune Frequency
2212 * @brief Set the FrequencyUp
2213 * @details Same frequencyUp
2214 * @see frequencyUp
2215 */
2216 inline void setFrequencyUp() { frequencyUp(); };
2217
2218 /**
2219 * @ingroup group08 Tune Frequency
2220 * @brief Set the Frequency Down
2221 * @details same frequencyDown
2222 * @see frequencyDown
2223 */
2225
2226 void getFirmware(void);
2227
2228 void seekStation(uint8_t SEEKUP, uint8_t WRAP); // See WRAP parameter
2229
2230 /**
2231 * @ingroup group08 Seek
2232 * @brief Sets the maximum time in milliseconds for seeking. The default value is 8000ms (8s).
2233 * @details Depending on the bandwidth, your reception conditions or step configuration, the seek process can take a long time.
2234 * @details This function sets a time limit for seeking process and back the control to the system if the time runs out.
2235 *
2236 * @addindex Seek
2237 *
2238 * @param time_in_ms time in milliseconds.
2239 */
2240 inline void setMaxSeekTime(long time_in_ms)
2241 {
2242 this->maxSeekTime = time_in_ms;
2243 };
2244
2245 /**
2246 * @ingroup group08 Seek
2247 *
2248 * @brief Search for the next station
2249 * @details Seek a station up. Stop when a station is found or the frequency has reached the upper limit
2250 * @see seekStation, seekStationProgress, setSeekAmLimits setSeekFmLimits
2251 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 124, 137, 139, 278
2252 */
2253 inline void seekStationUp()
2254 {
2255 seekStationProgress(NULL, SEEK_UP);
2256 };
2257
2258 /**
2259 * @ingroup group08 Seek
2260 *
2261 * @brief Search the previous station
2262 * @details Seek a station Down. Stop when a station is found or the frequency has reached the lower limit
2263 * @see seekStation, seekStationProgress, setSeekAmLimits, setSeekFmLimits
2264 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 124, 137, 139, 278
2265 */
2266 inline void seekStationDown()
2267 {
2268 seekStationProgress(NULL, SEEK_DOWN);
2269 };
2270
2271 void seekNextStation();
2272 void seekPreviousStation();
2273
2274 void seekStationProgress(void (*showFunc)(uint16_t f), uint8_t up_down);
2275 void seekStationProgress(void (*showFunc)(uint16_t f), bool (*stopSeking)(), uint8_t up_down);
2276
2277 // AM Seek property configurations
2278 void setSeekAmLimits(uint16_t bottom, uint16_t top);
2279 void setSeekAmSpacing(uint16_t spacing);
2280
2281 /**
2282 * @ingroup group08 Seek
2283 * @brief Set the Seek Am Srn Threshold object
2284 * @deprecated Use setSeekAmSNRThreshold instead.
2285 * @see setSeekAmSNRThreshold
2286 * @param value
2287 */
2288 void inline setSeekAmSrnThreshold(uint16_t value) { sendProperty(AM_SEEK_SNR_THRESHOLD, value); }; // Wrong name! Will be removed later
2289
2290 /**
2291 * @ingroup group08 Seek
2292 *
2293 * @brief Sets the SNR threshold for a valid AM Seek/Tune.
2294 *
2295 * @details If the value is zero then SNR threshold is not considered when doing a seek. Default value is 5 dB.
2296 * @see Si47XX PROGRAMMING GUIDE; (REV 1.0); page 127
2297 */
2298 void inline setSeekAmSNRThreshold(uint16_t value) { sendProperty(AM_SEEK_SNR_THRESHOLD, value); }; // Fixing the function name
2299
2300 void setSeekAmRssiThreshold(uint16_t value);
2301
2302 // FM Seek property configurations
2303 void setSeekFmLimits(uint16_t bottom, uint16_t top);
2304 void setSeekFmSpacing(uint16_t spacing);
2305
2306 /**
2307 * @ingroup group08 Seek
2308 * @brief Set the Seek Fm Srn Threshold object
2309 * @deprecated Use setSeekFmSNRThreshold instead.
2310 * @see setSeekFmSNRThreshold
2311 * @param value
2312 */
2313 void inline setSeekFmSrnThreshold(uint16_t value) { sendProperty(FM_SEEK_TUNE_SNR_THRESHOLD, value); }; // Wrong name. Will be removed later
2314
2315 /**
2316 * @ingroup group08 Seek
2317 *
2318 * @brief Sets the SNR threshold for a valid FM Seek/Tune.
2319 *
2320 * @details SNR Threshold which determines if a valid channel has been found during Seek/Tune. Specified in units of dB in 1 dB steps (0–127). Default is 3 dB
2321 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 102
2322 *
2323 * @param value between 0 and 127.
2324 */
2325 void inline setSeekFmSNRThreshold(uint16_t value) { sendProperty(FM_SEEK_TUNE_SNR_THRESHOLD, value); }; // Fixing the function name
2326
2327 void setSeekFmRssiThreshold(uint16_t value);
2328
2329 void setFmBlendStereoThreshold(uint8_t parameter);
2330 void setFmBlendMonoThreshold(uint8_t parameter);
2331 void setFmBlendRssiStereoThreshold(uint8_t parameter);
2332 void setFmBLendRssiMonoThreshold(uint8_t parameter);
2333 void setFmBlendSnrStereoThreshold(uint8_t parameter);
2334 void setFmBLendSnrMonoThreshold(uint8_t parameter);
2335 void setFmBlendMultiPathStereoThreshold(uint8_t parameter);
2336 void setFmBlendMultiPathMonoThreshold(uint8_t parameter);
2337 void setFmStereoOn();
2338 void setFmStereoOff();
2339
2340 void RdsInit();
2341 void setRdsIntSource(uint8_t RDSRECV, uint8_t RDSSYNCLOST, uint8_t RDSSYNCFOUND, uint8_t RDSNEWBLOCKA, uint8_t RDSNEWBLOCKB);
2342 void getRdsStatus(uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY);
2343
2344 /**
2345 * @ingroup group16 RDS
2346 * @brief Get the Rds Received FIFO
2347 * @details if FIFO is 1, it means the minimum number of groups was filled
2348 * @return true if minimum number of groups was filled.
2349 */
2350 inline bool getRdsReceived()
2351 {
2352 return currentRdsStatus.resp.RDSRECV;
2353 };
2354
2355 /**
2356 * @ingroup group16 RDS
2357 * @brief Get the Rds Sync Lost object
2358 * @details returns true (1) if Lost RDS synchronization is detected.
2359 * @return true if Lost RDS synchronization detected.
2360 */
2361 inline bool getRdsSyncLost()
2362 {
2363 return currentRdsStatus.resp.RDSSYNCLOST;
2364 };
2365
2366 /**
2367 * @ingroup group16 RDS
2368 * @brief Get the Rds Sync Found
2369 * @details return true if found RDS synchronization
2370 * @return true if found RDS synchronization
2371 */
2372 inline bool getRdsSyncFound()
2373 {
2374 return currentRdsStatus.resp.RDSSYNCFOUND;
2375 };
2376
2377 /**
2378 * @ingroup group16 RDS
2379 * @brief Get the Rds New Block A
2380 *
2381 * @details Returns true if valid Block A data has been received.
2382 * @return true or false
2383 */
2384 inline bool getRdsNewBlockA()
2385 {
2386 return currentRdsStatus.resp.RDSNEWBLOCKA;
2387 };
2388
2389 /**
2390 * @ingroup group16 RDS
2391 * @brief Get the Rds New Block B
2392 * @details Returns true if valid Block B data has been received.
2393 * @return true or false
2394 */
2395 inline bool getRdsNewBlockB()
2396 {
2397 return currentRdsStatus.resp.RDSNEWBLOCKB;
2398 };
2399
2400 /**
2401 * @ingroup group16 RDS
2402 * @brief Get the Rds Sync
2403 * @details Returns true if RDS currently synchronized.
2404 * @return true or false
2405 */
2406 inline bool getRdsSync()
2407 {
2408 return currentRdsStatus.resp.RDSSYNC;
2409 };
2410
2411 /**
2412 * @ingroup group16 RDS
2413 * @brief Get the Group Lost
2414 * @details Returns true if one or more RDS groups discarded due to FIFO overrun.
2415 * @return true or false
2416 */
2417 inline bool getGroupLost()
2418 {
2419 return currentRdsStatus.resp.GRPLOST;
2420 };
2421
2422 /**
2423 * @ingroup group16 RDS
2424 * @brief Get the Num Rds Fifo Used
2425 * @details Return the number of RDS FIFO used
2426 * @return uint8_t Total RDS FIFO used
2427 */
2429 {
2430 return currentRdsStatus.resp.RDSFIFOUSED;
2431 };
2432
2433 /**
2434 * @ingroup group16 RDS
2435 * @brief Sets the minimum number of RDS groups stored in the RDS FIFO before RDSRECV is set.
2436 * @details Return the number of RDS FIFO used
2437 * @param value from 0 to 25. Default value is 0.
2438 */
2439 inline void setFifoCount(uint16_t value)
2440 {
2441 sendProperty(FM_RDS_INT_FIFO_COUNT, value);
2442 };
2443
2444 /**
2445 * @ingroup group16 RDS
2446 * @brief Check if 0xD or 0xA special characters were received for group A
2447 * @see resetEndIndicatorGroupA
2448 * @return true or false
2449 */
2451 return rdsEndGroupA;
2452 }
2453
2454 /**
2455 * @ingroup group16 RDS
2456 * @brief Resets 0xD or 0xA special characters condition (makes it false)
2457 * @see getEndIndicatorGroupA
2458 */
2460 rdsEndGroupA = false;
2461 }
2462
2463 /**
2464 * @ingroup group16 RDS
2465 * @brief Check if 0xD or 0xA special characters were received for group B
2466 * @see resetEndIndicatorGroupB
2467 * @return true or false
2468 */
2470 {
2471 return rdsEndGroupB;
2472 }
2473
2474 /**
2475 * @ingroup group16 RDS
2476 * @brief Resets 0xD or 0xA special characters condition (makes it false)
2477 * @see getEndIndicatorGroupB
2478 */
2480 {
2481 rdsEndGroupB = false;
2482 }
2483
2484 /**
2485 * @ingroup group16 RDS status
2486 *
2487 * @brief Gets RDS Status.
2488 *
2489 * @details Same result of calling getRdsStatus(0,0,0).
2490 * @details Please, call getRdsStatus(uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY) instead getRdsStatus()
2491 * if you want other behaviour.
2492 *
2493 * @see SI4735::getRdsStatus(uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY)
2494 */
2495 inline void getRdsStatus()
2496 {
2497 getRdsStatus(0, 0, 0);
2498 }
2499
2500 /**
2501 * @ingroup group16 RDS status
2502 * @brief Empty FIFO
2503 * @details Clear RDS Receive FIFO.
2504 * @see getRdsStatus
2505 */
2506 inline void rdsClearFifo()
2507 {
2508 getRdsStatus(0, 1, 0);
2509 }
2510
2511 /**
2512 * @ingroup group16 RDS status
2513 * @brief Clears RDSINT.
2514 * @details INTACK Interrupt Acknowledge; 0 = RDSINT status preserved. 1 = Clears RDSINT.
2515 * @see getRdsStatus
2516 */
2517 inline void rdsClearInterrupt()
2518 {
2519 getRdsStatus(1, 0, 0);
2520 }
2521
2522 void setRdsConfig(uint8_t RDSEN, uint8_t BLETHA, uint8_t BLETHB, uint8_t BLETHC, uint8_t BLETHD);
2523 uint16_t getRdsPI(void);
2525 uint8_t getRdsFlagAB(void);
2529
2530 char *getRdsText(void);
2531 char *getRdsText0A(void); // Gets the Station name
2532 char *getRdsText2A(void); // Gets the Radio Text
2533 char *getRdsText2B(void);
2534
2535 void mjdConverter(uint32_t mjd, uint32_t *year, uint32_t *month, uint32_t *day);
2536 char *getRdsTime(void);
2537 char *getRdsDateTime(void);
2538 bool getRdsDateTime(uint16_t *year, uint16_t *month, uint16_t *day, uint16_t *hour, uint16_t * minute);
2539
2540 void getNext2Block(char *);
2541 void getNext4Block(char *);
2542
2543 void setSSBBfo(int offset);
2544 void setSSBConfig(uint8_t AUDIOBW, uint8_t SBCUTFLT, uint8_t AVC_DIVIDER, uint8_t AVCEN, uint8_t SMUTESEL, uint8_t DSP_AFCDIS);
2545 void setSSB(uint16_t fromFreq, uint16_t toFreq, uint16_t intialFreq, uint16_t step, uint8_t usblsb);
2546 void setSSB(uint8_t usblsb);
2547 void setSSBAudioBandwidth(uint8_t AUDIOBW);
2548 void setSSBAutomaticVolumeControl(uint8_t AVCEN);
2549 void setSSBSidebandCutoffFilter(uint8_t SBCUTFLT); // Fixing the function name
2550
2551 /**
2552 * @ingroup group17 Patch and SSB support
2553 * @deprecated Use setSSBSidebandCutoffFilter instead.
2554 * @see setSSBSidebandCutoffFilter
2555 * @param SBCUTFLT
2556 */
2557 void inline setSBBSidebandCutoffFilter(uint8_t SBCUTFLT) { setSSBSidebandCutoffFilter(SBCUTFLT); }; // Wrong name! will be removed later.
2558
2559 void setSSBAvcDivider(uint8_t AVC_DIVIDER);
2560 void setSSBDspAfc(uint8_t DSP_AFCDIS);
2561 void setSSBSoftMute(uint8_t SMUTESEL);
2562
2563 void setNBFM();
2564 void setNBFM(uint16_t fromFreq, uint16_t toFreq, uint16_t initialFreq, uint16_t step);
2565 void patchPowerUpNBFM();
2566 void loadPatchNBFM(const uint8_t *patch_content, const uint16_t patch_content_size);
2567 void setFrequencyNBFM(uint16_t freq);
2568
2569 si47x_firmware_query_library queryLibraryId();
2570 void patchPowerUp();
2571 bool downloadPatch(const uint8_t *ssb_patch_content, const uint16_t ssb_patch_content_size);
2572 bool downloadCompressedPatch(const uint8_t *ssb_patch_content, const uint16_t ssb_patch_content_size, const uint16_t *cmd_0x15, const int16_t cmd_0x15_size);
2573 void loadPatch(const uint8_t *ssb_patch_content, const uint16_t ssb_patch_content_size, uint8_t ssb_audiobw = 1);
2574 si4735_eeprom_patch_header downloadPatchFromEeprom(int eeprom_i2c_address);
2575 void ssbPowerUp();
2576
2577 /**
2578 * @ingroup group06 Si47XX device Power Up
2579 * @brief Set the Max Delay Power Up
2580 * @details Sets the delay needed in ms after a powerup command (default is 10ms).
2581 * @details Some crystal oscillator might need more time to become stable (500 ms is the recommended).
2582 * @details Low values make the load SSB patch faster. However, it can make the system unstable.
2583 *
2584 * @see MAX_DELAY_AFTER_POWERUP
2585 * @param ms delay in ms
2586 */
2587 inline void setMaxDelayPowerUp(uint16_t ms)
2588 {
2589 this->maxDelayAfterPouwerUp = ms;
2590 }
2591
2592 /**
2593 * @ingroup group08 Tune Frequency
2594 * @brief Set the Max Delay after Set Frequency
2595 *
2596 * @details After the set frequency command, the system need a time to get ready to the next set frequency (default value 30ms).
2597 * @details Why the waitToSend() does not work in this case? No idea for while!
2598 * @details A low value makes the getFrequency command inaccurate.
2599 *
2600 * @see MAX_DELAY_AFTER_POWERUP
2601 * @param ms
2602 */
2603 inline void setMaxDelaySetFrequency(uint16_t ms)
2604 {
2605 this->maxDelaySetFrequency = ms;
2606 }
2607
2608 /**
2609 * @ingroup group08 Tune Frequency step
2610 *
2611 * @brief Sets the current step value.
2612 *
2613 * @details This function does not check the limits of the current band. Please, don't take a step bigger than your legs.
2614 * @details Example:
2615 * @code
2616 * setFM(6400,10800,10390,10);
2617 * setFrequencyStep(100); // the step will be 1MHz (you are using FM mode)
2618 * .
2619 * .
2620 * .
2621 * setAM(7000,7600,7100,5);
2622 * setFrequencyStep(1); // the step will be 1kHz (you are usin AM or SSB mode)
2623 * @endcode
2624 *
2625 * @see setFM()
2626 * @see setAM()
2627 * @see setSSB()
2628 *
2629 * @param step if you are using FM, 10 means 100kHz. If you are using AM 10 means 10kHz
2630 * For AM, 1 (1kHz) to 1000 (1MHz) are valid values.
2631 * For FM 5 (50kHz), 10 (100kHz) and 100 (1MHz) are valid values.
2632 */
2633 inline void setFrequencyStep(uint16_t step)
2634 {
2635 this->currentStep = step;
2636 }
2637
2638 /**
2639 * @ingroup group08 Frequency
2640 *
2641 * @brief Gets the current frequency saved in memory.
2642 *
2643 * @details Unlike getFrequency, this method gets the current frequency recorded after the last setFrequency command.
2644 * @details This method avoids bus traffic and CI processing.
2645 * @details However, you can not get others status information like RSSI.
2646 *
2647 * @see getFrequency()
2648 */
2650 {
2651 return this->currentWorkFrequency;
2652 }
2653
2654 /**
2655 * @ingroup group08 Si47XX device Status
2656 *
2657 * @brief Gets the current status of the Si47XX (AM, FM or SSB)
2658 * @see Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 73 (FM) and 139 (AM)
2659 */
2660 inline void getStatus()
2661 {
2662 getStatus(0, 1);
2663 }
2664
2665 void setDeviceI2CAddress(uint8_t senPin);
2667 void setDeviceOtherI2CAddress(uint8_t i2cAddr);
2668
2669 /*******************************************************************************
2670 * The functions below modify the clock frequency for I2C communication.
2671 * 100kHz is usually the baseline.
2672 * Use one of these funcition if you have problem on you default configuration.
2673 *******************************************************************************/
2674
2675 /**
2676 * @ingroup group18 MCU I2C Speed
2677 * @brief Sets I2C bus to 10kHz
2678 */
2679 inline void setI2CLowSpeedMode(void)
2680 {
2681 Wire.setClock(10000);
2682 };
2683
2684 /**
2685 * @ingroup group18 MCU I2C Speed
2686 *
2687 * @brief Sets I2C bus to 100kHz
2688 */
2689 inline void setI2CStandardMode(void) { Wire.setClock(100000); };
2690
2691 /**
2692 * @ingroup group18 MCU I2C Speed
2693 *
2694 * @brief Sets I2C bus to 400kHz
2695 */
2696 inline void setI2CFastMode(void)
2697 {
2698 Wire.setClock(400000);
2699 };
2700
2701 /**
2702 * @ingroup group18 MCU I2C Speed
2703 *
2704 * @brief Sets the I2C bus to a given value.
2705 * ATTENTION: use this function with cation
2706 *
2707 * @param value in Hz. For example: The values 500000 sets the bus to 500kHz.
2708 */
2709 inline void setI2CFastModeCustom(long value = 500000) { Wire.setClock(value); };
2710
2711 /**
2712 * @ingroup group18 MCU External Audio Mute
2713 *
2714 * @brief Sets the Audio Mute Mcu Pin
2715 * @details This function sets the mcu digital pin you want to use to control the external audio mute circuit.
2716 * @details Some users may be uncomfortable with the loud popping of the speaker during some transitions caused by some SI47XX commands.
2717 * @details This problem occurs during the transition from the power down to power up.
2718 * @details Every time the user changes the mode (FM to AM or AM to FM) the power down and power up commands are required by the Si47XX devices.
2719 * @details If you have a extra circuit in your receiver to mute the audio on amplifier input, you can configure a MCU pin to control it by using this function.
2720 *
2721 * @see setHardwareAudioMute
2722 * @param pin if 0 ou greater sets the MCU digital pin will be used to control de external circuit.
2723 */
2724 inline void setAudioMuteMcuPin(int8_t pin)
2725 {
2726 audioMuteMcuPin = pin;
2727 pinMode(audioMuteMcuPin, OUTPUT);
2728 };
2729
2730 /**
2731 * @ingroup group18 MCU External Audio Mute
2732 *
2733 * @brief Sets the Hardware Audio Mute
2734 * @details Turns the Hardware audio mute on or off
2735 *
2736 * @see setAudioMuteMcuPin
2737 *
2738 * @param on True or false
2739 */
2740 inline void setHardwareAudioMute(bool on)
2741 {
2742 digitalWrite(audioMuteMcuPin, on);
2743 delayMicroseconds(300);
2744 }
2745
2746 void convertToChar(uint16_t value, char *strValue, uint8_t len, uint8_t dot, uint8_t separator, bool remove_leading_zeros = true );
2747};
2748#endif // _SI4735_H
#define AM_DEEMPHASIS
Definition: SI4735.h:127
#define SSB_AGC_STATUS
Definition: SI4735.h:118
#define AM_AGC_STATUS
Definition: SI4735.h:108
#define MIN_DELAY_WAIT_SEND_LOOP
Definition: SI4735.h:205
#define SI473X_ADDR_SEN_HIGH
Definition: SI4735.h:33
#define GPO_IEN
Definition: SI4735.h:163
#define FM_SEEK_BAND_BOTTOM
Definition: SI4735.h:76
#define FM_TUNE_STATUS
Definition: SI4735.h:45
#define SSB_MODE
Definition: SI4735.h:165
#define SSB_BFO
Definition: SI4735.h:164
#define FM_SEEK_START
Definition: SI4735.h:44
#define AM_SEEK_BAND_TOP
Definition: SI4735.h:144
#define FM_BLEND_SNR_MONO_THRESHOLD
Definition: SI4735.h:69
#define AM_AGC_OVERRIDE
Definition: SI4735.h:109
#define AM_SOFT_MUTE_SLOPE
Definition: SI4735.h:138
#define AM_NB_DELAY
Definition: SI4735.h:155
#define AM_NB_INTERVAL
Definition: SI4735.h:152
#define AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN
Definition: SI4735.h:129
#define XOSCEN_CRYSTAL
Definition: SI4735.h:210
#define NBFM_TUNE_FREQ
Definition: SI4735.h:84
#define DEFAULT_CURRENT_AVC_AM_MAX_GAIN
Definition: SI4735.h:208
#define AM_CURRENT_MODE
Definition: SI4735.h:196
#define MAX_DELAY_AFTER_SET_FREQUENCY
Definition: SI4735.h:203
#define SSB_RF_AGC_ATTACK_RATE
Definition: SI4735.h:174
#define AM_SEEK_SNR_THRESHOLD
Definition: SI4735.h:146
#define AM_CHANNEL_FILTER
Definition: SI4735.h:128
#define FM_NB_DETECT_THRESHOLD
Definition: SI4735.h:51
#define SI473X_ADDR_SEN_LOW
Definition: SI4735.h:32
#define NBFM_CURRENT_MODE
Definition: SI4735.h:198
#define AM_RSQ_STATUS
Definition: SI4735.h:107
#define AM_SOFT_MUTE_MAX_ATTENUATION
Definition: SI4735.h:139
#define AM_SEEK_FREQ_SPACING
Definition: SI4735.h:145
#define SSB_RF_AGC_RELEASE_RATE
Definition: SI4735.h:175
#define AM_TUNE_FREQ
Definition: SI4735.h:104
#define AM_FRONTEND_AGC_CONTROL
Definition: SI4735.h:150
#define RX_HARD_MUTE
Definition: SI4735.h:158
#define NBFM_RSQ_STATUS
Definition: SI4735.h:86
#define NBFM_AGC_OVERRIDE
Definition: SI4735.h:88
#define SEEK_UP
Definition: SI4735.h:200
#define REFCLK_PRESCALE
Definition: SI4735.h:126
#define SSB_IF_AGC_RELEASE_RATE
Definition: SI4735.h:176
#define NBFM_TUNE_STATUS
Definition: SI4735.h:85
#define SEEK_DOWN
Definition: SI4735.h:201
#define FM_BLEND_MULTIPATH_MONO_THRESHOLD
Definition: SI4735.h:71
#define AM_AGC_RELEASE_RATE
Definition: SI4735.h:149
#define FM_AGC_OVERRIDE
Definition: SI4735.h:47
#define SSB_IF_AGC_ATTACK_RATE
Definition: SI4735.h:177
#define AM_NB_RATE
Definition: SI4735.h:153
#define FM_BLEND_STEREO_THRESHOLD
Definition: SI4735.h:64
#define FM_BLEND_MULTIPATH_STEREO_THRESHOLD
Definition: SI4735.h:70
#define FM_NB_IIR_FILTER
Definition: SI4735.h:54
#define FM_RDS_INT_SOURCE
Definition: SI4735.h:58
#define FM_SOFT_MUTE_MAX_ATTENUATION
Definition: SI4735.h:73
#define DIGITAL_OUTPUT_SAMPLE_RATE
Definition: SI4735.h:124
#define FM_BLEND_MONO_THRESHOLD
Definition: SI4735.h:65
#define FM_BLEND_RSSI_MONO_THRESHOLD
Definition: SI4735.h:67
#define MAX_DELAY_AFTER_POWERUP
Definition: SI4735.h:204
#define SET_PROPERTY
Definition: SI4735.h:38
#define FM_BLEND_SNR_STEREO_THRESHOLD
Definition: SI4735.h:68
#define FM_SEEK_TUNE_RSSI_THRESHOLD
Definition: SI4735.h:80
#define FM_RSQ_STATUS
Definition: SI4735.h:48
#define DIGITAL_OUTPUT_FORMAT
Definition: SI4735.h:123
#define XOSCEN_RCLK
Definition: SI4735.h:211
#define GET_REV
Definition: SI4735.h:36
#define FM_DEEMPHASIS
Definition: SI4735.h:63
#define FM_SEEK_TUNE_SNR_THRESHOLD
Definition: SI4735.h:79
#define FM_TUNE_FREQ
Definition: SI4735.h:43
#define AM_NB_IIR_FILTER
Definition: SI4735.h:154
#define POWER_DOWN
Definition: SI4735.h:37
#define AM_SEEK_RSSI_THRESHOLD
Definition: SI4735.h:147
#define AM_SOFT_MUTE_SNR_THRESHOLD
Definition: SI4735.h:140
#define FM_NB_INTERVAL
Definition: SI4735.h:52
#define GET_INT_STATUS
Definition: SI4735.h:40
#define SSB_TUNE_FREQ
Definition: SI4735.h:115
#define SSB_AGC_OVERRIDE
Definition: SI4735.h:119
#define AM_SOFT_MUTE_RATE
Definition: SI4735.h:137
#define AM_SOFT_MUTE_ATTACK_RATE
Definition: SI4735.h:142
#define FM_BLEND_RSSI_STEREO_THRESHOLD
Definition: SI4735.h:66
#define POWER_UP
Definition: SI4735.h:35
#define FM_RDS_STATUS
Definition: SI4735.h:49
#define GPIO_CTL
Definition: SI4735.h:110
#define FM_SEEK_FREQ_SPACING
Definition: SI4735.h:78
#define FM_AGC_STATUS
Definition: SI4735.h:46
#define NBFM_AGC_STATUS
Definition: SI4735.h:87
#define FM_NB_RATE
Definition: SI4735.h:53
#define FM_CURRENT_MODE
Definition: SI4735.h:195
#define MAX_SEEK_TIME
Definition: SI4735.h:206
#define GET_PROPERTY
Definition: SI4735.h:39
#define AM_SEEK_START
Definition: SI4735.h:105
#define SSB_CURRENT_MODE
Definition: SI4735.h:197
#define FM_NB_DELAY
Definition: SI4735.h:55
#define AM_SOFT_MUTE_RELEASE_RATE
Definition: SI4735.h:141
#define REFCLK_FREQ
Definition: SI4735.h:125
#define SSB_SOFT_MUTE_MAX_ATTENUATION
Definition: SI4735.h:172
#define AM_TUNE_STATUS
Definition: SI4735.h:106
#define AM_AGC_ATTACK_RATE
Definition: SI4735.h:148
#define FM_SEEK_BAND_TOP
Definition: SI4735.h:77
#define RX_VOLUME
Definition: SI4735.h:157
#define GPIO_SET
Definition: SI4735.h:111
#define AM_SEEK_BAND_BOTTOM
Definition: SI4735.h:143
#define FM_RDS_CONFIG
Definition: SI4735.h:60
#define FM_CHANNEL_FILTER
Definition: SI4735.h:72
#define SI473X_ANALOG_AUDIO
Definition: SI4735.h:189
#define FM_RDS_INT_FIFO_COUNT
Definition: SI4735.h:59
SI4735 Class.
Definition: SI4735.h:1054
uint8_t ctsIntEnable
Definition: SI4735.h:1090
uint8_t currentSsbStatus
Definition: SI4735.h:1111
bool rdsEndGroupB
Definition: SI4735.h:1066
void setFmNoiseBlankInterval(uint16_t parameter)
Set the Fm Noise Blank Interval.
Definition: SI4735.h:1891
char rds_buffer2A[65]
RDS Radio Text buffer - Program Information.
Definition: SI4735.h:1056
int rdsTextAdress0A
rds_buffer0A current position
Definition: SI4735.h:1063
si473x_powerup powerUp
Definition: SI4735.h:1106
uint8_t lastMode
Stores the last mode used.
Definition: SI4735.h:1086
int8_t audioMuteMcuPin
Definition: SI4735.h:1112
int rdsTextAdress2A
rds_buffer2A current position
Definition: SI4735.h:1061
uint8_t currentClockType
Stores the current clock type used (Crystal or REF CLOCK)
Definition: SI4735.h:1089
void setAmNoiseBlank(uint16_t nb_rate=64, uint16_t nb_interval=55, uint16_t nb_irr_filter=300)
Set the Am Noise Blank.
Definition: SI4735.h:2101
int16_t deviceAddress
Stores the current I2C bus address.
Definition: SI4735.h:1068
uint16_t refClock
Frequency of Reference Clock in Hz.
Definition: SI4735.h:1093
void setFmNoiseBlankThreshold(uint16_t parameter)
Set the Fm Noise Blank Threshold.
Definition: SI4735.h:1862
si47x_rds_status currentRdsStatus
current RDS status
Definition: SI4735.h:1102
si47x_frequency currentFrequency
data structure to get current frequency
Definition: SI4735.h:1097
uint16_t currentMinimumFrequency
minimum frequency of the current band
Definition: SI4735.h:1080
uint8_t currentAudioMode
Current audio mode used (ANALOG or DIGITAL or both)
Definition: SI4735.h:1110
bool rdsEndGroupA
Definition: SI4735.h:1065
uint8_t refClockSourcePin
0 = RCLK pin is clock source; 1 = DCLK pin is clock source.
Definition: SI4735.h:1095
void setFmNoiseBlankRate(uint16_t parameter)
Set the Fm Noise Blank Rate.
Definition: SI4735.h:1902
uint16_t maxDelaySetFrequency
Stores the maximum delay after set frequency command (in ms).
Definition: SI4735.h:1071
uint8_t resetPin
pin used on Arduino Board to RESET the Si47XX device
Definition: SI4735.h:1076
uint8_t currentAvcAmMaxGain
Stores the current Automatic Volume Control Gain for AM.
Definition: SI4735.h:1088
si47x_ssb_mode currentSSBMode
indicates if USB or LSB
Definition: SI4735.h:1104
char rds_buffer2B[33]
RDS Radio Text buffer - Station Informaation.
Definition: SI4735.h:1057
si47x_response_status currentStatus
current device status
Definition: SI4735.h:1100
uint16_t maxDelayAfterPouwerUp
Stores the maximum delay you have to setup after a power up command (in ms).
Definition: SI4735.h:1072
SI4735()
Construct a new SI4735::SI4735.
Definition: SI4735.cpp:60
si47x_set_frequency currentFrequencyParams
Definition: SI4735.h:1098
void setFmNoiseBlankDelay(uint16_t parameter)
Set the Fm Noise Blank Delay.
Definition: SI4735.h:1912
void setFmNoiseBlank_IIR_Filter(uint16_t parameter)
Set the FmNoiseBlank IIR Filter.
Definition: SI4735.h:1922
uint16_t refClockPrescale
Prescaler for Reference Clock (divider).
Definition: SI4735.h:1094
uint16_t currentWorkFrequency
current frequency
Definition: SI4735.h:1082
si47x_rqs_status currentRqsStatus
current Radio SIgnal Quality status
Definition: SI4735.h:1099
uint8_t gpo2Enable
Definition: SI4735.h:1091
uint16_t currentMaximumFrequency
maximum frequency of the current band
Definition: SI4735.h:1081
uint8_t volume
Stores the current vlume setup (0-63).
Definition: SI4735.h:1108
uint8_t lastTextFlagAB
Definition: SI4735.h:1075
char rds_buffer0A[9]
RDS Basic tuning and switching information (Type 0 groups)
Definition: SI4735.h:1058
uint8_t currentTune
tell the current tune (FM, AM or SSB)
Definition: SI4735.h:1078
void setFmNoiseBlank(uint16_t nb_rate=64, uint16_t nb_interval=55, uint16_t nb_irr_filter=300)
Set the Fm Noise Blank.
Definition: SI4735.h:1879
si47x_firmware_information firmwareInfo
firmware information
Definition: SI4735.h:1101
void waitInterrupr(void)
unsigned long maxSeekTime
Stores the maximum time (ms) for a seeking process. Defines the maximum seeking time.
Definition: SI4735.h:1073
uint16_t currentStep
Stores the current step used to increment or decrement the frequency.
Definition: SI4735.h:1084
int rdsTextAdress2B
rds_buffer2B current position
Definition: SI4735.h:1062
si47x_agc_status currentAgcStatus
current AGC status
Definition: SI4735.h:1103
bool isCurrentTuneFM()
Definition: SI4735.h:2113
void setFmBandwidth(uint8_t filter_value=0)
Sets the Bandwith on FM mode.
Definition: SI4735.h:2157
char rds_time[25]
RDS date time received information.
Definition: SI4735.h:1059
uint16_t raw
Definition: SI4735.h:1001
uint8_t raw[8]
Definition: SI4735.h:609
uint8_t raw[3]
Definition: SI4735.h:907
uint8_t raw
Definition: SI4735.h:644
uint8_t raw[6]
Definition: SI4735.h:877
uint8_t raw[8]
Definition: SI4735.h:524
uint8_t raw[13]
Definition: SI4735.h:699
uint8_t ARG2
Definition: SI4735.h:387
uint8_t raw[5]
Definition: SI4735.h:350
uint8_t raw[2]
Definition: SI4735.h:929
uint16_t value
Definition: SI4735.h:561
uint8_t raw
Definition: SI4735.h:373
uint8_t raw
Definition: SI4735.h:412
uint8_t raw[32]
Definition: SI4735.h:1020
uint16_t DOSR
Definition: SI4735.h:1034
uint8_t raw[8]
Check it.
Definition: SI4735.h:454
uint8_t ARG3
Definition: SI4735.h:388
uint16_t raw
Definition: SI4735.h:297
uint8_t raw[9]
Definition: SI4735.h:488
uint16_t value
Definition: SI4735.h:327
uint8_t raw[2]
Definition: SI4735.h:956
uint16_t value
frequency (integer value)
Definition: SI4735.h:313
uint8_t raw[2]
Raw powerup parameters data. Same arg memory position. So, same content.
Definition: SI4735.h:248
uint8_t raw[2]
Definition: SI4735.h:723
uint8_t raw[2]
Definition: SI4735.h:978
uint8_t ANTCAPL
Definition: SI4735.h:390
uint8_t raw[2]
Definition: SI4735.h:753
uint8_t ANTCAPH
Definition: SI4735.h:389
uint8_t raw
Definition: SI4735.h:270
uint8_t raw
Definition: SI4735.h:544
uint16_t word
Definition: SI4735.h:624
void setGpioCtl(uint8_t GPO1OEN, uint8_t GPO2OEN, uint8_t GPO3OEN)
Enables output for GPO1, 2, and 3.
Definition: SI4735.cpp:119
void setGpio(uint8_t GPO1LEVEL, uint8_t GPO2LEVEL, uint8_t GPO3LEVEL)
Sets the output level (high or low) for GPO1, 2, and 3.
Definition: SI4735.cpp:158
void setDeviceOtherI2CAddress(uint8_t i2cAddr)
Sets the onther I2C Bus Address (for Si470X)
Definition: SI4735.cpp:283
void setGpioIen(uint8_t STCIEN, uint8_t RSQIEN, uint8_t ERRIEN, uint8_t CTSIEN, uint8_t STCREP, uint8_t RSQREP)
Configures the sources for the GPO2/INT interrupt pin.
Definition: SI4735.cpp:195
void setDeviceI2CAddress(uint8_t senPin)
Sets the I2C Bus Address.
Definition: SI4735.cpp:269
int16_t getDeviceI2CAddress(uint8_t resetPin)
I2C bus address setup.
Definition: SI4735.cpp:224
si47x_status getInterruptStatus()
Updates bits 6:0 of the status byte.
Definition: SI4735.cpp:83
uint8_t getFirmwarePATCHH()
Returns the Firmware P A T C H HIGH.
Definition: SI4735.h:1713
uint8_t getFirmwareFWMINOR()
Returns the Firmware F W M I N O R.
Definition: SI4735.h:1703
void waitToSend(void)
Wait for the si473x is ready (Clear to Send (CTS) status bit have to be 1).
Definition: SI4735.cpp:316
uint8_t getFirmwareCMPMINOR()
RESP6 - Returns the Component Major Revision (ASCII).
Definition: SI4735.h:1743
uint8_t getFirmwarePN()
Returns the Firmware Part Number.
Definition: SI4735.h:1683
uint8_t getFirmwareCMPMAJOR()
Get the Firmware C M P M A J O R object.
Definition: SI4735.h:1733
uint8_t getFirmwarePATCHL()
Returns the Firmware P A T C H LOW.
Definition: SI4735.h:1723
uint8_t getFirmwareFWMAJOR()
Returns the Firmware F W M A J O R.
Definition: SI4735.h:1693
uint8_t getFirmwareCHIPREV()
RESP8 - Returns the Chip Revision (ASCII)
Definition: SI4735.h:1753
void setMaxDelayPowerUp(uint16_t ms)
Set the Max Delay Power Up.
Definition: SI4735.h:2587
void reset(void)
Reset the SI473X
Definition: SI4735.cpp:297
void getFirmware(void)
Gets firmware information.
Definition: SI4735.cpp:476
void radioPowerUp(void)
Powerup the Si47XX.
Definition: SI4735.cpp:404
void analogPowerUp(void)
You have to call setPowerUp method before.
Definition: SI4735.cpp:439
void setRefClock(uint16_t refclk)
Sets the frequency of the REFCLK from the output of the prescaler.
Definition: SI4735.cpp:519
void setPowerUp(uint8_t CTSIEN, uint8_t GPO2OEN, uint8_t PATCH, uint8_t XOSCEN, uint8_t FUNC, uint8_t OPMODE)
Set the Power Up parameters for si473X.
Definition: SI4735.cpp:346
void setup(uint8_t resetPin, uint8_t defaultFunction)
Starts the Si473X device.
Definition: SI4735.cpp:614
void powerDown(void)
Moves the device from powerup to powerdown mode.
Definition: SI4735.cpp:454
void setRefClockPrescaler(uint16_t prescale, uint8_t rclk_sel=0)
Sets the number used by the prescaler to divide the external RCLK down to the internal REFCLK.
Definition: SI4735.cpp:548
void setup(uint8_t resetPin, uint8_t ctsIntEnable, uint8_t defaultFunction, uint8_t audioMode=SI473X_ANALOG_AUDIO, uint8_t clockType=XOSCEN_CRYSTAL, uint8_t gpo2Enable=0)
Starts the Si473X device.
Definition: SI4735.cpp:574
bool getCurrentRssiDetectLow()
Checks if RSSI detected is LOW.
Definition: SI4735.h:1516
uint8_t getStatusMULT()
Get the Status the M U L T.
Definition: SI4735.h:1309
bool getCurrentPilot()
Checks the current pilot.
Definition: SI4735.h:1610
bool getCurrentSnrDetectLow()
Checks if SNR detect is low.
Definition: SI4735.h:1538
bool getCurrentBlendDetectInterrupt()
Gets the Current Blend Detect Interrupt.
Definition: SI4735.h:1667
void setAMSoftMuteSlop(uint8_t parameter)
Sets the AM attenuation slope during soft mute.
Definition: SI4735.h:1950
bool getBandLimit()
Returns true if a seek hit the band limit.
Definition: SI4735.h:1258
void seekStationDown()
Search the previous station.
Definition: SI4735.h:2266
void setAGC(uint8_t AGCDIS, uint8_t AGCIDX)
Automatic Gain Control setup (alternative name for setAutomaticGainControl )
Definition: SI4735.h:1478
void setAutomaticGainControl(uint8_t AGCDIS, uint8_t AGCIDX)
Automatic Gain Control setup.
Definition: SI4735.cpp:1044
uint8_t getCurrentSignedFrequencyOffset()
Gets the Signed frequency offset (kHz).
Definition: SI4735.h:1634
bool getTuneCompleteTriggered()
Get the Tune Complete status.
Definition: SI4735.h:1215
void setFMDeEmphasis(uint8_t parameter)
Sets the FM Receive de-emphasis to 50 or 75 μs.
Definition: SI4735.h:1836
void seekStation(uint8_t SEEKUP, uint8_t WRAP)
Look for a station (Automatic tune)
Definition: SI4735.cpp:1172
void seekStationProgress(void(*showFunc)(uint16_t f), bool(*stopSeking)(), uint8_t up_down)
Seeks a station up or down.
Definition: SI4735.cpp:1322
void setAMSoftMuteReleaseRate(uint8_t parameter)
Sets the soft mute release rate.
Definition: SI4735.h:1993
void getStatus()
Gets the current status of the Si47XX (AM, FM or SSB)
Definition: SI4735.h:2660
void setAM(uint16_t fromFreq, uint16_t toFreq, uint16_t intialFreq, uint16_t step)
Sets the radio to AM (LW/MW/SW) function.
Definition: SI4735.cpp:815
void setAMFrontEndAgcControl(uint8_t MIN_GAIN_INDEX, uint8_t ATTN_BACKUP)
Adjusts the AM AGC for external front-end attenuator and external front-end cascode LNA.
Definition: SI4735.h:2077
bool isCurrentTuneAM()
Returns true if the current function is AM (AM_TUNE_FREQ).
Definition: SI4735.h:2125
void setAMSoftMuteRate(uint8_t parameter)
Sets the attack and decay rates when entering or leaving soft mute.
Definition: SI4735.h:1965
uint8_t getAgcGainIndex()
Gets the current AGC gain index.
Definition: SI4735.h:1454
void setSeekFmSrnThreshold(uint16_t value)
Set the Seek Fm Srn Threshold object.
Definition: SI4735.h:2313
uint8_t getCurrentRSSI()
Get the current receive signal strength (0–127 dBμV)
Definition: SI4735.h:1494
void setTuneFrequencyFast(uint8_t FAST)
Sets the FAST Tuning.
Definition: SI4735.h:2179
void getStatus(uint8_t, uint8_t)
Gets the current status of the Si4735 (AM or FM)
Definition: SI4735.cpp:951
bool getCurrentValidChannel()
Checks if the current channel is valid.
Definition: SI4735.h:1560
void setAvcAmMaxGain(uint8_t gain=90)
Sets the maximum gain for automatic volume control.
Definition: SI4735.cpp:1084
void setSeekFmSpacing(uint16_t spacing)
Selects frequency spacingfor FM seek. Default is 100 kHz (value 10) spacing. There are only 3 valid v...
Definition: SI4735.cpp:1402
void setFrequency(uint16_t)
Set the frequency to the corrent function of the Si4735 (FM, AM or SSB)
Definition: SI4735.cpp:683
void setAMDeEmphasis(uint8_t parameter)
Sets the AM Receive de-emphasis to 50 or disable.
Definition: SI4735.h:1934
void setAMSoftMuteSnrThreshold(uint8_t parameter)
Sets the SNR threshold to engage soft mute.
Definition: SI4735.h:1980
void setFM(uint16_t fromFreq, uint16_t toFreq, uint16_t initialFreq, uint16_t step)
Sets the radio to FM function.
Definition: SI4735.cpp:853
bool isCurrentTuneSSB()
Returns true if the current function is SSB (SSB_TUNE_FREQ).
Definition: SI4735.h:2137
bool getStatusError()
Get the Status Error.
Definition: SI4735.h:1226
void setTuneFrequencyFreze(uint8_t FREEZE)
Sets Freeze Metrics During Alternate Frequency Jum.
Definition: SI4735.h:2200
void setSeekAmLimits(uint16_t bottom, uint16_t top)
Sets the bottom frequency and top frequency of the AM band for seek. Default is 520 to 1710.
Definition: SI4735.cpp:1357
uint8_t getCurrentMultipath()
Gets the current Multipath.
Definition: SI4735.h:1623
void setSeekAmSpacing(uint16_t spacing)
Selects frequency spacingfor AM seek. Default is 10 kHz spacing.
Definition: SI4735.cpp:1388
void setAmAgcAttackRate(uint16_t parameter)
Sets the AGC attack rate.
Definition: SI4735.h:2019
void getCurrentReceivedSignalQuality(void)
Queries the status of the Received Signal Quality (RSQ) of the current channel (FM_RSQ_STATUS)
Definition: SI4735.cpp:1156
void setAM()
Sets the radio to AM function. It means: LW MW and SW.
Definition: SI4735.cpp:760
bool getCurrentSoftMuteIndicator()
Soft Mute Indicator.
Definition: SI4735.h:1584
void setFrequencyUp()
Set the FrequencyUp.
Definition: SI4735.h:2216
void setFrequencyStep(uint16_t step)
Sets the current step value.
Definition: SI4735.h:2633
uint8_t getTuneFrequecyFast()
Returns the FAST tuning status.
Definition: SI4735.h:2168
void setMaxDelaySetFrequency(uint16_t ms)
Set the Max Delay after Set Frequency.
Definition: SI4735.h:2603
uint16_t getFrequency(void)
Gets the current frequency of the Si4735 (AM or FM)
Definition: SI4735.cpp:929
void seekStationProgress(void(*showFunc)(uint16_t f), uint8_t up_down)
Seeks a station up or down.
Definition: SI4735.cpp:1267
void setSeekAmSrnThreshold(uint16_t value)
Set the Seek Am Srn Threshold object.
Definition: SI4735.h:2288
uint16_t getCurrentFrequency()
Gets the current frequency saved in memory.
Definition: SI4735.h:2649
bool getCurrentMultipathDetectHigh()
Gets the Current Multipath Detect High.
Definition: SI4735.h:1656
void setSeekAmSNRThreshold(uint16_t value)
Sets the SNR threshold for a valid AM Seek/Tune.
Definition: SI4735.h:2298
void setBandwidth(uint8_t AMCHFLT, uint8_t AMPLFLT)
Selects the bandwidth of the channel filter for AM reception.
Definition: SI4735.cpp:889
void setSeekFmSNRThreshold(uint16_t value)
Sets the SNR threshold for a valid FM Seek/Tune.
Definition: SI4735.h:2325
void frequencyDown()
Decrements the current frequency on current band/function by using the current step.
Definition: SI4735.cpp:738
uint8_t getTuneFrequecyFreeze()
Returns the FREEZE status.
Definition: SI4735.h:2189
void setSeekFmRssiThreshold(uint16_t value)
Sets the RSSI threshold for a valid FM Seek/Tune.
Definition: SI4735.cpp:1431
bool getRadioDataSystemInterrupt()
Get the Radio Data System (RDS) Interrupt status.
Definition: SI4735.h:1204
void setFrequencyDown()
Set the Frequency Down.
Definition: SI4735.h:2224
void setAMSoftMuteAttackRate(uint16_t parameter)
Sets the soft mute attack rate.
Definition: SI4735.h:2006
void getAutomaticGainControl()
Queries Automatic Gain Control STATUS.
Definition: SI4735.cpp:999
void setTuneFrequencyAntennaCapacitor(uint16_t capacitor)
Selects the tuning capacitor value.
Definition: SI4735.cpp:643
void seekStationUp()
Search for the next station.
Definition: SI4735.h:2253
void setAmAgcReleaseRate(uint16_t parameter)
Sets the AGC release rate.
Definition: SI4735.h:2032
bool getACFIndicator()
Returns true if the AFC rails (AFC Rail Indicator).
Definition: SI4735.h:1245
void seekNextStation()
Search for the next station.
Definition: SI4735.cpp:1215
void getCurrentReceivedSignalQuality(uint8_t INTACK)
Queries the status of the Received Signal Quality (RSQ) of the current channel.
Definition: SI4735.cpp:1105
uint8_t getStatusSNR()
Gets the SNR metric when tune is complete (dB)
Definition: SI4735.h:1296
void frequencyUp()
Increments the current frequency on current band/function by using the current step.
Definition: SI4735.cpp:721
void setFmSoftMuteMaxAttenuation(uint8_t smattn=0)
Sets the Fm Soft Mute Max Attenuation.
Definition: SI4735.h:1852
uint8_t getCurrentStereoBlend()
Gets the value of the amount of stereo blend in % (100 = full stereo, 0 = full mono).
Definition: SI4735.h:1597
void setFM()
Sets the radio to FM function.
Definition: SI4735.cpp:785
bool getSignalQualityInterrupt()
Get the Signal Quality Interrupt status.
Definition: SI4735.h:1193
bool getCurrentMultipathDetectLow()
Get Multipath Detect Low.
Definition: SI4735.h:1645
void seekPreviousStation()
Search the previous station.
Definition: SI4735.cpp:1230
uint8_t getCurrentSNR()
Gets the current SNR metric (0–127 dB).
Definition: SI4735.h:1505
bool getCurrentRssiDetectHigh()
Checks if RSSI detected is high.
Definition: SI4735.h:1527
void setSeekAmRssiThreshold(uint16_t value)
Sets the RSSI threshold for a valid AM Seek/Tune.
Definition: SI4735.cpp:1417
bool isAgcEnabled()
Checks if the AGC is enabled.
Definition: SI4735.h:1443
bool getCurrentSnrDetectHigh()
Checks if SNR detect is high.
Definition: SI4735.h:1549
void setMaxSeekTime(long time_in_ms)
Sets the maximum time in milliseconds for seeking. The default value is 8000ms (8s).
Definition: SI4735.h:2240
uint8_t getReceivedSignalStrengthIndicator()
Returns the value of Received Signal Strength Indicator (dBμV).
Definition: SI4735.h:1283
void setSeekFmLimits(uint16_t bottom, uint16_t top)
Sets the bottom frequency and top frequency of the FM band for seek. Default is 8750 to 10790.
Definition: SI4735.cpp:1373
bool getStatusValid()
Gets the channel status.
Definition: SI4735.h:1272
bool getStatusCTS()
Gets the Error flag Clear to Send.
Definition: SI4735.h:1237
bool getCurrentAfcRailIndicator()
AFC Rail Indicator.
Definition: SI4735.h:1571
void setProperty(uint16_t propertyNumber, uint16_t param)
Sets a given SI47XX device property.
Definition: SI4735.h:1161
void sendCommand(uint8_t cmd, int parameter_size, const uint8_t *parameter)
Sends a given command to the SI47XX devices.
Definition: SI4735.cpp:1485
void sendProperty(uint16_t propertyNumber, uint16_t param)
Sends (sets) property to the SI47XX.
Definition: SI4735.cpp:1453
void getCommandResponse(int num_of_bytes, uint8_t *response)
Returns with the command response.
Definition: SI4735.cpp:1507
int32_t getProperty(uint16_t propertyValue)
Gets a given property from the SI47XX.
Definition: SI4735.cpp:1553
si47x_status getStatusResponse()
Gets the first byte response.
Definition: SI4735.cpp:1527
void setFmBlendMultiPathStereoThreshold(uint8_t parameter)
Sets multipath threshold for stereo blend (Full stereo below threshold, blend above threshold).
Definition: SI4735.cpp:1693
void setFmBLendRssiMonoThreshold(uint8_t parameter)
Sets RSSI threshold for mono blend (Full mono below threshold, blend above threshold).
Definition: SI4735.cpp:1645
void setFmBlendSnrStereoThreshold(uint8_t parameter)
Sets SNR threshold for stereo blend (Full stereo above threshold, blend below threshold).
Definition: SI4735.cpp:1661
void setFmStereoOn()
Turn Off Stereo operation.
Definition: SI4735.cpp:1729
void setFmStereoOff()
Turn Off Stereo operation.
Definition: SI4735.cpp:1719
void setFmBlendRssiStereoThreshold(uint8_t parameter)
Sets RSSI threshold for stereo blend. (Full stereo above threshold, blend below threshold....
Definition: SI4735.cpp:1629
void setFmBlendStereoThreshold(uint8_t parameter)
Sets RSSI threshold for stereo blend (Full stereo above threshold, blend below threshold).
Definition: SI4735.cpp:1597
void setFmBlendMultiPathMonoThreshold(uint8_t parameter)
Sets Multipath threshold for mono blend (Full mono above threshold, blend below threshold).
Definition: SI4735.cpp:1709
void setFmBlendMonoThreshold(uint8_t parameter)
Sets RSSI threshold for mono blend (Full mono below threshold, blend above threshold).
Definition: SI4735.cpp:1613
void setFmBLendSnrMonoThreshold(uint8_t parameter)
Sets SNR threshold for mono blend (Full mono below threshold, blend above threshold).
Definition: SI4735.cpp:1677
void disableFmDebug()
There is a debug feature that remains active in Si4704/05/3x-D60 firmware which can create periodic n...
Definition: SI4735.cpp:1744
void setVolumeDown()
Set the Volume Down.
Definition: SI4735.h:1783
void setAudioMute(bool off)
Sets the audio on or off.
Definition: SI4735.cpp:1832
void digitalOutputSampleRate(uint16_t DOSR)
Enables digital audio output and configures digital audio output sample rate in samples per second (s...
Definition: SI4735.cpp:1801
void volumeDown()
Set sound volume level Down
Definition: SI4735.cpp:1875
void setVolume(uint8_t volume)
Sets volume level (0 to 63)
Definition: SI4735.cpp:1815
uint8_t getCurrentVolume()
Get the Current Volume.
Definition: SI4735.h:1768
void volumeUp()
Set sound volume level Up
Definition: SI4735.cpp:1861
void setAmDelayNB(uint16_t value)
Sets the delay before applying impulse blanking.
Definition: SI4735.h:1815
void setAudioMode(uint8_t audioMode)
Sets the Audio Mode. See table below.
Definition: SI4735.h:1803
uint8_t getVolume()
Gets the current volume level.
Definition: SI4735.cpp:1849
void setVolumeUp()
Set the Volume Up.
Definition: SI4735.h:1776
void digitalOutputFormat(uint8_t OSIZE, uint8_t OMONO, uint8_t OMODE, uint8_t OFALL)
Configures the digital audio output format.
Definition: SI4735.cpp:1777
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B
Definition: SI4735.cpp:2152
void resetEndIndicatorGroupB()
Resets 0xD or 0xA special characters condition (makes it false)
Definition: SI4735.h:2479
char * getRdsText0A(void)
Gets the station name and other messages.
Definition: SI4735.cpp:2321
void rdsClearFifo()
Empty FIFO.
Definition: SI4735.h:2506
bool getEndIndicatorGroupB()
Check if 0xD or 0xA special characters were received for group B.
Definition: SI4735.h:2469
void resetEndIndicatorGroupA()
Resets 0xD or 0xA special characters condition (makes it false)
Definition: SI4735.h:2459
void getRdsStatus(uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY)
Gets the RDS status. Store the status in currentRdsStatus member. RDS COMMAND FM_RDS_STATUS.
Definition: SI4735.cpp:2068
void rdsClearInterrupt()
Clears RDSINT.
Definition: SI4735.h:2517
char * getRdsDateTime(void)
Gets the RDS the Time and Date when the Group type is 4.
Definition: SI4735.cpp:2601
bool getRdsNewBlockA()
Get the Rds New Block A.
Definition: SI4735.h:2384
bool getRdsReceived()
Get the Rds Received FIFO.
Definition: SI4735.h:2350
bool getRdsSync()
Get the Rds Sync.
Definition: SI4735.h:2406
char * getRdsText(void)
Gets the RDS Text when the message is of the Group Type 2 version A.
Definition: SI4735.cpp:2297
bool getRdsSyncFound()
Get the Rds Sync Found.
Definition: SI4735.h:2372
char * getRdsText2B(void)
Gets the Text processed for the 2B group.
Definition: SI4735.cpp:2387
uint8_t getNumRdsFifoUsed()
Get the Num Rds Fifo Used.
Definition: SI4735.h:2428
bool getGroupLost()
Get the Group Lost.
Definition: SI4735.h:2417
bool getRdsDateTime(uint16_t *year, uint16_t *month, uint16_t *day, uint16_t *hour, uint16_t *minute)
Decodes the RDS time to LOCAL Julian Day and time.
Definition: SI4735.cpp:2529
void getRdsStatus()
Gets RDS Status.
Definition: SI4735.h:2495
uint8_t getRdsGroupType(void)
Returns the Group Type (extracted from the Block B)
Definition: SI4735.cpp:2135
char * getRdsTime(void)
Gets the RDS time and date when the Group type is 4.
Definition: SI4735.cpp:2425
uint8_t getRdsTextSegmentAddress(void)
Returns the address of the text segment.
Definition: SI4735.cpp:2174
void getNext2Block(char *)
Process data received from group 2B.
Definition: SI4735.cpp:2226
void mjdConverter(uint32_t mjd, uint32_t *year, uint32_t *month, uint32_t *day)
Converts the MJD number to integers Year, month and day.
Definition: SI4735.cpp:2490
bool getRdsSyncLost()
Get the Rds Sync Lost object.
Definition: SI4735.h:2361
uint8_t getRdsProgramType(void)
Returns the Program Type (extracted from the Block B)
Definition: SI4735.cpp:2209
void clearRdsBuffer2A()
Clear RDS buffer 2A (text)
Definition: SI4735.cpp:1914
void setFifoCount(uint16_t value)
Sets the minimum number of RDS groups stored in the RDS FIFO before RDSRECV is set.
Definition: SI4735.h:2439
void setRdsConfig(uint8_t RDSEN, uint8_t BLETHA, uint8_t BLETHB, uint8_t BLETHC, uint8_t BLETHD)
Sets RDS property.
Definition: SI4735.cpp:1980
void getNext4Block(char *)
Process data received from group 2A.
Definition: SI4735.cpp:2261
bool getEndIndicatorGroupA()
Check if 0xD or 0xA special characters were received for group A.
Definition: SI4735.h:2450
void setRdsIntSource(uint8_t RDSRECV, uint8_t RDSSYNCLOST, uint8_t RDSSYNCFOUND, uint8_t RDSNEWBLOCKA, uint8_t RDSNEWBLOCKB)
Configures interrupt related to RDS.
Definition: SI4735.cpp:2026
void clearRdsBuffer0A()
Clear RDS buffer 0A (text)
Definition: SI4735.cpp:1939
char * getRdsText2A(void)
Gets the Text processed for the 2A group.
Definition: SI4735.cpp:2354
void clearRdsBuffer2B()
Clear RDS buffer 2B (text)
Definition: SI4735.cpp:1927
uint16_t getRdsPI(void)
Returns the programa type.
Definition: SI4735.cpp:2119
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
Definition: SI4735.cpp:2190
bool getRdsNewBlockB()
Get the Rds New Block B.
Definition: SI4735.h:2395
void RdsInit()
Starts the control member variables for RDS.
Definition: SI4735.cpp:1900
void setAmSoftMuteMaxAttenuation(uint8_t smattn=0)
Sets the Am Soft Mute Max Attenuation.
Definition: SI4735.h:1394
void ssbPowerUp()
This function can be useful for debug and test.
Definition: SI4735.cpp:3125
void setSsbAgcAttackRate(uint16_t parameter)
Sets the AGC attack rate on SSB mode.
Definition: SI4735.h:2045
uint8_t getCurrentAvcAmMaxGain()
Get the current Avc Am Max Gain.
Definition: SI4735.h:1378
void setSsbIfAgcAttackRate(uint8_t param=4)
Sets the IF AGC attack rate.
Definition: SI4735.h:1432
void setSsbAgcOverrite(uint8_t SSBAGCDIS, uint8_t SSBAGCNDX, uint8_t reserved=0)
Automatic Gain Control setup.
Definition: SI4735.cpp:3021
void setSSB(uint8_t usblsb)
Set the radio to AM function.
Definition: SI4735.cpp:2913
void setAvcAmDefaultGain()
Sets the Avc Am Max Gain to default gain (0x2A80)
Definition: SI4735.h:1363
void getSsbAgcStatus()
Queries SSB Automatic Gain Control STATUS.
Definition: SI4735.cpp:2994
void setSSBBfo(int offset)
Sets the SSB Beat Frequency Offset (BFO).
Definition: SI4735.cpp:2723
void loadPatch(const uint8_t *ssb_patch_content, const uint16_t ssb_patch_content_size, uint8_t ssb_audiobw=1)
Loads a given SSB patch content.
Definition: SI4735.cpp:3312
uint16_t getAntennaTuningCapacitor()
Get the Antenna Tuning Capacitor value.
Definition: SI4735.h:1323
void setSsbAgcReleaseRate(uint16_t parameter)
Sets the AGC Release rate on SSB mode.
Definition: SI4735.h:2058
void setSSBAudioBandwidth(uint8_t AUDIOBW)
SSB Audio Bandwidth for SSB mode.
Definition: SI4735.cpp:2890
void setSSBDspAfc(uint8_t DSP_AFCDIS)
Sets DSP AFC disable or enable.
Definition: SI4735.cpp:2797
void setAvcAmMaxGain()
Sets the Avc Am Max Gain to maximum gain (0x7800)
Definition: SI4735.h:1343
void setSSBSidebandCutoffFilter(uint8_t SBCUTFLT)
Sets SBB Sideband Cutoff Filter for band pass and low pass filters.
Definition: SI4735.cpp:2860
si4735_eeprom_patch_header downloadPatchFromEeprom(int eeprom_i2c_address)
Transfers the content of a patch stored in an eeprom to the SI4735 device.
Definition: SI4735.cpp:3342
void setSSB(uint16_t fromFreq, uint16_t toFreq, uint16_t intialFreq, uint16_t step, uint8_t usblsb)
Definition: SI4735.cpp:2947
void setSsbSoftMuteMaxAttenuation(uint8_t smattn=0)
Sets the SSB Soft Mute Max Attenuation object.
Definition: SI4735.h:1408
void setSSBSoftMute(uint8_t SMUTESEL)
Sets SSB Soft-mute Based on RSSI or SNR Selection:
Definition: SI4735.cpp:2812
void setSSBConfig(uint8_t AUDIOBW, uint8_t SBCUTFLT, uint8_t AVC_DIVIDER, uint8_t AVCEN, uint8_t SMUTESEL, uint8_t DSP_AFCDIS)
Sets the SSB receiver mode.
Definition: SI4735.cpp:2772
void setSsbIfAgcReleaseRate(uint8_t param=140)
Sets the number of milliseconds the low IF peak detector.
Definition: SI4735.h:1420
void setSSBAutomaticVolumeControl(uint8_t AVCEN)
Sets SSB Automatic Volume Control (AVC) for SSB mode.
Definition: SI4735.cpp:2827
si47x_firmware_query_library queryLibraryId()
Query the library information of the Si47XX device.
Definition: SI4735.cpp:3068
void sendSSBModeProperty()
Just send the property SSB_MOD to the device. Internal use (privete method).
Definition: SI4735.cpp:2968
void setSBBSidebandCutoffFilter(uint8_t SBCUTFLT)
Definition: SI4735.h:2557
bool downloadCompressedPatch(const uint8_t *ssb_patch_content, const uint16_t ssb_patch_content_size, const uint16_t *cmd_0x15, const int16_t cmd_0x15_size)
Deal with compressed SSB patch.
Definition: SI4735.cpp:3271
void setAvcAmMinGain()
Sets the Avc Am Max Gain to minimal gain (0x1000)
Definition: SI4735.h:1353
void patchPowerUp()
This method can be used to prepare the device to apply SSBRX patch.
Definition: SI4735.cpp:3109
void setSSBAvcDivider(uint8_t AVC_DIVIDER)
Sets AVC Divider.
Definition: SI4735.cpp:2842
bool downloadPatch(const uint8_t *ssb_patch_content, const uint16_t ssb_patch_content_size)
Transfers the content of a patch stored in a array of bytes to the SI4735 device.
Definition: SI4735.cpp:3183
void setI2CStandardMode(void)
Sets I2C bus to 100kHz.
Definition: SI4735.h:2689
void setAudioMuteMcuPin(int8_t pin)
Sets the Audio Mute Mcu Pin.
Definition: SI4735.h:2724
void convertToChar(uint16_t value, char *strValue, uint8_t len, uint8_t dot, uint8_t separator, bool remove_leading_zeros=true)
Converts a number to a char array.
Definition: SI4735.cpp:3418
void setHardwareAudioMute(bool on)
Sets the Hardware Audio Mute.
Definition: SI4735.h:2740
void setI2CFastModeCustom(long value=500000)
Sets the I2C bus to a given value. ATTENTION: use this function with cation.
Definition: SI4735.h:2709
void setI2CFastMode(void)
Sets I2C bus to 400kHz.
Definition: SI4735.h:2696
void setI2CLowSpeedMode(void)
Sets I2C bus to 10kHz.
Definition: SI4735.h:2679
void setNBFM(uint16_t fromFreq, uint16_t toFreq, uint16_t initialFreq, uint16_t step)
Definition: SI4735.cpp:3582
void setNBFM()
Set the radio to FM function.
Definition: SI4735.cpp:3551
void setFrequencyNBFM(uint16_t freq)
Set the frequency to the corrent function of the Si4735 on NBFM mode.
Definition: SI4735.cpp:3610
void patchPowerUpNBFM()
This method can be used to prepare the device to apply NBFM patch.
Definition: SI4735.cpp:3508
void loadPatchNBFM(const uint8_t *patch_content, const uint16_t patch_content_size)
Loads a given NBFM patch content.
Definition: SI4735.cpp:3527