PU2CLR Si4735 Arduino Library  1.1.9
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 SI47XX, BROADCAST AM/FM/SW RADIO RECEIVER IC family from Silicon Labs.
5  * @details This library is intended to provide an easier interface for controlling the SI47XX by using Arduino platform.
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 20 examples on <https://github.com/pu2clr/SI4735/tree/master/examples>
10  *
11  * @see https://pu2clr.github.io/SI4735/
12  * @see Si47XX PROGRAMMING GUIDE AN332: https://www.silabs.com/documents/public/application-notes/AN332.pdf
13  * @see AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; AMENDMENT FOR SI4735-D60 SSB AND NBFM PATCHES
14  *
15  * @author PU2CLR - Ricardo Lima Caratti
16  * @date 2019-2020
17  */
18 
19 #include <Arduino.h>
20 #include <Wire.h>
21 
22 #define POWER_UP_FM 0 // FM
23 #define POWER_UP_AM 1 // AM and SSB (if patch applyed)
24 #define POWER_UP_WB 3 // Weather Band Receiver
25 #define POWER_PATCH 15 //
26 
27 // SI473X commands (general)
28 #define SI473X_ADDR_SEN_LOW 0x11 // SI473X I2C buss address when the SEN pin (16) is set to low 0V.
29 #define SI473X_ADDR_SEN_HIGH 0x63 // SI473X I2C buss address when the SEN pin (16) is set to high +3.3V
30 
31 #define POWER_UP 0x01 // Power up device and mode selection.
32 #define GET_REV 0x10 // Returns revision information on the device.
33 #define POWER_DOWN 0x11 // Power down device.
34 #define SET_PROPERTY 0x12 // Sets the value of a property.
35 #define GET_PROPERTY 0x13 // Retrieves a property’s value.
36 #define GET_INT_STATUS 0x14 // Read interrupt status bits.
37 
38 // FM
39 #define FM_TUNE_FREQ 0x20
40 #define FM_SEEK_START 0x21 // Begins searching for a valid FM frequency.
41 #define FM_TUNE_STATUS 0x22
42 #define FM_AGC_STATUS 0x27
43 #define FM_AGC_OVERRIDE 0x28
44 #define FM_RSQ_STATUS 0x23
45 #define FM_RDS_STATUS 0x24 // Returns RDS information for current channel and reads an entry from the RDS FIFO.
46 
47 // FM RDS properties
48 #define FM_RDS_INT_SOURCE 0x1500
49 #define FM_RDS_INT_FIFO_COUNT 0x1501
50 #define FM_RDS_CONFIG 0x1502
51 #define FM_RDS_CONFIDENCE 0x1503
52 
53 #define FM_BLEND_STEREO_THRESHOLD 0x1105
54 #define FM_BLEND_MONO_THRESHOLD 0x1106
55 #define FM_BLEND_RSSI_STEREO_THRESHOLD 0x1800
56 #define FM_BLEND_RSSI_MONO_THRESHOLD 0x1801
57 #define FM_BLEND_SNR_STEREO_THRESHOLD 0x1804
58 #define FM_BLEND_SNR_MONO_THRESHOLD 0x1805
59 #define FM_BLEND_MULTIPATH_STEREO_THRESHOLD 0x1808
60 #define FM_BLEND_MULTIPATH_MONO_THRESHOLD 0x1809
61 
62 // AM command
63 #define AM_TUNE_FREQ 0x40 // Tunes to a given AM frequency.
64 #define AM_SEEK_START 0x41 // Begins searching for a valid AM frequency.
65 #define AM_TUNE_STATUS 0x42 // Queries the status of the already issued AM_TUNE_FREQ or AM_SEEK_START command.
66 #define AM_RSQ_STATUS 0x43 // Queries the status of the Received Signal Quality (RSQ) for the current channel.
67 #define AM_AGC_STATUS 0x47 // Queries the current AGC settings.
68 #define AM_AGC_OVERRIDE 0x48 // Overrides AGC settings by disabling and forcing it to a fixed value.
69 #define GPIO_CTL 0x80 // Configures GPO1, 2, and 3 as output or Hi-Z.
70 #define GPIO_SET 0x81 // Sets GPO1, 2, and 3 output level (low or high).
71 
72 //SSB command (SAME AM CMD VALUES)
73 // See AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; pages 4 and 5
74 #define SSB_TUNE_FREQ 0x40 // Tunes to a given SSB frequency.
75 #define SSB_TUNE_STATUS 0x42 // Queries the status of the already issued SSB_TUNE_FREQ or AM_SEEK_START command.
76 #define SSB_RSQ_STATUS 0x43 // Queries the status of the Received Signal Quality (RSQ) for the current channel.
77 #define SSB_AGC_STATUS 0x47 // Queries the current AGC settings.
78 #define SSB_AGC_OVERRIDE 0x48 // Overrides AGC settings by disabling and forcing it to a fixed value.
79 
80 // AM/SW/LW Receiver Property Summary
81 // See Si47XX PROGRAMMING GUIDE AN332; page 125
82 #define DIGITAL_OUTPUT_FORMAT 0x0102 // Configure digital audio outputs.
83 #define DIGITAL_OUTPUT_SAMPLE_RATE 0x0104 // Configure digital audio output sample rate
84 #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.
85 #define REFCLK_PRESCALE 0x0202 // Sets the prescaler value for RCLK input.
86 #define AM_DEEMPHASIS 0x3100 // Sets deemphasis time constant. Can be set to 50 μs. Deemphasis is disabled by default.
87 #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.
88 #define AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN 0x3103 // Sets the maximum gain for automatic volume control.
89 #define AM_MODE_AFC_SW_PULL_IN_RANGE 0x3104 // Sets the SW AFC pull-in range.
90 #define AM_MODE_AFC_SW_LOCK_IN_RANGE 0x3105 // Sets the SW AFC lock-in.
91 #define AM_RSQ_INTERRUPTS 0x3200 // Same SSB - Configures interrupt related to Received Signal Quality metrics. All interrupts are disabled by default.
92 #define AM_RSQ_SNR_HIGH_THRESHOLD 0x3201 //Sets high threshold for SNR interrupt.
93 #define AM_RSQ_SNR_LOW_THRESHOLD 0x3202 // Sets low threshold for SNR interrupt.
94 #define AM_RSQ_RSSI_HIGH_THRESHOLD 0x3203 // Sets high threshold for RSSI interrupt.
95 #define AM_RSQ_RSSI_LOW_THRESHOLD 0x3204 // Sets low threshold for RSSI interrupt.
96 #define AM_SOFT_MUTE_RATE 0x3300 // Sets the attack and decay rates when entering or leaving soft mute. The default is 278 dB/s.
97 #define AM_SOFT_MUTE_SLOPE 0x3301 // Sets the AM soft mute slope. Default value is a slope of 1.
98 #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.
99 #define AM_SOFT_MUTE_SNR_THRESHOLD 0x3303 // Sets SNR threshold to engage soft mute. Default is 8 dB.
100 #define AM_SOFT_MUTE_RELEASE_RATE 0x3304 // Sets softmute release rate. Smaller values provide slower release, and larger values provide faster release.
101 #define AM_SOFT_MUTE_ATTACK_RATE 0x3305 // Sets software attack rate. Smaller values provide slower attack, and larger values provide faster attack.
102 #define AM_SEEK_BAND_BOTTOM 0x3400 // Sets the bottom of the AM band for seek. Default is 520.
103 #define AM_SEEK_BAND_TOP 0x3401 // Sets the top of the AM band for seek. Default is 1710.
104 #define AM_SEEK_FREQ_SPACING 0x3402 // Selects frequency spacing for AM seek. Default is 10 kHz spacing.
105 #define AM_SEEK_SNR_THRESHOLD 0x3403 // Sets the SNR threshold for a valid AM Seek/Tune.
106 #define AM_SEEK_RSSI_THRESHOLD 0x3404 // Sets the RSSI threshold for a valid AM Seek/Tune.
107 #define AM_AGC_ATTACK_RATE 0x3702 // Sets the number of milliseconds the high peak detector must be exceeded before decreasing gain.
108 #define AM_AGC_RELEASE_RATE 0x3703 // Sets the number of milliseconds the low peak detector must not be exceeded before increasing the gain.
109 #define AM_FRONTEND_AGC_CONTROL 0x3705 // Adjusts AM AGC for frontend (external) attenuator and LNA.
110 #define AM_NB_DETECT_THRESHOLD 0x3900 // Sets the threshold for detecting impulses in dB above the noise floor
111 #define AM_NB_INTERVAL 0x3901 // Interval in micro-seconds that original samples are replaced by interpolated clean samples
112 #define AM_NB_RATE 0x3902 // Noise blanking rate in 100 Hz units. Default value is 64.
113 #define AM_NB_IIR_FILTER 0x3903 // Sets the bandwidth of the noise floor estimator. Default value is 300.
114 #define AM_NB_DELAY 0x3904 // Delay in micro-seconds before applying impulse blanking to the original samples
115 
116 #define RX_VOLUME 0x4000
117 #define RX_HARD_MUTE 0x4001
118 
119 // SSB properties
120 // See AN332 REV 0.8 Universal Programming Guide (Amendment for SI4735-D60 SSN and NBFM Patches)
121 
122 #define GPO_IEN 0x0001 // AM and SSB - Enable interrupt source
123 #define SSB_BFO 0x0100 // Sets the Beat Frequency Offset (BFO) under SSB mode.
124 #define SSB_MODE 0x0101 // Sets number of properties of the SSB mode.
125 #define SSB_RSQ_INTERRUPTS 0x3200 // Configure Interrupts related to RSQ
126 #define SSB_RSQ_SNR_HI_THRESHOLD 0x3201 // Sets high threshold for SNR interrupt
127 #define SSB_RSQ_SNR_LO_THRESHOLD 0x3202 // Sets low threshold for SNR interrupt
128 #define SSB_RSQ_RSSI_HI_THRESHOLD 0x3203 // Sets high threshold for RSSI interrupt
129 #define SSB_RSQ_RSSI_LO_THRESHOLD 0x3204 // Sets low threshold for RSSI interrupt
130 #define SSB_SOFT_MUTE_RATE 0x3300 // Sets the attack and decay rates when entering or leaving soft mute
131 #define SSB_SOFT_MUTE_MAX_ATTENUATION 0x3302 // Sets the maximum attenuation during soft mute (db); 0dB to disable soft mute; defaul 8dB;
132 #define SSB_SOFT_MUTE_SNR_THRESHOLD 0x3303 // Sets SNR threshould to engage soft mute. Defaul 8dB
133 #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.
134 #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.
135 
136 // SSB
137 #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.
138 #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.
139 
140 // See AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; pages 12 and 13
141 #define LSB_MODE 1 // 01
142 #define USB_MODE 2 // 10
143 
144 // Parameters
145 #define SI473X_RDS_OUTPUT_ONLY 0b00000000 // RDS output only (no audio outputs) Si4749 only
146 #define SI473X_ANALOG_AUDIO 0b00000101 // Analog Audio Inputs
147 #define SI473X_DIGITAL_AUDIO1 0b00001011 // Digital audio output (DCLK, LOUT/DFS, ROUT/DIO)
148 #define SI473X_DIGITAL_AUDIO2 0b10110000 // Digital audio outputs (DCLK, DFS, DIO)
149 #define SI473X_ANALOG_DIGITAL_AUDIO 0b10110101 // Analog and digital audio outputs (LOUT/ROUT and DCLK, DFS,DIO)
150 
151 // Other parameters
152 #define FM_CURRENT_MODE 0
153 #define AM_CURRENT_MODE 1
154 #define SSB_CURRENT_MODE 2
155 
156 #define MAX_DELAY_AFTER_SET_FREQUENCY 30 // In ms - This value helps to improve the precision during of getting frequency value
157 #define MAX_DELAY_AFTER_POWERUP 10 // In ms - Max delay you have to setup after a power up command.
158 #define MIN_DELAY_WAIT_SEND_LOOP 300 // In uS (Microsecond) - each loop of waitToSend sould wait this value in microsecond
159 
160 /** @defgroup group01 SI473X data types
161  * @section group01 SI473X data types
162  *
163  * @brief SI473X data representation
164  *
165  * @details The goal here is separate data from code.
166  * The Si47XX family works with many internal data that can be represented by data structure
167  * or defined data type in C/C++. These C/C++ resources have been used widely here.
168  * This aproach made the library easier to build and maintain. Each data structure created
169  * here has its reference (name of the document and page on which it was based).
170  * In other words, to make the SI47XX device easier to deal, some defined data types were
171  * created to handle byte and bits to process commands, properties and responses.
172  * These data types will be usefull to deal with SI473X
173  */
174 
175 /**
176  * @ingroup group01
177  *
178  * @brief Power Up arguments data type
179  *
180  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 64 and 65
181  */
182 typedef union {
183  struct
184  {
185  // ARG1
186  uint8_t FUNC : 4; //!< Function (0 = FM Receive; 1–14 = Reserved; 15 = Query Library ID)
187  uint8_t XOSCEN : 1; //!< Crystal Oscillator Enable (0 = crystal oscillator disabled; 1 = Use crystal oscillator and and OPMODE=ANALOG AUDIO) .
188  uint8_t PATCH : 1; //!< Patch Enable (0 = Boot normally; 1 = Copy non-volatile memory to RAM).
189  uint8_t GPO2OEN : 1; //!< GPO2 Output Enable (0 = GPO2 output disabled; 1 = GPO2 output enabled).
190  uint8_t CTSIEN : 1; //!< CTS Interrupt Enable (0 = CTS interrupt disabled; 1 = CTS interrupt enabled).
191  // ARG2
192  uint8_t OPMODE; //!< Application Setting. See page 65
193  } arg; //!< Refined powerup parameters
194  uint8_t raw[2]; //!< Raw powerup parameters data. Same arg memory position. So, same content.
195 } si473x_powerup;
196 
197 /**
198  * @ingroup group01
199  *
200  * @brief Data type for Enables output for GPO1, GPO2 and GPO3
201  *
202  * @details GPO1, 2, and 3 can be configured for output (Hi-Z or active drive) by setting the GPO1OEN, GPO2OEN, and GPO3OEN bit.
203  *
204  * @see Si47XX PROGRAMMING GUIDE; AN332; page 82 and 144
205  */
206 typedef union {
207  struct
208  {
209  uint8_t DUMMY1 : 1; //!< Always write 0.
210  uint8_t GPO1OEN : 1; //!< GPO1 Output Enable.
211  uint8_t GPO2OEN : 1; //!< GPO2 Output Enable.
212  uint8_t GPO3OEN : 1; //!< GPO3 Output Enable.
213  uint8_t DUMMY2 : 4; //!< Always write 0.
214  } arg; //!< Refined powerup parameters
216 } si473x_gpio;
217 
218 /**
219  * @ingroup group01
220  *
221  * @brief Data type for Configuring the sources for the GPO2/INT interrupt pin
222  *
223  * @details Valid sources are the lower 8 bits of the STATUS byte, including CTS, ERR, RSQINT, and STCINT bits.
224  *
225  * @see Si47XX PROGRAMMING GUIDE; AN332; page 146
226  */
227 typedef union {
228  struct
229  {
230  uint8_t STCIEN : 1; //!< Seek/Tune Complete Interrupt Enable (0 or 1).
231  uint8_t DUMMY1 : 2; //!< Always write 0.
232  uint8_t RSQIEN : 1; //!< RSQ Interrupt Enable (0 or 1).
233  uint8_t DUMMY2 : 2; //!< Always write 0.
234  uint8_t ERRIEN : 1; //!< ERR Interrupt Enable (0 or 1).
235  uint8_t CTSIEN : 1; //!< CTS Interrupt Enable (0 or 1).
236  uint8_t STCREP : 1; //!< STC Interrupt Repeat (0 or 1).
237  uint8_t DUMMY3 : 2; //!< Always write 0.
238  uint8_t RSQREP : 1; //!< RSQ Interrupt Repeat (0 or 1).
239  uint8_t DUMMY4 : 4; //!< Always write 0.
240  } arg;
242 } si473x_gpio_ien;
243 
244 
245 
246 /**
247  * @ingroup group01
248  *
249  * @brief Represents how the frequency is stored in the si4735.
250  * @details It helps to convert frequency in uint16_t to two bytes (uint8_t) (FREQL and FREQH)
251  */
252 typedef union {
253  struct
254  {
255  uint8_t FREQL; //!< Tune Frequency Low byte.
256  uint8_t FREQH; //!< Tune Frequency High byte.
257  } raw; //!< Raw data that represents the frequency stored in the Si47XX device.
258  uint16_t value; //!< frequency (integer value)
259 } si47x_frequency;
260 
261 /**
262  * @ingroup group01
263  * @brief Antenna Tuning Capacitor data type manupulation
264  */
265 typedef union {
266  struct
267  {
268  uint8_t ANTCAPL; //!< Antenna Tuning Capacitor High byte
269  uint8_t ANTCAPH; //!< Antenna Tuning Capacitor Low byte
270  } raw;
272 } si47x_antenna_capacitor;
273 
274 /**
275  * @ingroup group01
276  *
277  * @brief AM Tune frequency data type command (AM_TUNE_FREQ command)
278  *
279  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 135
280  */
281 typedef union {
282  struct
283  {
284  uint8_t FAST : 1; //!< ARG1 - FAST Tuning. If set, executes fast and invalidated tune. The tune status will not be accurate.
285  uint8_t FREEZE : 1; //!< Valid only for FM (Must be 0 to AM)
286  uint8_t DUMMY1 : 4; //!< Always set 0
287  uint8_t USBLSB : 2; //!< SSB Upper Side Band (USB) and Lower Side Band (LSB) Selection. 10 = USB is selected; 01 = LSB is selected.
288  uint8_t FREQH; //!< ARG2 - Tune Frequency High byte.
289  uint8_t FREQL; //!< ARG3 - Tune Frequency Low byte.
290  uint8_t ANTCAPH; //!< ARG4 - Antenna Tuning Capacitor High byte.
291  uint8_t ANTCAPL; //!< ARG5 - Antenna Tuning Capacitor Low byte. Note used for FM.
292  } arg;
294 } si47x_set_frequency;
295 
296 /**
297  * @ingroup group01
298  *
299  * @brief Seek frequency (automatic tuning)
300  *
301  * @details Represents searching for a valid frequency data type.
302  */
303 typedef union {
304  struct
305  {
306  uint8_t RESERVED1 : 2;
307  uint8_t WRAP : 1; //!< Determines whether the seek should Wrap = 1, or Halt = 0 when it hits the band limit.
308  uint8_t SEEKUP : 1; //!< Determines the direction of the search, either UP = 1, or DOWN = 0.
309  uint8_t RESERVED2 : 4;
310  } arg;
312 } si47x_seek;
313 
314 /**
315  * @ingroup group01 status response structure
316  *
317  * @brief Status response data representation
318  *
319  * @details Represents searching for a valid frequency data type.
320  */
321 typedef union {
322  struct
323  {
324  uint8_t STCINT : 1; //!< 1 = Tune complete has been triggered.
325  uint8_t DUMMY1 : 1; //!< Reserved (Values may vary).
326  uint8_t RDSINT : 1; //!< 1 = Radio data system interrupt has been triggered.
327  uint8_t RSQINT : 1; //!< 1 = Received Signal Quality measurement has been triggered.
328  uint8_t DUMMY2 : 2; //!< Reserved (Values may vary).
329  uint8_t ERR : 1; //!< 1 = Error.
330  uint8_t CTS : 1; //!< 0 = Wait before sending next command; 1 = Clear to send next command.
331  } refined;
333 } si47x_status;
334 
335 /**
336  * @ingroup group01
337  *
338  * @brief Response status command
339  *
340  * @details Response data from a query status command
341  *
342  * @see Si47XX PROGRAMMING GUIDE; pages 73 and
343  */
344 typedef union {
345  struct
346  {
347  // Status
348  uint8_t STCINT : 1; //!< Seek/Tune Complete Interrupt; 1 = Tune complete has been triggered.
349  uint8_t DUMMY1 : 1;
350  uint8_t RDSINT : 1; //!< Radio Data System (RDS) Interrup; 0 = interrupt has not been triggered.
351  uint8_t RSQINT : 1; //!< Received Signal Quality Interrupt; 0 = interrupt has not been triggered.
352  uint8_t DUMMY2 : 2;
353  uint8_t ERR : 1; //!< Error. 0 = No error 1 = Error
354  uint8_t CTS : 1; //!< Clear to Send.
355  // RESP1
356  uint8_t VALID : 1; //!< Valid Channel
357  uint8_t AFCRL : 1; //!< AFC Rail Indicator
358  uint8_t DUMMY3 : 5;
359  uint8_t BLTF : 1; //!< Reports if a seek hit the band limit
360  // RESP2
361  uint8_t READFREQH; //!< Read Frequency High byte.
362  // RESP3
363  uint8_t READFREQL; //!< Read Frequency Low byte.
364  // RESP4
365  uint8_t RSSI; //!< Received Signal Strength Indicator (dBμV)
366  // RESP5
367  uint8_t SNR; //!< This byte contains the SNR metric when tune is complete (dB).
368  // RESP6
369  uint8_t MULT; //!< Contains the multipath metric when tune is complete
370  // RESP7
371  uint8_t READANTCAP; //!< Contains the current antenna tuning capacitor value
372  } resp;
373  uint8_t raw[8]; //!< Check it
374 } si47x_response_status;
375 
376 /**
377  * @ingroup group01
378  *
379  * @brief Data representation for Firmware Information (GET_REV)
380  *
381  * @details The part number, chip revision, firmware revision, patch revision and component revision numbers.
382  *
383  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 66 and 131
384  */
385 typedef union {
386  struct
387  {
388  // status ("RESP0")
389  uint8_t STCINT : 1;
390  uint8_t DUMMY1 : 1;
391  uint8_t RDSINT : 1;
392  uint8_t RSQINT : 1;
393  uint8_t DUMMY2 : 2;
394  uint8_t ERR : 1;
395  uint8_t CTS : 1;
396  uint8_t PN; //!< RESP1 - Final 2 digits of Part Number (HEX).
397  uint8_t FWMAJOR; //!< RESP2 - Firmware Major Revision (ASCII).
398  uint8_t FWMINOR; //!< RESP3 - Firmware Minor Revision (ASCII).
399  uint8_t PATCHH; //!< RESP4 - Patch ID High byte (HEX).
400  uint8_t PATCHL; //!< RESP5 - Patch ID Low byte (HEX).
401  uint8_t CMPMAJOR; //!< RESP6 - Component Major Revision (ASCII).
402  uint8_t CMPMINOR; //!< RESP7 - Component Minor Revision (ASCII).
403  uint8_t CHIPREV; //!< RESP8 - Chip Revision (ASCII).
404  // RESP9 to RESP15 not used
405  } resp;
407 } si47x_firmware_information;
408 
409 /**
410  * @ingroup group01
411  *
412  * @brief Firmware Query Library ID response.
413  *
414  * @details Used to represent the response of a power up command with FUNC = 15 (patch)
415  *
416  * To confirm that the patch is compatible with the internal device library revision, the library
417  * revision should be confirmed by issuing the POWER_UP command with Function = 15 (query library ID)
418  *
419  * @see Si47XX PROGRAMMING GUIDE; AN332; page 12
420  */
421 typedef union {
422  struct
423  {
424  // status ("RESP0")
425  uint8_t STCINT : 1;
426  uint8_t DUMMY1 : 1;
427  uint8_t RDSINT : 1;
428  uint8_t RSQINT : 1;
429  uint8_t DUMMY2 : 2;
430  uint8_t ERR : 1;
431  uint8_t CTS : 1;
432  uint8_t PN; //!< RESP1 - Final 2 digits of Part Number (HEX).
433  uint8_t FWMAJOR; //!< RESP2 - Firmware Major Revision (ASCII).
434  uint8_t FWMINOR; //!< RESP3 - Firmware Minor Revision (ASCII).
435  uint8_t RESERVED1; //!< RESP4 - Reserved, various values.
436  uint8_t RESERVED2; //!< RESP5 - Reserved, various values.
437  uint8_t CHIPREV; //!< RESP6 - Chip Revision (ASCII).
438  uint8_t LIBRARYID; //!< RESP7 - Library Revision (HEX).
439  // RESP9 to RESP15 not used
440  } resp;
442 } si47x_firmware_query_library;
443 
444 /**
445  * @ingroup group01
446  *
447  * @brief Seek station status
448  *
449  * @details Status of FM_TUNE_FREQ or FM_SEEK_START commands or Status of AM_TUNE_FREQ or AM_SEEK_START commands.
450  *
451  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 73 and 139
452  */
453 typedef union {
454  struct
455  {
456  uint8_t INTACK : 1; //!< If set, clears the seek/tune complete interrupt status indicator.
457  uint8_t CANCEL : 1; //!< If set, aborts a seek currently in progress.
458  uint8_t RESERVED2 : 6;
459  } arg;
461 } si47x_tune_status;
462 
463 /**
464  * @ingroup group01
465  *
466  * @brief Data type to deal with SET_PROPERTY command
467  *
468  * @details Property Data type (help to deal with SET_PROPERTY command on si473X)
469  */
470 typedef union {
471  struct
472  {
473  uint8_t byteLow;
474  uint8_t byteHigh;
475  } raw;
477 } si47x_property;
478 
479 /** @defgroup group02 RDS Data types */
480 /** @section group02 RDS Data types */
481 
482 /**
483  * @ingroup group02
484  *
485  * @brief Radio Signal Quality data representation
486  *
487  * @details Data type for status information about the received signal quality (FM_RSQ_STATUS and AM_RSQ_STATUS)
488  *
489  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 75 and
490  */
491 typedef union {
492  struct
493  {
494  // status ("RESP0")
495  uint8_t STCINT : 1;
496  uint8_t DUMMY1 : 1;
497  uint8_t RDSINT : 1;
498  uint8_t RSQINT : 1;
499  uint8_t DUMMY2 : 2;
500  uint8_t ERR : 1;
501  uint8_t CTS : 1;
502  // RESP1
503  uint8_t RSSIILINT : 1; //!< RSSI Detect Low.
504  uint8_t RSSIHINT : 1; //!< RSSI Detect High.
505  uint8_t SNRLINT : 1; //!< SNR Detect Low.
506  uint8_t SNRHINT : 1; //!< SNR Detect High.
507  uint8_t MULTLINT : 1; //!< Multipath Detect Low
508  uint8_t MULTHINT : 1; //!< Multipath Detect High
509  uint8_t DUMMY3 : 1;
510  uint8_t BLENDINT : 1; //!< Blend Detect Interrupt.
511  // RESP2
512  uint8_t VALID : 1; //!< Valid Channel.
513  uint8_t AFCRL : 1; //!< AFC Rail Indicator.
514  uint8_t DUMMY4 : 1;
515  uint8_t SMUTE : 1; //!< Soft Mute Indicator. Indicates soft mute is engaged.
516  uint8_t DUMMY5 : 4;
517  // RESP3
518  uint8_t STBLEND : 7; //!< Indicates amount of stereo blend in% (100 = full stereo, 0 = full mono).
519  uint8_t PILOT : 1; //!< Indicates stereo pilot presence.
520  // RESP4 to RESP7
521  uint8_t RSSI; //!< RESP4 - Contains the current receive signal strength (0–127 dBμV).
522  uint8_t SNR; //!< RESP5 - Contains the current SNR metric (0–127 dB).
523  uint8_t MULT; //!< RESP6 - Contains the current multipath metric. (0 = no multipath; 100 = full multipath)
524  uint8_t FREQOFF; //!< RESP7 - Signed frequency offset (kHz).
525  } resp;
527 } si47x_rqs_status;
528 
529 /**
530  * @ingroup group02
531  *
532  * @brief Data type for RDS Status command and response information
533  *
534  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 77 and 78
535  * @see Also https://en.wikipedia.org/wiki/Radio_Data_System
536  */
537 typedef union {
538  struct
539  {
540  uint8_t INTACK : 1; // Interrupt Acknowledge; 0 = RDSINT status preserved; 1 = Clears RDSINT.
541  uint8_t MTFIFO : 1; // Empty FIFO; 0 = If FIFO not empty; 1 = Clear RDS Receive FIFO.
542  uint8_t STATUSONLY : 1; // Determines if data should be removed from the RDS FIFO.
543  uint8_t dummy : 5;
544  } arg;
546 } si47x_rds_command;
547 
548 /**
549  * @ingroup group02
550  *
551  * @brief Response data type for current channel and reads an entry from the RDS FIFO.
552  *
553  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 77 and 78
554  */
555 typedef union {
556  struct
557  {
558  // status ("RESP0")
559  uint8_t STCINT : 1;
560  uint8_t DUMMY1 : 1;
561  uint8_t RDSINT : 1;
562  uint8_t RSQINT : 1;
563  uint8_t DUMMY2 : 2;
564  uint8_t ERR : 1;
565  uint8_t CTS : 1;
566  // RESP1
567  uint8_t RDSRECV : 1; //!< RDS Received; 1 = FIFO filled to minimum number of groups set by RDSFIFOCNT.
568  uint8_t RDSSYNCLOST : 1; //!< RDS Sync Lost; 1 = Lost RDS synchronization.
569  uint8_t RDSSYNCFOUND : 1; //!< RDS Sync Found; 1 = Found RDS synchronization.
570  uint8_t DUMMY3 : 1;
571  uint8_t RDSNEWBLOCKA : 1; //!< RDS New Block A; 1 = Valid Block A data has been received.
572  uint8_t RDSNEWBLOCKB : 1; //!< RDS New Block B; 1 = Valid Block B data has been received.
573  uint8_t DUMMY4 : 2;
574  // RESP2
575  uint8_t RDSSYNC : 1; //!< RDS Sync; 1 = RDS currently synchronized.
576  uint8_t DUMMY5 : 1;
577  uint8_t GRPLOST : 1; //!< Group Lost; 1 = One or more RDS groups discarded due to FIFO overrun.
578  uint8_t DUMMY6 : 5;
579  // RESP3 to RESP11
580  uint8_t RDSFIFOUSED; //!< RESP3 - RDS FIFO Used; Number of groups remaining in the RDS FIFO (0 if empty).
581  uint8_t BLOCKAH; //!< RESP4 - RDS Block A; HIGH byte
582  uint8_t BLOCKAL; //!< RESP5 - RDS Block A; LOW byte
583  uint8_t BLOCKBH; //!< RESP6 - RDS Block B; HIGH byte
584  uint8_t BLOCKBL; //!< RESP7 - RDS Block B; LOW byte
585  uint8_t BLOCKCH; //!< RESP8 - RDS Block C; HIGH byte
586  uint8_t BLOCKCL; //!< RESP9 - RDS Block C; LOW byte
587  uint8_t BLOCKDH; //!< RESP10 - RDS Block D; HIGH byte
588  uint8_t BLOCKDL; //!< RESP11 - RDS Block D; LOW byte
589  // RESP12 - Blocks A to D Corrected Errors.
590  // 0 = No errors;
591  // 1 = 1–2 bit errors detected and corrected;
592  // 2 = 3–5 bit errors detected and corrected.
593  // 3 = Uncorrectable.
594  uint8_t BLED : 2;
595  uint8_t BLEC : 2;
596  uint8_t BLEB : 2;
597  uint8_t BLEA : 2;
598  } resp;
600 } si47x_rds_status;
601 
602 /**
603  * @ingroup group02
604  *
605  * @brief FM_RDS_INT_SOURCE property data type
606  *
607  * @see Si47XX PROGRAMMING GUIDE; AN332; page 103
608  * @see also https://en.wikipedia.org/wiki/Radio_Data_System
609  */
610 typedef union {
611  struct
612  {
613  uint8_t RDSRECV : 1; //!< If set, generate RDSINT when RDS FIFO has at least FM_RDS_INT_FIFO_COUNT entries.
614  uint8_t RDSSYNCLOST : 1; //!< If set, generate RDSINT when RDS loses synchronization.
615  uint8_t RDSSYNCFOUND : 1; //!< f set, generate RDSINT when RDS gains synchronization.
616  uint8_t DUMMY1 : 1; //!< Always write to 0.
617  uint8_t RDSNEWBLOCKA : 1; //!< If set, generate an interrupt when Block A data is found or subsequently changed
618  uint8_t RDSNEWBLOCKB : 1; //!< If set, generate an interrupt when Block B data is found or subsequently changed
619  uint8_t DUMMY2 : 5; //!< Reserved - Always write to 0.
620  uint8_t DUMMY3 : 5; //!< Reserved - Always write to 0.
621  } refined;
623 } si47x_rds_int_source;
624 
625 /**
626  * @ingroup group02
627  *
628  * @brief Data type for FM_RDS_CONFIG Property
629  *
630  * IMPORTANT: all block errors must be less than or equal the associated block error threshold for the group
631  * to be stored in the RDS FIFO.
632  * 0 = No errors; 1 = 1–2 bit errors detected and corrected; 2 = 3–5 bit errors detected and corrected; 3 = Uncorrectable.
633  * Recommended Block Error Threshold options:
634  * 2,2,2,2 = No group stored if any errors are uncorrected.
635  * 3,3,3,3 = Group stored regardless of errors.
636  * 0,0,0,0 = No group stored containing corrected or uncorrected errors.
637  * 3,2,3,3 = Group stored with corrected errors on B, regardless of errors on A, C, or D.
638  *
639  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 58 and 104
640  */
641 typedef union {
642  struct
643  {
644  uint8_t RDSEN : 1; //!< 1 = RDS Processing Enable.
645  uint8_t DUMMY1 : 7;
646  uint8_t BLETHD : 2; //!< Block Error Threshold BLOCKD
647  uint8_t BLETHC : 2; //!< Block Error Threshold BLOCKC.
648  uint8_t BLETHB : 2; //!< Block Error Threshold BLOCKB.
649  uint8_t BLETHA : 2; //!< Block Error Threshold BLOCKA.
650  } arg;
652 } si47x_rds_config;
653 
654 /**
655  * @ingroup group02
656  *
657  * @brief Block A data type
658  */
659 typedef union {
660  struct
661  {
662  uint16_t pi;
663  } refined;
664  struct
665  {
666  uint8_t highValue; // Most Significant uint8_t first
667  uint8_t lowValue;
668  } raw;
669 } si47x_rds_blocka;
670 
671 /**
672  * @ingroup group02
673  *
674  * @brief Block B data type
675  *
676  * @details For GCC on System-V ABI on 386-compatible (32-bit processors), the following stands:
677  *
678  * 1) Bit-fields are allocated from right to left (least to most significant).
679  * 2) A bit-field must entirely reside in a storage unit appropriate for its declared type.
680  * Thus a bit-field never crosses its unit boundary.
681  * 3) Bit-fields may share a storage unit with other struct/union members, including members that are not bit-fields.
682  * Of course, struct members occupy different parts of the storage unit.
683  * 4) Unnamed bit-fields' types do not affect the alignment of a structure or union, although individual
684  * bit-fields' member offsets obey the alignment constraints.
685  *
686  * @see also Si47XX PROGRAMMING GUIDE; AN332; pages 78 and 79
687  * @see also https://en.wikipedia.org/wiki/Radio_Data_System
688  */
689 typedef union {
690  struct
691  {
692  uint16_t address : 2; // Depends on Group Type and Version codes. If 0A or 0B it is the Text Segment Address.
693  uint16_t DI : 1; // Decoder Controll bit
694  uint16_t MS : 1; // Music/Speech
695  uint16_t TA : 1; // Traffic Announcement
696  uint16_t programType : 5; // PTY (Program Type) code
697  uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
698  uint16_t versionCode : 1; // (B0) => 0=A; 1=B
699  uint16_t groupType : 4; // Group Type code.
700  } group0;
701  struct
702  {
703  uint16_t address : 4; // Depends on Group Type and Version codes. If 2A or 2B it is the Text Segment Address.
704  uint16_t textABFlag : 1; // Do something if it chanhes from binary "0" to binary "1" or vice-versa
705  uint16_t programType : 5; // PTY (Program Type) code
706  uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
707  uint16_t versionCode : 1; // (B0) => 0=A; 1=B
708  uint16_t groupType : 4; // Group Type code.
709  } group2;
710  struct
711  {
712  uint16_t content : 4; // Depends on Group Type and Version codes.
713  uint16_t textABFlag : 1; // Do something if it chanhes from binary "0" to binary "1" or vice-versa
714  uint16_t programType : 5; // PTY (Program Type) code
715  uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
716  uint16_t versionCode : 1; // (B0) => 0=A; 1=B
717  uint16_t groupType : 4; // Group Type code.
718  } refined;
719  struct
720  {
721  uint8_t lowValue;
722  uint8_t highValue; // Most Significant byte first
723  } raw;
724 } si47x_rds_blockb;
725 
726 /*
727  *
728  *
729  * Group type 4A ( RDS Date and Time)
730  * When group type 4A is used by the station, it shall be transmitted every minute according to EN 50067.
731  * This Structure uses blocks 2,3 and 5 (B,C,D)
732  *
733  * Commented due to “Crosses boundary” on GCC 32-bit plataform.
734  */
735 /*
736 typedef union {
737  struct
738  {
739  uint32_t offset : 5; // Local Time Offset
740  uint32_t offset_sense : 1; // Local Offset Sign ( 0 = + , 1 = - )
741  uint32_t minute : 6; // UTC Minutes
742  uint32_t hour : 5; // UTC Hours
743  uint32_t mjd : 17; // Modified Julian Day Code
744  } refined;
745  uint8_t raw[6];
746 } si47x_rds_date_time;
747 */
748 
749 /**
750  * @ingroup group02
751  *
752  * Group type 4A ( RDS Date and Time)
753  * When group type 4A is used by the station, it shall be transmitted every minute according to EN 50067.
754  * This Structure uses blocks 2,3 and 5 (B,C,D)
755  *
756  * ATTENTION:
757  * To make it compatible with 8, 16 and 32 bits platforms and avoid Crosses boundary, it was necessary to
758  * split minute and hour representation.
759  */
760 typedef union {
761  struct
762  {
763  uint8_t offset : 5; // Local Time Offset
764  uint8_t offset_sense : 1; // Local Offset Sign ( 0 = + , 1 = - )
765  uint8_t minute1 : 2; // UTC Minutes - 2 bits less significant (void “Crosses boundary”).
766  uint8_t minute2 : 4; // UTC Minutes - 4 bits more significant (void “Crosses boundary”)
767  uint8_t hour1 : 4; // UTC Hours - 4 bits less significant (void “Crosses boundary”)
768  uint8_t hour2 : 1; // UTC Hours - 4 bits more significant (void “Crosses boundary”)
769  uint32_t mjd : 17; // Modified Julian Day Code
770  } refined;
772 } si47x_rds_date_time;
773 
774 /** @defgroup group03 Receiver Status and Setup */
775 /** @section group03 Receiver Status and Setup */
776 
777 /**
778  * @ingroup group03
779  *
780  * AGC data types
781  * FM / AM and SSB structure to AGC
782  *
783  * @see Si47XX PROGRAMMING GUIDE; AN332; For FM page 80; for AM page 142
784  * @see AN332 REV 0.8 Universal Programming Guide Amendment for SI4735-D60 SSB and NBFM patches; page 18.
785  */
786 typedef union {
787  struct
788  {
789  // status ("RESP0")
790  uint8_t STCINT : 1;
791  uint8_t DUMMY1 : 1;
792  uint8_t RDSINT : 1; // Not used for AM/SSB
793  uint8_t RSQINT : 1;
794  uint8_t DUMMY2 : 2;
795  uint8_t ERR : 1;
796  uint8_t CTS : 1;
797  // RESP1
798  uint8_t AGCDIS : 1; // This bit indicates if the AGC is enabled or disabled. 0 = AGC enabled; 1 = AGC disabled.
799  uint8_t DUMMY : 7;
800  // RESP2
801  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.
802  } refined;
804 } si47x_agc_status;
805 
806 /**
807  * @ingroup group03
808  *
809  * If FM, Overrides AGC setting by disabling the AGC and forcing the LNA to have a certain gain that ranges between 0
810  * (minimum attenuation) and 26 (maximum attenuation).
811  * If AM, overrides the AGC setting by disabling the AGC and forcing the gain index that ranges between 0
812  *
813  * @see Si47XX PROGRAMMING GUIDE; AN332; For FM page 81; for AM page 143
814  */
815 typedef union {
816  struct
817  {
818  // ARG1
819  uint8_t AGCDIS : 1; // if set to 1 indicates if the AGC is disabled. 0 = AGC enabled; 1 = AGC disabled.
820  uint8_t DUMMY : 7;
821  // ARG2
822  uint8_t AGCIDX; // AGC Index; If AMAGCDIS = 1, this byte forces the AGC gain index; 0 = Minimum attenuation (max gain)
823  } arg;
825 } si47x_agc_overrride;
826 
827 /**
828  * @ingroup group03
829  *
830  * The bandwidth of the AM channel filter data type
831  * AMCHFLT values: 0 = 6 kHz Bandwidth
832  * 1 = 4 kHz Bandwidth
833  * 2 = 3 kHz Bandwidth
834  * 3 = 2 kHz Bandwidth
835  * 4 = 1 kHz Bandwidth
836  * 5 = 1.8 kHz Bandwidth
837  * 6 = 2.5 kHz Bandwidth, gradual roll off
838  * 7–15 = Reserved (Do not use)
839  *
840  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 125 and 151
841  */
842 typedef union {
843  struct
844  {
845  uint8_t AMCHFLT : 4; //!< Selects the bandwidth of the AM channel filter.
846  uint8_t DUMMY1 : 4;
847  uint8_t AMPLFLT : 1; //!< Enables the AM Power Line Noise Rejection Filter.
848  uint8_t DUMMY2 : 7;
849  } param;
851 } si47x_bandwidth_config; // AM_CHANNEL_FILTER
852 
853 /**
854  * @ingroup group03
855  *
856  * SSB - datatype for SSB_MODE (property 0x0101)
857  *
858  * @see AN332 REV 0.8 UNIVERSAL PROGRAMMING GUIDE; page 24
859  */
860 typedef union {
861  struct
862  {
863  uint8_t AUDIOBW : 4; //!< 0 = 1.2KHz (default); 1=2.2KHz; 2=3KHz; 3=4KHz; 4=500Hz; 5=1KHz
864  uint8_t SBCUTFLT : 4; //!< SSB side band cutoff filter for band passand low pass filter
865  uint8_t AVC_DIVIDER : 4; //!< set 0 for SSB mode; set 3 for SYNC mode;
866  uint8_t AVCEN : 1; //!< SSB Automatic Volume Control (AVC) enable; 0=disable; 1=enable (default);
867  uint8_t SMUTESEL : 1; //!< SSB Soft-mute Based on RSSI or SNR
868  uint8_t DUMMY1 : 1; //!< Always write 0;
869  uint8_t DSP_AFCDIS : 1; //!< 0=SYNC MODE, AFC enable; 1=SSB MODE, AFC disable.
870  } param;
872 } si47x_ssb_mode;
873 
874 /**
875  * @ingroup group03
876  *
877  * @brief Digital audio output format data structure (Property 0x0102. DIGITAL_OUTPUT_FORMAT).
878  *
879  * @details Used to configure: DCLK edge, data format, force mono, and sample precision.
880  *
881  * @see Si47XX PROGRAMMING GUIDE; AN332; page 195.
882  */
883 typedef union {
884  struct
885  {
886  uint8_t OSIZE : 2; //!< Digital Output Audio Sample Precision (0=16 bits, 1=20 bits, 2=24 bits, 3=8bits).
887  uint8_t OMONO : 1; //!< Digital Output Mono Mode (0=Use mono/stereo blend ).
888  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).
889  uint8_t OFALL : 1; //!< Digital Output DCLK Edge (0 = use DCLK rising edge, 1 = use DCLK falling edge)
890  uint8_t dummy : 8; //!< Always 0.
891  } refined;
893 } si4735_digital_output_format;
894 
895 /**
896  * @ingroup group03
897  *
898  * @brief Digital audio output sample structure (Property 0x0104. DIGITAL_OUTPUT_SAMPLE_RATE).
899  *
900  * @details Used to enable digital audio output and to configure the digital audio output sample rate in samples per second (sps).
901  *
902  * @see Si47XX PROGRAMMING GUIDE; AN332; page 196.
903  */
904 typedef struct
905 {
906  uint16_t DOSR; // Digital Output Sample Rate(32–48 ksps .0 to disable digital audio output).
907 } si4735_digital_output_sample_rate; // Maybe not necessary
908 
909 volatile static bool data_from_si4735; /** @ingroup group04 store the interrupt status */
910 
911 /**
912  * @brief Interrupt Function
913  *
914  * @details this function just set the volatile static bool data_from_si4735 to true;
915  *
916  * If you are using interrupt feature, this function will be called by the system, not by you.
917  * If you are not using interrupt feature, please, ignore the compile message:
918  * "warning: 'void interrupt_hundler()' defined but not used [-Wunused-function]"
919  */
920 static void interrupt_hundler()
921 {
922  data_from_si4735 = true;
923 };
924 
925 /**********************************************************************
926  * SI4735 Class definition
927  **********************************************************************/
928 
929 /**
930  * @brief SI4735 Class
931  *
932  * @details This class implements all functions to help you to control the Si47XX devices.
933  * This library was built based on “Si47XX PROGRAMMING GUIDE; AN332 ”.
934  * It also can be used on all members of the SI473X family respecting, of course, the features available
935  * for each IC version. These functionalities can be seen in the comparison matrix shown in
936  * table 1 (Product Family Function); pages 2 and 3 of the programming guide.
937  *
938  * @author PU2CLR - Ricardo Lima Caratti
939  */
940 class SI4735
941 {
942 protected:
943  char rds_buffer2A[65]; //!< RDS Radio Text buffer - Program Information
944  char rds_buffer2B[33]; //!< RDS Radio Text buffer - Station Informaation
945  char rds_buffer0A[9]; //!< RDS Basic tuning and switching information (Type 0 groups)
946  char rds_time[20]; //!< RDS date time received information
947 
948  int rdsTextAdress2A; //!< rds_buffer2A current position
949  int rdsTextAdress2B; //!< rds_buffer2B current position
950  int rdsTextAdress0A; //!< rds_buffer0A current position
951 
952  int16_t deviceAddress = SI473X_ADDR_SEN_LOW; //!< current I2C buss address
953 
954  uint16_t maxDelaySetFrequency = MAX_DELAY_AFTER_SET_FREQUENCY; // Max delay (ms) after set frequency command
955  uint16_t maxDelayAfterPouwerUp = MAX_DELAY_AFTER_POWERUP; // Max delay you have to setup after a power up command.
956 
958  uint8_t resetPin; //!< pin used on Arduino Board to RESET the Si47XX device
959  uint8_t interruptPin; //!< pin used on Arduino Board to control interrupt. If -1, interrupt is no used.
960 
961  uint8_t currentTune; //!< tell the current tune (FM, AM or SSB)
962 
963  uint16_t currentMinimumFrequency; //!< minimum frequency of the current band
964  uint16_t currentMaximumFrequency; //!< maximum frequency of the current band
965  uint16_t currentWorkFrequency; //!< current frequency
966 
967  uint16_t currentStep; //!< current steps
968 
969  uint8_t lastMode = -1; //!< Store the last mode used.
970 
971  uint8_t currentAvcAmMaxGain = 48; //!< Automatic Volume Control Gain for AM - Default 48
972 
973  si47x_frequency currentFrequency; //!< data structure to get current frequency
974  si47x_set_frequency currentFrequencyParams;
975  si47x_rqs_status currentRqsStatus; //!< current Radio SIgnal Quality status
976  si47x_response_status currentStatus; //!< current device status
977  si47x_firmware_information firmwareInfo; //!< firmware information
978  si47x_rds_status currentRdsStatus; //!< current RDS status
979  si47x_agc_status currentAgcStatus; //!< current AGC status
980  si47x_ssb_mode currentSSBMode; //!< indicates if USB or LSB
981 
982  si473x_powerup powerUp;
983 
985 
986  uint8_t currentAudioMode = SI473X_ANALOG_AUDIO; //!< current audio mode used (ANALOG or DIGITAL or both)
988 
989 
990  bool controlMcu = false;
994 
995 
996 
997  void waitInterrupr(void);
998  si47x_status getInterruptStatus();
999 
1000  void setGpioCtl(uint8_t GPO1OEN, uint8_t GPO2OEN, uint8_t GPO3OEN);
1001  void setGpio(uint8_t GPO1LEVEL, uint8_t GPO2LEVEL, uint8_t GPO3LEVEL);
1002  void setGpioIen(uint8_t STCIEN, uint8_t RSQIEN, uint8_t ERRIEN, uint8_t CTSIEN, uint8_t STCREP, uint8_t RSQREP);
1003 
1004  void sendProperty(uint16_t propertyNumber, uint16_t param);
1005 
1006  void sendSSBModeProperty();
1007  void disableFmDebug();
1008  void clearRdsBuffer2A();
1009  void clearRdsBuffer2B();
1010  void clearRdsBuffer0A();
1011 
1012 public:
1013  SI4735();
1014  void reset(void);
1015  void waitToSend(void);
1016 
1017  void setup(uint8_t resetPin, uint8_t defaultFunction);
1018  void setup(uint8_t resetPin, int interruptPin, uint8_t defaultFunction, uint8_t audioMode = SI473X_ANALOG_AUDIO);
1019 
1021 
1022  /**
1023  * @ingroup group10 Generic get property
1024  *
1025  * @brief Sets the a given Property
1026  *
1027  * @details Sets the Si47XX device with a given attribute.
1028  * @details You might need to use the bit operations or some bit field structure to set right the values.
1029  *
1030  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 55, 69, 124 and 134.
1031  * @param propertyNumber
1032  * @param param pamameter value
1033  */
1034  inline void setProperty(uint16_t propertyNumber, uint16_t param) {
1035  sendProperty(propertyNumber, param);
1036  };
1037 
1038 
1039  void setPowerUp(uint8_t CTSIEN, uint8_t GPO2OEN, uint8_t PATCH, uint8_t XOSCEN, uint8_t FUNC, uint8_t OPMODE);
1040  void radioPowerUp(void);
1041  void analogPowerUp(void);
1042  void powerDown(void);
1043 
1044  void setFrequency(uint16_t);
1045 
1046  void getStatus(uint8_t, uint8_t);
1047 
1048  uint16_t getFrequency(void);
1049 
1050  /**
1051  * STATUS RESPONSE
1052  * Set of methods to get current status information. Call them after getStatus or getFrequency or seekStation
1053  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 63
1054  */
1055 
1056  /**
1057  * @brief Get the Signal Quality Interrupt status
1058  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 63
1059  * @return RDSINT status
1060  */
1062  {
1063  return currentStatus.resp.RSQINT;
1064  };
1065 
1066  /**
1067  * @brief Get the Radio Data System (RDS) Interrupt status
1068  * @see Si47XX PROGRAMMING GUIDE; AN332; page 63
1069  * @return RDSINT status
1070  */
1072  {
1073  return currentStatus.resp.RDSINT;
1074  };
1075 
1076  /**
1077  * @brief Get the Tune Complete status
1078  * @details Seek/Tune Complete Interrupt; 1 = Tune complete has been triggered.
1079  * @return STCINT status
1080  */
1082  {
1083  return currentStatus.resp.STCINT;
1084  };
1085 
1086  /**
1087  * @brief Get the Status Error
1088  * @details Return the Error flag (true or false) of status of the least Tune or Seek
1089  * @return Error flag
1090  */
1091  inline bool getStatusError()
1092  {
1093  return currentStatus.resp.ERR;
1094  };
1095 
1096  /**
1097  * @brief Gets the Error flag Clear to Send
1098  *
1099  * @return CTS
1100  */
1101  inline bool getStatusCTS() { return currentStatus.resp.CTS; };
1102 
1103  /**
1104  * @brief Returns true if the AFC rails (AFC Rail Indicator).
1105  *
1106  * @return true
1107  */
1108  inline bool getACFIndicator()
1109  {
1110  return currentStatus.resp.AFCRL;
1111  };
1112 
1113  /**
1114  * @brief Returns true if a seek hit the band limit
1115  *
1116  * @details (WRAP = 0 in FM_START_SEEK) or wrapped to the original frequency(WRAP = 1).
1117  *
1118  * @return BLTF
1119  */
1120  inline bool getBandLimit()
1121  {
1122  return currentStatus.resp.BLTF;
1123  };
1124 
1125  /**
1126  * @brief Gets the channel status
1127  *
1128  * @details Returns true if the channel is currently valid as determined by the seek/tune properties (0x1403, 0x1404, 0x1108)
1129  *
1130  * @return true
1131  * @return false
1132  */
1133  inline bool getStatusValid()
1134  {
1135  return currentStatus.resp.VALID;
1136  };
1137 
1138  /**
1139  * @brief Returns the value of Received Signal Strength Indicator (dBμV).
1140  *
1141  * @return uint8_t
1142  */
1144  {
1145  return currentStatus.resp.RSSI;
1146  };
1147 
1148  /**
1149  * @brief Gets the SNR metric when tune is complete (dB)
1150  *
1151  * @details Returns the value of the SNR metric when tune is complete (dB).
1152  *
1153  * @return uint8_t
1154  */
1156  {
1157  return currentStatus.resp.SNR;
1158  };
1159 
1160  /**
1161  * @brief Get the Status the M U L T
1162  *
1163  * @details Returns the value containing the multipath metric when tune is complete.
1164  *
1165  * @return uint8_t
1166  */
1168  {
1169  return currentStatus.resp.MULT;
1170  };
1171 
1172  /**
1173  * @brief Get the Antenna Tuning Capacitor value
1174  *
1175  * @details Returns the current antenna tuning capacitor value.
1176  *
1177  * @return uint8_t capacitance
1178  */
1180  {
1181  return currentStatus.resp.READANTCAP;
1182  };
1183 
1184  void getAutomaticGainControl(); //!< Queries Automatic Gain Control STATUS
1185 
1186  /**
1187  * @brief Sets the Avc Am Max Gain to 48dB
1188  *
1189  */
1190  inline void setAvcAmMaxGain()
1191  {
1192  sendProperty(AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN, ((currentAvcAmMaxGain = 48) * 340));
1193  };
1194 
1195  void setAvcAmMaxGain(uint8_t gain); //!< Sets the maximum gain for automatic volume control.
1196 
1197  /**
1198  * @brief Get the current Avc Am Max Gain
1199  *
1200  * @return uint8_t Current AVC gain index value
1201  */
1203  {
1204  return currentAvcAmMaxGain;
1205  };
1206 
1207  /**
1208  * @brief Sets the Am Soft Mute Max Attenuation
1209  *
1210  * @details This function can be useful to disable Soft Mute. The value 0 disable soft mute.
1211  * @details Specified in units of dB. Default maximum attenuation is 8 dB.
1212  *
1213  * @see Si47XX PROGRAMMING GUIDE; AN332; page 158.
1214  *
1215  * @param smattn Maximum attenuation to apply when in soft mute
1216  */
1217  inline void setAmSoftMuteMaxAttenuation(uint8_t smattn = 0)
1218  {
1219  sendProperty(AM_SOFT_MUTE_MAX_ATTENUATION, smattn);
1220  };
1221 
1222  /**
1223  * @brief Sets the SSB Soft Mute Max Attenuation object
1224  *
1225  * @details Sets maximum attenuation during soft mute (dB). Set to 0 to disable soft mute.
1226  * @details Specified in units of dB. Default maximum attenuation is 8 dB.
1227  *
1228  * @param smattn Maximum attenuation to apply when in soft mute.
1229  */
1230  inline void setSsbSoftMuteMaxAttenuation(uint8_t smattn = 0)
1231  {
1232  sendProperty(SSB_SOFT_MUTE_MAX_ATTENUATION, smattn);
1233  };
1234 
1235  /**
1236  * @brief Checks if the AGC is enabled
1237  *
1238  * @return true if the AGC is enabled
1239  */
1240  inline bool isAgcEnabled()
1241  {
1242  return !currentAgcStatus.refined.AGCDIS;
1243  };
1244 
1245  /**
1246  * @brief Gets the current AGC gain index
1247  *
1248  * @return uint8_t The current AGC gain index.
1249  */
1251  {
1252  return currentAgcStatus.refined.AGCIDX;
1253  };
1254 
1255  void setAutomaticGainControl(uint8_t AGCDIS, uint8_t AGCIDX);
1256 
1257  void getCurrentReceivedSignalQuality(uint8_t INTACK);
1259 
1260  // AM and FM
1261 
1262  /**
1263  * @brief Get the current receive signal strength (0–127 dBμV)
1264  *
1265  * @return uint8_t a value between 0 to 127
1266  */
1268  {
1269  return currentRqsStatus.resp.RSSI;
1270  };
1271 
1272  /**
1273  * @brief Gets the current SNR metric (0–127 dB).
1274  *
1275  * @return uint8_t SNR value in dB (0-127)
1276  */
1278  {
1279  return currentRqsStatus.resp.SNR;
1280  };
1281 
1282  /**
1283  * @brief Checks if RSSI detected is LOW.
1284  *
1285  * @return true if RSSI is low
1286  */
1288  {
1289  return currentRqsStatus.resp.RSSIILINT;
1290  };
1291 
1292  /**
1293  * @brief Checks if RSSI detected is high
1294  *
1295  * @return true if RSSI detected is high
1296  */
1298  {
1299  return currentRqsStatus.resp.RSSIHINT;
1300  };
1301 
1302  /**
1303  * @brief Checks if SNR detect is low
1304  *
1305  * @return true if SNR detected is low
1306  */
1308  {
1309  return currentRqsStatus.resp.SNRLINT;
1310  };
1311 
1312  /**
1313  * @brief Checks if SNR detect is high
1314  *
1315  * @return true if SNR detect is high
1316  */
1318  {
1319  return currentRqsStatus.resp.SNRHINT;
1320  };
1321 
1322  /**
1323  * @brief Checks if the current channel is valid
1324  *
1325  * @return true if the current channel is valid
1326  */
1328  {
1329  return currentRqsStatus.resp.VALID;
1330  };
1331 
1332  /**
1333  * @brief AFC Rail Indicator
1334  *
1335  * @return true or false
1336  */
1338  {
1339  return currentRqsStatus.resp.AFCRL;
1340  };
1341 
1342  /**
1343  * @brief Soft Mute Indicator.
1344  *
1345  * @details Indicates soft mute is engaged.
1346  *
1347  * @return true if soft mute indicates is engaged.
1348  */
1350  {
1351  return currentRqsStatus.resp.SMUTE;
1352  };
1353 
1354  // Just FM
1355 
1356  /**
1357  * @brief Gets the value of the amount of stereo blend in % (100 = full stereo, 0 = full mono).
1358  *
1359  * @return uint8_t value (0 to 100)
1360  */
1362  {
1363  return currentRqsStatus.resp.STBLEND;
1364  };
1365 
1366  /**
1367  * @brief Checks the current pilot
1368  *
1369  * @details Indicates stereo pilot presence.
1370  *
1371  * @return true if stereo pilot presence has detected
1372  */
1373  inline bool getCurrentPilot()
1374  {
1375  return currentRqsStatus.resp.PILOT;
1376  };
1377 
1378  /**
1379  * @brief Gets the current Multipath
1380  *
1381  * @details Contains the current multipath metric. (0 = no multipath; 100 = full multipath)
1382  *
1383  * @return uint8_t value (0 to 100)
1384  */
1386  {
1387  return currentRqsStatus.resp.MULT;
1388  };
1389 
1390  inline uint8_t getCurrentSignedFrequencyOffset() { return currentRqsStatus.resp.FREQOFF; }; //!< Signed frequency offset (kHz).
1391  inline bool getCurrentMultipathDetectLow() { return currentRqsStatus.resp.MULTLINT; }; //!< Multipath Detect Low.
1392  inline bool getCurrentMultipathDetectHigh() { return currentRqsStatus.resp.MULTHINT; }; //!< Multipath Detect High
1393  inline bool getCurrentBlendDetectInterrupt() { return currentRqsStatus.resp.BLENDINT; }; //!< Blend Detect Interrupt
1394 
1395  /*
1396  * FIRMWARE RESPONSE
1397  *
1398  * See Si47XX PROGRAMMING GUIDE; AN332; page 66
1399  */
1400 
1401  inline uint8_t getFirmwarePN() { return firmwareInfo.resp.PN; }; //!< RESP1 - Part Number (HEX)
1402  inline uint8_t getFirmwareFWMAJOR() { return firmwareInfo.resp.FWMAJOR; }; //!< RESP2 - Returns the Firmware Major Revision (ASCII).
1403  inline uint8_t getFirmwareFWMINOR() { return firmwareInfo.resp.FWMINOR; }; //!< RESP3 - Returns the Firmware Minor Revision (ASCII).
1404  inline uint8_t getFirmwarePATCHH() { return firmwareInfo.resp.PATCHH; }; //!< RESP4 - Returns the Patch ID High byte (HEX).
1405  inline uint8_t getFirmwarePATCHL() { return firmwareInfo.resp.PATCHL; }; //!< RESP5 - Returns the Patch ID Low byte (HEX).
1406  inline uint8_t getFirmwareCMPMAJOR() { return firmwareInfo.resp.CMPMAJOR; }; //!< RESP6 - Returns the Component Major Revision (ASCII).
1407  inline uint8_t getFirmwareCMPMINOR() { return firmwareInfo.resp.CMPMINOR; }; //!< RESP7 - Returns the Component Minor Revision (ASCII).
1408  inline uint8_t getFirmwareCHIPREV() { return firmwareInfo.resp.CHIPREV; }; //!< RESP8 - Returns the Chip Revision (ASCII).
1409 
1410  void setVolume(uint8_t volume);
1411  uint8_t getVolume();
1412  void volumeDown();
1413  void volumeUp();
1414  inline uint8_t getCurrentVolume() { return volume; }; //!< Returns the current volume level.
1415 
1416  /**
1417  * @ingroup group13 Digital Audio setup
1418  * @brief Sets the Audio Mode. See table below.
1419  * @details If you want to change the audio mode, call this function before call setAM(), setFM() or setSSB().
1420  * @details Sets the Si47XX device to use ANALOG or DIGITAL audio output. The table below show the valid values.
1421  * @details This function will only take effect after calling setAM(), setFM() or setSSB().
1422  *
1423  *
1424  * | Macro | Value (Binary) | Description |
1425  * | ----- | ----- | ----------- |
1426  * | SI473X_ANALOG_AUDIO | 0b00000101 | Analog Audio Inputs |
1427  * | SI473X_DIGITAL_AUDIO1 | 0b00001011 | Digital audio output (DCLK, LOUT/DFS, ROUT/DIO) |
1428  * | SI473X_DIGITAL_AUDIO2 | 0b10110000 | Digital audio outputs (DCLK, DFS, DIO) |
1429  * | SI473X_DIGITAL_AUDIO3 | 0b10110101 | Analog and digital audio outputs (LOUT/ROUT and DCLK, DFS,DIO) |
1430  *
1431  * @see setAM(), setFM(), setSSB().
1432  * @param audioMode One of the values options above
1433  */
1434  inline void setAudioMode(uint8_t audioMode) {
1435  currentAudioMode = audioMode;
1436  };
1437 
1438 
1439  void digitalOutputFormat(uint8_t OSIZE, uint8_t OMONO, uint8_t OMODE, uint8_t OFALL);
1440  void digitalOutputSampleRate(uint16_t DOSR);
1441 
1442  void setAudioMute(bool off); // if true mute the audio; else unmute
1443 
1444  void setAM();
1445  void setFM();
1446  void setAM(uint16_t fromFreq, uint16_t toFreq, uint16_t intialFreq, uint16_t step);
1447  void setFM(uint16_t fromFreq, uint16_t toFreq, uint16_t initialFreq, uint16_t step);
1448 
1449  void setBandwidth(uint8_t AMCHFLT, uint8_t AMPLFLT);
1450 
1451  inline uint8_t getTuneFrequencyFast() { return currentFrequencyParams.arg.FAST; }; //!< Returns the FAST tuning status
1452  inline void setTuneFrequencyFast(uint8_t FAST) { currentFrequencyParams.arg.FAST = FAST; }; //!< FAST Tuning. If set, executes fast and invalidated tune. The tune status will not be accurate
1453  inline uint8_t getTuneFrequencyFreeze() { return currentFrequencyParams.arg.FREEZE; }; //!< Returns the FREEZE status
1454  inline void setTuneFrequencyFreeze(uint8_t FREEZE) { currentFrequencyParams.arg.FREEZE = FREEZE; }; //!< Only FM. Freeze Metrics During Alternate Frequency Jump.
1455  void setTuneFrequencyAntennaCapacitor(uint16_t capacitor);
1456 
1457  void frequencyUp();
1458  void frequencyDown();
1459  bool isCurrentTuneFM();
1460  bool isCurrentTuneAM();
1461  bool isCurrentTuneSSB();
1462 
1463  void getFirmware(void);
1464 
1465  void seekStation(uint8_t SEEKUP, uint8_t WRAP);
1466  void seekStationUp();
1467  void seekStationDown();
1468  void setSeekAmLimits(uint16_t bottom, uint16_t top);
1469  void setSeekAmSpacing(uint16_t spacing);
1470  void setSeekSrnThreshold(uint16_t value);
1471  void setSeekRssiThreshold(uint16_t value);
1472 
1473  void setFmBlendStereoThreshold(uint8_t parameter);
1474  void setFmBlendMonoThreshold(uint8_t parameter);
1475  void setFmBlendRssiStereoThreshold(uint8_t parameter);
1476  void setFmBLendRssiMonoThreshold(uint8_t parameter);
1477  void setFmBlendSnrStereoThreshold(uint8_t parameter);
1478  void setFmBLendSnrMonoThreshold(uint8_t parameter);
1479  void setFmBlendMultiPathStereoThreshold(uint8_t parameter);
1480  void setFmBlendMultiPathMonoThreshold(uint8_t parameter);
1481  void setFmStereoOn();
1482  void setFmStereoOff();
1483 
1484  void RdsInit();
1485  void setRdsIntSource(uint8_t RDSNEWBLOCKB, uint8_t RDSNEWBLOCKA, uint8_t RDSSYNCFOUND, uint8_t RDSSYNCLOST, uint8_t RDSRECV);
1486  void getRdsStatus(uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY);
1487  void getRdsStatus();
1488 
1489  /**
1490  * @brief Get the Rds Received FIFO
1491  * @details if FIFO is 1, it means the minimum number of groups was filled
1492  * @return true if minimum number of groups was filled.
1493  */
1494  inline bool getRdsReceived()
1495  {
1496  return currentRdsStatus.resp.RDSRECV;
1497  };
1498 
1499  /**
1500  * @brief Get the Rds Sync Lost object
1501  * @details returns true (1) if Lost RDS synchronization is detected.
1502  * @return true if Lost RDS synchronization detected.
1503  */
1504  inline bool getRdsSyncLost()
1505  {
1506  return currentRdsStatus.resp.RDSSYNCLOST;
1507  };
1508 
1509  /**
1510  * @brief Get the Rds Sync Found
1511  * @details return true if found RDS synchronization
1512  * @return true if found RDS synchronization
1513  */
1514  inline bool getRdsSyncFound()
1515  {
1516  return currentRdsStatus.resp.RDSSYNCFOUND;
1517  };
1518 
1519  /**
1520  * @brief Get the Rds New Block A
1521  *
1522  * @details Returns true if valid Block A data has been received.
1523  * @return true or false
1524  */
1525  inline bool getRdsNewBlockA()
1526  {
1527  return currentRdsStatus.resp.RDSNEWBLOCKA;
1528  };
1529 
1530  /**
1531  * @brief Get the Rds New Block B
1532  * @details Returns true if valid Block B data has been received.
1533  * @return true or false
1534  */
1535  inline bool getRdsNewBlockB()
1536  {
1537  return currentRdsStatus.resp.RDSNEWBLOCKB;
1538  };
1539 
1540  /**
1541  * @brief Get the Rds Sync
1542  * @details Returns true if RDS currently synchronized.
1543  * @return true or false
1544  */
1545  inline bool getRdsSync()
1546  {
1547  return currentRdsStatus.resp.RDSSYNC;
1548  };
1549 
1550  /**
1551  * @brief Get the Group Lost
1552  * @details Returns true if one or more RDS groups discarded due to FIFO overrun.
1553  * @return true or false
1554  */
1555  inline bool getGroupLost()
1556  {
1557  return currentRdsStatus.resp.GRPLOST;
1558  };
1559 
1560  /**
1561  * @brief Get the Num Rds Fifo Used
1562  * @details Return the number of RDS FIFO used
1563  * @return uint8_t Total RDS FIFO used
1564  */
1566  {
1567  return currentRdsStatus.resp.RDSFIFOUSED;
1568  };
1569 
1570  void setRdsConfig(uint8_t RDSEN, uint8_t BLETHA, uint8_t BLETHB, uint8_t BLETHC, uint8_t BLETHD);
1571  uint16_t getRdsPI(void);
1572  uint8_t getRdsGroupType(void);
1573  uint8_t getRdsFlagAB(void);
1574  uint8_t getRdsVersionCode(void);
1575  uint8_t getRdsProgramType(void);
1577 
1578  char *getRdsText(void);
1579  char *getRdsText0A(void); // Gets the Station name
1580  char *getRdsText2A(void); // Gets the Radio Text
1581  char *getRdsText2B(void);
1582 
1583  char *getRdsTime(void);
1584 
1585  void getNext2Block(char *);
1586  void getNext4Block(char *);
1587 
1588  void ssbSetup();
1589  void setSSBBfo(int offset);
1590  void setSSBConfig(uint8_t AUDIOBW, uint8_t SBCUTFLT, uint8_t AVC_DIVIDER, uint8_t AVCEN, uint8_t SMUTESEL, uint8_t DSP_AFCDIS);
1591  void setSSB(uint16_t fromFreq, uint16_t toFreq, uint16_t intialFreq, uint16_t step, uint8_t usblsb);
1592  void setSSB(uint8_t usblsb);
1593  void setSSBAudioBandwidth(uint8_t AUDIOBW);
1594  void setSSBAutomaticVolumeControl(uint8_t AVCEN);
1595  void setSBBSidebandCutoffFilter(uint8_t SBCUTFLT);
1596  void setSSBAvcDivider(uint8_t AVC_DIVIDER);
1597  void setSSBDspAfc(uint8_t DSP_AFCDIS);
1598  void setSSBSoftMute(uint8_t SMUTESEL);
1599 
1600  si47x_firmware_query_library queryLibraryId();
1601  void patchPowerUp();
1602  bool downloadPatch(const uint8_t *ssb_patch_content, const uint16_t ssb_patch_content_size);
1603  bool downloadPatch(int eeprom_i2c_address);
1604  void ssbPowerUp();
1605 
1606  /**
1607  * @ingroup group06 Si47XX device Power Up
1608  * @brief Set the Max Delay Power Up
1609  * @details Sets the delay needed in ms after a powerup command (default is 10ms).
1610  * @details Some external crystal might need more time to become stable (500 ms is the recommended).
1611  * @details Low values make the load SSB patch faster. However, it can make the system unstable.
1612  *
1613  * @see MAX_DELAY_AFTER_POWERUP
1614  * @param ms delay in ms
1615  */
1616  inline void setMaxDelayPowerUp(uint16_t ms)
1617  {
1618  this->maxDelayAfterPouwerUp = ms;
1619  }
1620 
1621  /**
1622  * @ingroup group08 Tune Frequency
1623  * @brief Set the Max Delay after Set Frequency
1624  *
1625  * @details After the set frequency command, the system need a time to get ready to the next set frequency (default value 30ms).
1626  * @details Why the waitToSend() does not work in this case? No idea for while!
1627  * @details A low value makes the getFrequency command inaccurate.
1628  *
1629  * @see MAX_DELAY_AFTER_POWERUP
1630  * @param ms
1631  */
1632  inline void setMaxDelaySetFrequency(uint16_t ms)
1633  {
1634  this->maxDelaySetFrequency = ms;
1635  }
1636 
1637  /**
1638  * @ingroup group08 Tune Frequency step
1639  *
1640  * @brief Sets the current step value.
1641  *
1642  * @details This function does not check the limits of the current band. Please, don't take a step bigger than your legs.
1643  * @details Example:
1644  * @code
1645  * setFM(6400,10800,10390,10);
1646  * setFrequencyStep(100); // the step will be 1MHz (you are using FM mode)
1647  * .
1648  * .
1649  * .
1650  * setAM(7000,7600,7100,5);
1651  * setFrequencyStep(1); // the step will be 1KHz (you are usin AM or SSB mode)
1652  * @endcode
1653  *
1654  * @see setFM()
1655  * @see setAM()
1656  * @see setSSB()
1657  *
1658  * @param step if you are using FM, 10 means 100KHz. If you are using AM 10 means 10KHz
1659  * For AM, 1 (1KHz) to 1000 (1MHz) are valid values.
1660  * For FM 5 (50KHz), 10 (100KHz) and 100 (1MHz) are valid values.
1661  */
1662  inline void setFrequencyStep(uint16_t step)
1663  {
1664  this->currentStep = step;
1665  }
1666 
1667  /**
1668  * @ingroup group14 Frequency
1669  *
1670  * @brief Gets the current frequency saved in memory.
1671  *
1672  * @details Unlike getFrequency, this method gets the current frequency recorded after the last setFrequency command.
1673  * @details This method avoids bus traffic and CI processing.
1674  * @details However, you can not get others status information like RSSI.
1675  *
1676  * @see getFrequency()
1677  */
1679  {
1680  return this->currentWorkFrequency;
1681  }
1682 
1683  /**
1684  * @ingroup group14 Si47XX device Status
1685  *
1686  * @brief Gets the current status of the Si47XX (AM, FM or SSB)
1687  *
1688  * @see Si47XX PROGRAMMING GUIDE; AN332; pages 73 (FM) and 139 (AM)
1689  */
1690  inline void getStatus()
1691  {
1692  getStatus(0, 1);
1693  }
1694 
1695 
1696  void setDeviceI2CAddress(uint8_t senPin);
1698  void setDeviceOtherI2CAddress(uint8_t i2cAddr);
1699 
1700 
1701 
1702  /*******************************************************************************
1703  * The functions below modify the clock frequency for I2C communication.
1704  * 100KHz is usually the baseline.
1705  * Use one of these funcition if you have problem on you default configuration.
1706  *******************************************************************************/
1707 
1708  /**
1709  * @ingroup group18 MCU I2C Speed
1710  * @brief Sets I2C buss to 10KHz
1711  */
1712  inline void setI2CLowSpeedMode(void)
1713  {
1714  Wire.setClock(10000);
1715  };
1716 
1717  /**
1718  * @ingroup group18 MCU I2C Speed
1719  *
1720  * @brief Sets I2C buss to 100KHz
1721  */
1722  inline void setI2CStandardMode(void) { Wire.setClock(100000); };
1723 
1724  /**
1725  * @ingroup group18 MCU I2C Speed
1726  *
1727  * @brief Sets I2C buss to 400KHz
1728  */
1729  inline void setI2CFastMode(void)
1730  {
1731  Wire.setClock(400000);
1732  };
1733 
1734  /**
1735  * @ingroup group18 MCU I2C Speed
1736  *
1737  * @brief Sets the I2C bus to a given value.
1738  *
1739  * ATTENTION: use this function with cation
1740  *
1741  * @param value in Hz. For example: The values 500000 sets the bus to 500KHz.
1742  */
1743  inline void setI2CFastModeCustom(long value = 500000) { Wire.setClock(value); };
1744 
1745  // MCU control. Virtual
1746  virtual void setMcuControl(bool value);
1747  virtual void setMcuWakeUpPin(uint8_t pin);
1748  virtual void mcuWakeUp();
1749  virtual void mcuSleepDown();
1750  virtual void setMcuClockSpeed(uint32_t clock);
1751 
1752  // void setAudioMuteMcuPin(uint8_t pin);
1753  // void setHardwareAudioMute(bool on);
1754 
1755  /**
1756  * @ingroup group18 MCU External Audio Mute
1757  *
1758  * @brief Sets the Audio Mute Mcu Pin
1759  * @details This function sets the mcu digital pin you want to use to control the external audio mute circuit.
1760  * @details Some users may be uncomfortable with the loud popping of the speaker during some transitions caused by some SI47XX commands.
1761  * @details This problem occurs during the transition from the power down to power up.
1762  * @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.
1763  * @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.
1764  *
1765  * @see setHardwareAudioMute
1766  * @param pin if 0 ou greater sets the MCU digital pin will be used to control de external circuit.
1767  */
1768  inline void setAudioMuteMcuPin(int8_t pin)
1769  {
1770  audioMuteMcuPin = pin;
1771  pinMode(audioMuteMcuPin, OUTPUT);
1772  };
1773 
1774  /**
1775  * @ingroup group18 MCU External Audio Mute
1776  *
1777  * @brief Sets the Hardware Audio Mute
1778  * @details Turns the Hardware audio mute on or off
1779  *
1780  * @see setAudioMuteMcuPin
1781  *
1782  * @param on True or false
1783  */
1784  inline void setHardwareAudioMute(bool on) {
1785  digitalWrite(audioMuteMcuPin, on);
1786  }
1787 
1788 
1789 };
SI4735::setGpioIen
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:206
SI4735::getRdsProgramType
uint8_t getRdsProgramType(void)
Returns the Program Type (extracted from the Block B)
Definition: SI4735.cpp:1956
SSB_SOFT_MUTE_MAX_ATTENUATION
#define SSB_SOFT_MUTE_MAX_ATTENUATION
Definition: SI4735.h:131
SI4735::currentSsbStatus
uint8_t currentSsbStatus
Definition: SI4735.h:987
SI4735::getCurrentSnrDetectHigh
bool getCurrentSnrDetectHigh()
Checks if SNR detect is high.
Definition: SI4735.h:1317
FM_BLEND_RSSI_STEREO_THRESHOLD
#define FM_BLEND_RSSI_STEREO_THRESHOLD
Definition: SI4735.h:55
SI4735::downloadPatch
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:2680
SI4735::currentFrequency
si47x_frequency currentFrequency
data structure to get current frequency
Definition: SI4735.h:973
SI4735::setMaxDelayPowerUp
void setMaxDelayPowerUp(uint16_t ms)
Set the Max Delay Power Up.
Definition: SI4735.h:1616
SI4735::isCurrentTuneFM
bool isCurrentTuneFM()
Returns true if the current function is FM (FM_TUNE_FREQ).
Definition: SI4735.cpp:815
FM_TUNE_STATUS
#define FM_TUNE_STATUS
Definition: SI4735.h:41
SI4735::patchPowerUp
void patchPowerUp()
This method can be used to prepare the device to apply SSBRX patch.
Definition: SI4735.cpp:2592
SI4735::interruptPin
uint8_t interruptPin
pin used on Arduino Board to control interrupt. If -1, interrupt is no used.
Definition: SI4735.h:959
SI4735::lastMode
uint8_t lastMode
Store the last mode used.
Definition: SI4735.h:969
SI4735::getAntennaTuningCapacitor
uint8_t getAntennaTuningCapacitor()
Get the Antenna Tuning Capacitor value.
Definition: SI4735.h:1179
MAX_DELAY_AFTER_SET_FREQUENCY
#define MAX_DELAY_AFTER_SET_FREQUENCY
Definition: SI4735.h:156
SI4735::mcuWakeUp
virtual void mcuWakeUp()
Sets the pin that controls some MCU features. You might do something with that.
Definition: SI4735.cpp:2851
SI4735::getAutomaticGainControl
void getAutomaticGainControl()
Queries Automatic Gain Control STATUS.
Definition: SI4735.cpp:1338
SI4735::setProperty
void setProperty(uint16_t propertyNumber, uint16_t param)
Sets the a given Property.
Definition: SI4735.h:1034
SSB_BFO
#define SSB_BFO
Definition: SI4735.h:123
SI4735::isCurrentTuneAM
bool isCurrentTuneAM()
Returns true if the current function is AM (AM_TUNE_FREQ).
Definition: SI4735.cpp:827
SI4735::setFmStereoOn
void setFmStereoOn()
Turn Off Stereo operation.
Definition: SI4735.cpp:1122
SI4735::setFmStereoOff
void setFmStereoOff()
Turn Off Stereo operation.
Definition: SI4735.cpp:1112
SI4735::rds_time
char rds_time[20]
RDS date time received information.
Definition: SI4735.h:946
SI4735::setFM
void setFM(uint16_t fromFreq, uint16_t toFreq, uint16_t initialFreq, uint16_t step)
Sets the radio to FM function.
Definition: SI4735.cpp:793
SI4735::setTuneFrequencyFast
void setTuneFrequencyFast(uint8_t FAST)
Returns the FAST tuning status.
Definition: SI4735.h:1452
SI4735::setSeekAmLimits
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:1571
POWER_UP
#define POWER_UP
Definition: SI4735.h:31
SI4735::getRdsGroupType
uint8_t getRdsGroupType(void)
Returns the Group Type (extracted from the Block B)
Definition: SI4735.cpp:1882
SI4735::getRdsText0A
char * getRdsText0A(void)
Gets the station name and other messages.
Definition: SI4735.cpp:2066
GPO_IEN
#define GPO_IEN
Definition: SI4735.h:122
SI4735::setAvcAmMaxGain
void setAvcAmMaxGain()
Sets the Avc Am Max Gain to 48dB.
Definition: SI4735.h:1190
AM_CURRENT_MODE
#define AM_CURRENT_MODE
Definition: SI4735.h:153
SI4735::getTuneFrequencyFast
uint8_t getTuneFrequencyFast()
Definition: SI4735.h:1451
SI4735::getVolume
uint8_t getVolume()
Gets the current volume level.
Definition: SI4735.cpp:1230
AM_TUNE_FREQ
#define AM_TUNE_FREQ
Definition: SI4735.h:63
SI4735::rds_buffer2B
char rds_buffer2B[33]
RDS Radio Text buffer - Station Informaation.
Definition: SI4735.h:944
SI4735::getRdsSyncLost
bool getRdsSyncLost()
Get the Rds Sync Lost object.
Definition: SI4735.h:1504
SI4735::getRdsPI
uint16_t getRdsPI(void)
Returns the programa type.
Definition: SI4735.cpp:1866
FM_AGC_STATUS
#define FM_AGC_STATUS
Definition: SI4735.h:42
SI4735::currentStatus
si47x_response_status currentStatus
current device status
Definition: SI4735.h:976
SI4735::setGpio
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:169
SI4735::currentAvcAmMaxGain
uint8_t currentAvcAmMaxGain
Automatic Volume Control Gain for AM - Default 48.
Definition: SI4735.h:971
SI4735::seekStation
void seekStation(uint8_t SEEKUP, uint8_t WRAP)
Look for a station (Automatic tune)
Definition: SI4735.cpp:1503
SI4735::getGroupLost
bool getGroupLost()
Get the Group Lost.
Definition: SI4735.h:1555
SI4735::getAgcGainIndex
uint8_t getAgcGainIndex()
Gets the current AGC gain index.
Definition: SI4735.h:1250
SI4735::setup
void setup(uint8_t resetPin, int interruptPin, uint8_t defaultFunction, uint8_t audioMode=SI473X_ANALOG_AUDIO)
Starts the Si473X device.
Definition: SI4735.cpp:504
SI4735::setMcuWakeUpPin
virtual void setMcuWakeUpPin(uint8_t pin)
Sets pin used to wake the MCU up.
Definition: SI4735.cpp:2836
SI4735::setSsbSoftMuteMaxAttenuation
void setSsbSoftMuteMaxAttenuation(uint8_t smattn=0)
Sets the SSB Soft Mute Max Attenuation object.
Definition: SI4735.h:1230
SI4735::setI2CFastModeCustom
void setI2CFastModeCustom(long value=500000)
Sets the I2C bus to a given value.
Definition: SI4735.h:1743
FM_RDS_STATUS
#define FM_RDS_STATUS
Definition: SI4735.h:45
SI4735::getStatus
void getStatus()
Gets the current status of the Si47XX (AM, FM or SSB)
Definition: SI4735.h:1690
si47x_set_frequency::raw
uint8_t raw[5]
Definition: SI4735.h:293
SI4735::currentRqsStatus
si47x_rqs_status currentRqsStatus
current Radio SIgnal Quality status
Definition: SI4735.h:975
AM_AGC_OVERRIDE
#define AM_AGC_OVERRIDE
Definition: SI4735.h:68
SI4735::radioPowerUp
void radioPowerUp(void)
Powerup the Si47XX.
Definition: SI4735.cpp:406
SI4735::isAgcEnabled
bool isAgcEnabled()
Checks if the AGC is enabled.
Definition: SI4735.h:1240
SI4735::setFM
void setFM()
Sets the radio to FM function.
Definition: SI4735.cpp:724
SI4735::getRdsNewBlockA
bool getRdsNewBlockA()
Get the Rds New Block A.
Definition: SI4735.h:1525
si47x_tune_status::raw
uint8_t raw
Definition: SI4735.h:460
SI4735::setVolume
void setVolume(uint8_t volume)
RESP8 - Returns the Chip Revision (ASCII).
Definition: SI4735.cpp:1200
SI4735::getRdsTextSegmentAddress
uint8_t getRdsTextSegmentAddress(void)
Returns the address of the text segment.
Definition: SI4735.cpp:1921
si47x_rds_command::raw
uint8_t raw
Definition: SI4735.h:545
si47x_status::raw
uint8_t raw
Definition: SI4735.h:332
SI4735::setAudioMuteMcuPin
void setAudioMuteMcuPin(int8_t pin)
Sets the Audio Mute Mcu Pin.
Definition: SI4735.h:1768
SI4735::downloadPatch
bool downloadPatch(int eeprom_i2c_address)
Transfers the content of a patch stored in a eeprom to the SI4735 device.
Definition: SI4735.cpp:2742
si47x_ssb_mode::raw
uint8_t raw[2]
Definition: SI4735.h:871
SI4735::ssbSetup
void ssbSetup()
Starts the Si473X device on SSB (same AM Mode).
Definition: SI4735.cpp:2610
SI4735::getCurrentSoftMuteIndicator
bool getCurrentSoftMuteIndicator()
Soft Mute Indicator.
Definition: SI4735.h:1349
SI4735::controlMcu
bool controlMcu
Definition: SI4735.h:990
SI4735::getFirmwareFWMINOR
uint8_t getFirmwareFWMINOR()
RESP2 - Returns the Firmware Major Revision (ASCII).
Definition: SI4735.h:1403
SI4735::getCurrentMultipath
uint8_t getCurrentMultipath()
Gets the current Multipath.
Definition: SI4735.h:1385
SI4735::waitToSend
void waitToSend(void)
Wait for the si473x is ready (Clear to Send (CTS) status bit have to be 1).
Definition: SI4735.cpp:331
SI4735::getInterruptStatus
si47x_status getInterruptStatus()
Updates bits 6:0 of the status byte.
Definition: SI4735.cpp:93
FM_BLEND_SNR_MONO_THRESHOLD
#define FM_BLEND_SNR_MONO_THRESHOLD
Definition: SI4735.h:58
SI4735::setFmBlendRssiStereoThreshold
void setFmBlendRssiStereoThreshold(uint8_t parameter)
Sets RSSI threshold for stereo blend. (Full stereo above threshold, blend below threshold....
Definition: SI4735.cpp:1022
SI4735::setDeviceOtherI2CAddress
void setDeviceOtherI2CAddress(uint8_t i2cAddr)
Sets the onther I2C Bus Address (for Si470X)
Definition: SI4735.cpp:295
si47x_bandwidth_config::raw
uint8_t raw[2]
Definition: SI4735.h:850
SI4735::digitalOutputFormat
void digitalOutputFormat(uint8_t OSIZE, uint8_t OMONO, uint8_t OMODE, uint8_t OFALL)
Configures the digital audio output format.
Definition: SI4735.cpp:1166
SI4735::getCurrentBlendDetectInterrupt
bool getCurrentBlendDetectInterrupt()
Multipath Detect High.
Definition: SI4735.h:1393
FM_BLEND_RSSI_MONO_THRESHOLD
#define FM_BLEND_RSSI_MONO_THRESHOLD
Definition: SI4735.h:56
FM_CURRENT_MODE
#define FM_CURRENT_MODE
Definition: SI4735.h:152
si47x_rqs_status::raw
uint8_t raw[8]
Definition: SI4735.h:526
SI4735::frequencyUp
void frequencyUp()
Increments the current frequency on current band/function by using the current step.
Definition: SI4735.cpp:659
SI4735::currentRdsStatus
si47x_rds_status currentRdsStatus
current RDS status
Definition: SI4735.h:978
SI4735::getCurrentSignedFrequencyOffset
uint8_t getCurrentSignedFrequencyOffset()
Definition: SI4735.h:1390
SI4735::currentSSBMode
si47x_ssb_mode currentSSBMode
indicates if USB or LSB
Definition: SI4735.h:980
SI4735::audioMuteMcuPin
int8_t audioMuteMcuPin
Definition: SI4735.h:992
GPIO_SET
#define GPIO_SET
Definition: SI4735.h:70
SI4735::setTuneFrequencyAntennaCapacitor
void setTuneFrequencyAntennaCapacitor(uint16_t capacitor)
Only FM. Freeze Metrics During Alternate Frequency Jump.
Definition: SI4735.cpp:583
AM_SEEK_BAND_BOTTOM
#define AM_SEEK_BAND_BOTTOM
Definition: SI4735.h:102
SI4735::getRdsFlagAB
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B
Definition: SI4735.cpp:1899
SI4735::getCurrentReceivedSignalQuality
void getCurrentReceivedSignalQuality(uint8_t INTACK)
Queries the status of the Received Signal Quality (RSQ) of the current channel.
Definition: SI4735.cpp:1439
SI4735::getCurrentAfcRailIndicator
bool getCurrentAfcRailIndicator()
AFC Rail Indicator.
Definition: SI4735.h:1337
si47x_frequency::value
uint16_t value
frequency (integer value)
Definition: SI4735.h:258
SI4735::getRdsNewBlockB
bool getRdsNewBlockB()
Get the Rds New Block B.
Definition: SI4735.h:1535
SI4735::setSSBSoftMute
void setSSBSoftMute(uint8_t SMUTESEL)
Sets SSB Soft-mute Based on RSSI or SNR Selection:
Definition: SI4735.cpp:2353
SI4735::deviceAddress
int16_t deviceAddress
current I2C buss address
Definition: SI4735.h:952
SI4735::setMaxDelaySetFrequency
void setMaxDelaySetFrequency(uint16_t ms)
Set the Max Delay after Set Frequency.
Definition: SI4735.h:1632
SI4735::setSSBConfig
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:2313
SSB_TUNE_FREQ
#define SSB_TUNE_FREQ
Definition: SI4735.h:74
DIGITAL_OUTPUT_SAMPLE_RATE
#define DIGITAL_OUTPUT_SAMPLE_RATE
Definition: SI4735.h:83
SI4735::setAM
void setAM()
Sets the radio to AM function. It means: LW MW and SW.
Definition: SI4735.cpp:698
SI4735::getFirmwarePN
uint8_t getFirmwarePN()
Blend Detect Interrupt.
Definition: SI4735.h:1401
SI4735::ssbPowerUp
void ssbPowerUp()
This function can be useful for debug and test.
Definition: SI4735.cpp:2622
MAX_DELAY_AFTER_POWERUP
#define MAX_DELAY_AFTER_POWERUP
Definition: SI4735.h:157
SI4735::setFrequencyStep
void setFrequencyStep(uint16_t step)
Sets the current step value.
Definition: SI4735.h:1662
SI4735::clearRdsBuffer2A
void clearRdsBuffer2A()
Clear RDS buffer 2A (text)
Definition: SI4735.cpp:1648
SI4735::seekStationUp
void seekStationUp()
Search for the next station.
Definition: SI4735.cpp:1540
SI4735::getCurrentRssiDetectLow
bool getCurrentRssiDetectLow()
Checks if RSSI detected is LOW.
Definition: SI4735.h:1287
SI4735::setTuneFrequencyFreeze
void setTuneFrequencyFreeze(uint8_t FREEZE)
Returns the FREEZE status.
Definition: SI4735.h:1454
FM_BLEND_STEREO_THRESHOLD
#define FM_BLEND_STEREO_THRESHOLD
Definition: SI4735.h:53
SI4735::getFirmwareCMPMAJOR
uint8_t getFirmwareCMPMAJOR()
RESP5 - Returns the Patch ID Low byte (HEX).
Definition: SI4735.h:1406
si4735_digital_output_format::raw
uint16_t raw
Definition: SI4735.h:892
SI4735::setFmBlendMonoThreshold
void setFmBlendMonoThreshold(uint8_t parameter)
Sets RSSI threshold for mono blend (Full mono below threshold, blend above threshold).
Definition: SI4735.cpp:1006
SI4735::currentMinimumFrequency
uint16_t currentMinimumFrequency
minimum frequency of the current band
Definition: SI4735.h:963
SI4735::getTuneCompleteTriggered
bool getTuneCompleteTriggered()
Get the Tune Complete status.
Definition: SI4735.h:1081
SI4735::setMcuClockSpeed
virtual void setMcuClockSpeed(uint32_t clock)
Sets the Mcu Clock Speed if the platform supports this resource.
Definition: SI4735.cpp:2881
SI4735::volume
uint8_t volume
Definition: SI4735.h:984
SI4735::volumeDown
void volumeDown()
Set sound volume level Down
Definition: SI4735.cpp:1256
SI4735::setFmBlendMultiPathStereoThreshold
void setFmBlendMultiPathStereoThreshold(uint8_t parameter)
Sets multipath threshold for stereo blend (Full stereo below threshold, blend above threshold).
Definition: SI4735.cpp:1086
SI4735::getCurrentAvcAmMaxGain
uint8_t getCurrentAvcAmMaxGain()
Get the current Avc Am Max Gain.
Definition: SI4735.h:1202
SI4735::rdsTextAdress2B
int rdsTextAdress2B
rds_buffer2B current position
Definition: SI4735.h:949
SI4735::rdsTextAdress2A
int rdsTextAdress2A
rds_buffer2A current position
Definition: SI4735.h:948
SI4735::SI4735
SI4735()
Construct a new SI4735::SI4735.
Definition: SI4735.cpp:58
si473x_powerup::raw
uint8_t raw[2]
Raw powerup parameters data. Same arg memory position. So, same content.
Definition: SI4735.h:194
SI4735::getRdsTime
char * getRdsTime(void)
Gets the RDS time and date when the Group type is 4.
Definition: SI4735.cpp:2165
FM_RDS_INT_SOURCE
#define FM_RDS_INT_SOURCE
Definition: SI4735.h:48
SI4735::getStatusCTS
bool getStatusCTS()
Gets the Error flag Clear to Send.
Definition: SI4735.h:1101
si473x_gpio::raw
uint8_t raw
Definition: SI4735.h:215
SI473X_ADDR_SEN_LOW
#define SI473X_ADDR_SEN_LOW
Definition: SI4735.h:28
SI4735::setAM
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:755
AM_SEEK_FREQ_SPACING
#define AM_SEEK_FREQ_SPACING
Definition: SI4735.h:104
SI4735::maxDelayAfterPouwerUp
uint16_t maxDelayAfterPouwerUp
Definition: SI4735.h:955
SI4735::setSSBAudioBandwidth
void setSSBAudioBandwidth(uint8_t AUDIOBW)
SSB Audio Bandwidth for SSB mode.
Definition: SI4735.cpp:2432
SI4735::currentFrequencyParams
si47x_set_frequency currentFrequencyParams
Definition: SI4735.h:974
SI4735::setSBBSidebandCutoffFilter
void setSBBSidebandCutoffFilter(uint8_t SBCUTFLT)
Sets SBB Sideband Cutoff Filter for band pass and low pass filters.
Definition: SI4735.cpp:2402
DIGITAL_OUTPUT_FORMAT
#define DIGITAL_OUTPUT_FORMAT
Definition: SI4735.h:82
SI4735::setFmBLendSnrMonoThreshold
void setFmBLendSnrMonoThreshold(uint8_t parameter)
Sets SNR threshold for mono blend (Full mono below threshold, blend above threshold).
Definition: SI4735.cpp:1070
SI4735::getRdsText2A
char * getRdsText2A(void)
Gets the Text processed for the 2A group.
Definition: SI4735.cpp:2099
SI4735::setRdsConfig
void setRdsConfig(uint8_t RDSEN, uint8_t BLETHA, uint8_t BLETHB, uint8_t BLETHC, uint8_t BLETHD)
Sets RDS property.
Definition: SI4735.cpp:1711
SI4735::setFmBlendSnrStereoThreshold
void setFmBlendSnrStereoThreshold(uint8_t parameter)
Sets SNR threshold for stereo blend (Full stereo above threshold, blend below threshold).
Definition: SI4735.cpp:1054
SI4735::waitInterrupr
void waitInterrupr(void)
Interrupt handle.
Definition: SI4735.cpp:72
SI4735::getCurrentReceivedSignalQuality
void getCurrentReceivedSignalQuality(void)
Queries the status of the Received Signal Quality (RSQ) of the current channel (FM_RSQ_STATUS)
Definition: SI4735.cpp:1486
SI4735::setSeekRssiThreshold
void setSeekRssiThreshold(uint16_t value)
Sets the RSSI threshold for a valid AM Seek/Tune.
Definition: SI4735.cpp:1614
SI4735::setSeekSrnThreshold
void setSeekSrnThreshold(uint16_t value)
Sets the SNR threshold for a valid AM Seek/Tune.
Definition: SI4735.cpp:1600
SI4735
SI4735 Class.
Definition: SI4735.h:940
SI4735::resetPin
uint8_t resetPin
pin used on Arduino Board to RESET the Si47XX device
Definition: SI4735.h:958
SI4735::setI2CFastMode
void setI2CFastMode(void)
Sets I2C buss to 400KHz.
Definition: SI4735.h:1729
AM_TUNE_STATUS
#define AM_TUNE_STATUS
Definition: SI4735.h:65
SI4735::setup
void setup(uint8_t resetPin, uint8_t defaultFunction)
Starts the Si473X device.
Definition: SI4735.cpp:554
SI4735::setSSB
void setSSB(uint8_t usblsb)
Set the radio to AM function.
Definition: SI4735.cpp:2455
SI4735::setAmSoftMuteMaxAttenuation
void setAmSoftMuteMaxAttenuation(uint8_t smattn=0)
Sets the Am Soft Mute Max Attenuation.
Definition: SI4735.h:1217
si47x_seek::raw
uint8_t raw
Definition: SI4735.h:311
SI473X_ADDR_SEN_HIGH
#define SI473X_ADDR_SEN_HIGH
Definition: SI4735.h:29
SI4735::getDeviceI2CAddress
int16_t getDeviceI2CAddress(uint8_t resetPin)
I2C bus address setup.
Definition: SI4735.cpp:236
SI4735::setBandwidth
void setBandwidth(uint8_t AMCHFLT, uint8_t AMPLFLT)
Selects the bandwidth of the channel filter for AM reception.
Definition: SI4735.cpp:865
SI4735::getReceivedSignalStrengthIndicator
uint8_t getReceivedSignalStrengthIndicator()
Returns the value of Received Signal Strength Indicator (dBμV).
Definition: SI4735.h:1143
SI4735::setI2CStandardMode
void setI2CStandardMode(void)
Sets I2C buss to 100KHz.
Definition: SI4735.h:1722
SI4735::mcuSleepDown
virtual void mcuSleepDown()
You might want to do something when MCU wakes up.
Definition: SI4735.cpp:2866
SI4735::isCurrentTuneSSB
bool isCurrentTuneSSB()
Returns true if the current function is SSB (SSB_TUNE_FREQ).
Definition: SI4735.cpp:839
SI4735::getRadioDataSystemInterrupt
bool getRadioDataSystemInterrupt()
Get the Radio Data System (RDS) Interrupt status.
Definition: SI4735.h:1071
SI4735::getBandLimit
bool getBandLimit()
Returns true if a seek hit the band limit.
Definition: SI4735.h:1120
SI4735::setAudioMode
void setAudioMode(uint8_t audioMode)
Returns the current volume level.
Definition: SI4735.h:1434
SI4735::getNext4Block
void getNext4Block(char *)
Process data received from group 2A.
Definition: SI4735.cpp:2007
SI4735::controlMcuClock
uint32_t controlMcuClock
Definition: SI4735.h:993
SI4735::setSSB
void setSSB(uint16_t fromFreq, uint16_t toFreq, uint16_t intialFreq, uint16_t step, uint8_t usblsb)
Definition: SI4735.cpp:2487
AM_SEEK_START
#define AM_SEEK_START
Definition: SI4735.h:64
si47x_antenna_capacitor::value
uint16_t value
Definition: SI4735.h:271
SI4735::getCurrentStereoBlend
uint8_t getCurrentStereoBlend()
Gets the value of the amount of stereo blend in % (100 = full stereo, 0 = full mono).
Definition: SI4735.h:1361
SI4735::setSSBAutomaticVolumeControl
void setSSBAutomaticVolumeControl(uint8_t AVCEN)
Sets SSB Automatic Volume Control (AVC) for SSB mode.
Definition: SI4735.cpp:2368
SI4735::rds_buffer2A
char rds_buffer2A[65]
RDS Radio Text buffer - Program Information.
Definition: SI4735.h:943
SI4735::reset
void reset(void)
Reset the SI473X
Definition: SI4735.cpp:309
SI4735::getCurrentMultipathDetectLow
bool getCurrentMultipathDetectLow()
Signed frequency offset (kHz).
Definition: SI4735.h:1391
RX_HARD_MUTE
#define RX_HARD_MUTE
Definition: SI4735.h:117
SI4735::queryLibraryId
si47x_firmware_query_library queryLibraryId()
Query the library information of the Si47XX device.
Definition: SI4735.cpp:2551
SI4735::getTuneFrequencyFreeze
uint8_t getTuneFrequencyFreeze()
FAST Tuning. If set, executes fast and invalidated tune. The tune status will not be accurate.
Definition: SI4735.h:1453
SI4735::getCurrentRSSI
uint8_t getCurrentRSSI()
Get the current receive signal strength (0–127 dBμV)
Definition: SI4735.h:1267
SET_PROPERTY
#define SET_PROPERTY
Definition: SI4735.h:34
SI4735::getRdsVersionCode
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
Definition: SI4735.cpp:1937
SI4735::getCurrentFrequency
uint16_t getCurrentFrequency()
Gets the current frequency saved in memory.
Definition: SI4735.h:1678
FM_BLEND_SNR_STEREO_THRESHOLD
#define FM_BLEND_SNR_STEREO_THRESHOLD
Definition: SI4735.h:57
SI4735::getCurrentMultipathDetectHigh
bool getCurrentMultipathDetectHigh()
Multipath Detect Low.
Definition: SI4735.h:1392
SI4735::getRdsText2B
char * getRdsText2B(void)
Gets the Text processed for the 2B group.
Definition: SI4735.cpp:2132
SI4735::getRdsStatus
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:1799
GET_PROPERTY
#define GET_PROPERTY
Definition: SI4735.h:35
SI4735::maxDelaySetFrequency
uint16_t maxDelaySetFrequency
Definition: SI4735.h:954
FM_BLEND_MONO_THRESHOLD
#define FM_BLEND_MONO_THRESHOLD
Definition: SI4735.h:54
FM_TUNE_FREQ
#define FM_TUNE_FREQ
Definition: SI4735.h:39
SI4735::setGpioCtl
void setGpioCtl(uint8_t GPO1OEN, uint8_t GPO2OEN, uint8_t GPO3OEN)
Enables output for GPO1, 2, and 3.
Definition: SI4735.cpp:130
SI4735::sendProperty
void sendProperty(uint16_t propertyNumber, uint16_t param)
Sends (sets) property to the SI47XX.
Definition: SI4735.cpp:913
SSB_MODE
#define SSB_MODE
Definition: SI4735.h:124
SI4735::clearRdsBuffer2B
void clearRdsBuffer2B()
Clear RDS buffer 2B (text)
Definition: SI4735.cpp:1660
SI4735::getStatusSNR
uint8_t getStatusSNR()
Gets the SNR metric when tune is complete (dB)
Definition: SI4735.h:1155
AM_AGC_STATUS
#define AM_AGC_STATUS
Definition: SI4735.h:67
SI4735::clearRdsBuffer0A
void clearRdsBuffer0A()
Clear RDS buffer 0A (text)
Definition: SI4735.cpp:1671
SI4735::currentAgcStatus
si47x_agc_status currentAgcStatus
current AGC status
Definition: SI4735.h:979
SI4735::getRdsSync
bool getRdsSync()
Get the Rds Sync.
Definition: SI4735.h:1545
SI4735::getFrequency
uint16_t getFrequency(void)
Gets the current frequency of the Si4735 (AM or FM)
Definition: SI4735.cpp:1278
SI4735::setDeviceI2CAddress
void setDeviceI2CAddress(uint8_t senPin)
Sets the I2C Bus Address.
Definition: SI4735.cpp:281
SI4735::currentTune
uint8_t currentTune
tell the current tune (FM, AM or SSB)
Definition: SI4735.h:961
SI4735::setFmBlendMultiPathMonoThreshold
void setFmBlendMultiPathMonoThreshold(uint8_t parameter)
Sets Multipath threshold for mono blend (Full mono above threshold, blend below threshold).
Definition: SI4735.cpp:1102
si47x_agc_overrride::raw
uint8_t raw[2]
Definition: SI4735.h:824
si47x_rds_date_time::raw
uint8_t raw[6]
Definition: SI4735.h:771
AM_SEEK_BAND_TOP
#define AM_SEEK_BAND_TOP
Definition: SI4735.h:103
SI4735::getNumRdsFifoUsed
uint8_t getNumRdsFifoUsed()
Get the Num Rds Fifo Used.
Definition: SI4735.h:1565
si47x_response_status::raw
uint8_t raw[8]
Check it.
Definition: SI4735.h:373
GET_REV
#define GET_REV
Definition: SI4735.h:32
SI4735::getFirmwarePATCHH
uint8_t getFirmwarePATCHH()
RESP3 - Returns the Firmware Minor Revision (ASCII).
Definition: SI4735.h:1404
AM_SOFT_MUTE_MAX_ATTENUATION
#define AM_SOFT_MUTE_MAX_ATTENUATION
Definition: SI4735.h:98
SI4735::setAudioMute
void setAudioMute(bool off)
Sets the audio on or off.
Definition: SI4735.cpp:1215
SI4735::analogPowerUp
void analogPowerUp(void)
You have to call setPowerUp method before.
Definition: SI4735.cpp:434
SI4735::RdsInit
void RdsInit()
Starts the control member variables for RDS.
Definition: SI4735.cpp:1634
SI4735::powerDown
void powerDown(void)
Moves the device from powerup to powerdown mode.
Definition: SI4735.cpp:449
SI4735::setMcuControl
virtual void setMcuControl(bool value)
Enables MCU control resource.
Definition: SI4735.cpp:2821
si47x_firmware_information::raw
uint8_t raw[9]
Definition: SI4735.h:406
SI4735::getStatusError
bool getStatusError()
Get the Status Error.
Definition: SI4735.h:1091
si4735_digital_output_sample_rate::DOSR
uint16_t DOSR
Definition: SI4735.h:906
si47x_rds_config::raw
uint8_t raw[2]
Definition: SI4735.h:651
SI4735::disableFmDebug
void disableFmDebug()
There is a debug feature that remains active in Si4704/05/3x-D60 firmware which can create periodic n...
Definition: SI4735.cpp:1137
SI4735::currentStep
uint16_t currentStep
current steps
Definition: SI4735.h:967
si47x_firmware_query_library::raw
uint8_t raw[8]
Definition: SI4735.h:441
SI4735::lastTextFlagAB
uint8_t lastTextFlagAB
Definition: SI4735.h:957
SI4735::getCurrentValidChannel
bool getCurrentValidChannel()
Checks if the current channel is valid.
Definition: SI4735.h:1327
SI4735::currentAudioMode
uint8_t currentAudioMode
current audio mode used (ANALOG or DIGITAL or both)
Definition: SI4735.h:986
SI4735::getCurrentSnrDetectLow
bool getCurrentSnrDetectLow()
Checks if SNR detect is low.
Definition: SI4735.h:1307
SI4735::getCurrentPilot
bool getCurrentPilot()
Checks the current pilot.
Definition: SI4735.h:1373
SI4735::setAvcAmMaxGain
void setAvcAmMaxGain(uint8_t gain)
Sets the maximum gain for automatic volume control.
Definition: SI4735.cpp:1417
SI4735::getACFIndicator
bool getACFIndicator()
Returns true if the AFC rails (AFC Rail Indicator).
Definition: SI4735.h:1108
SI4735::setFmBLendRssiMonoThreshold
void setFmBLendRssiMonoThreshold(uint8_t parameter)
Sets RSSI threshold for mono blend (Full mono below threshold, blend above threshold).
Definition: SI4735.cpp:1038
SI4735::setRdsIntSource
void setRdsIntSource(uint8_t RDSNEWBLOCKB, uint8_t RDSNEWBLOCKA, uint8_t RDSSYNCFOUND, uint8_t RDSSYNCLOST, uint8_t RDSRECV)
Configures interrupt related to RDS.
Definition: SI4735.cpp:1757
AM_RSQ_STATUS
#define AM_RSQ_STATUS
Definition: SI4735.h:66
SI4735::getRdsReceived
bool getRdsReceived()
Get the Rds Received FIFO.
Definition: SI4735.h:1494
SI4735::powerUp
si473x_powerup powerUp
Definition: SI4735.h:982
SI4735::currentMaximumFrequency
uint16_t currentMaximumFrequency
maximum frequency of the current band
Definition: SI4735.h:964
SI4735::getRdsText
char * getRdsText(void)
Gets the RDS Text when the message is of the Group Type 2 version A.
Definition: SI4735.cpp:2042
SI4735::setAutomaticGainControl
void setAutomaticGainControl(uint8_t AGCDIS, uint8_t AGCIDX)
Automatic Gain Control setup.
Definition: SI4735.cpp:1383
FM_RSQ_STATUS
#define FM_RSQ_STATUS
Definition: SI4735.h:44
SI4735::rdsTextAdress0A
int rdsTextAdress0A
rds_buffer0A current position
Definition: SI4735.h:950
SI4735::seekStationDown
void seekStationDown()
Search the previous station.
Definition: SI4735.cpp:1554
SI4735::getRdsSyncFound
bool getRdsSyncFound()
Get the Rds Sync Found.
Definition: SI4735.h:1514
FM_AGC_OVERRIDE
#define FM_AGC_OVERRIDE
Definition: SI4735.h:43
SI4735::getCurrentSNR
uint8_t getCurrentSNR()
Gets the current SNR metric (0–127 dB).
Definition: SI4735.h:1277
si47x_property::value
uint16_t value
Definition: SI4735.h:476
SI4735::getFirmwareFWMAJOR
uint8_t getFirmwareFWMAJOR()
RESP1 - Part Number (HEX)
Definition: SI4735.h:1402
SI4735::getSignalQualityInterrupt
bool getSignalQualityInterrupt()
Get the Signal Quality Interrupt status.
Definition: SI4735.h:1061
FM_BLEND_MULTIPATH_MONO_THRESHOLD
#define FM_BLEND_MULTIPATH_MONO_THRESHOLD
Definition: SI4735.h:60
FM_SEEK_START
#define FM_SEEK_START
Definition: SI4735.h:40
SI4735::getStatusValid
bool getStatusValid()
Gets the channel status.
Definition: SI4735.h:1133
SI4735::getRdsStatus
void getRdsStatus()
Gets RDS Status.
Definition: SI4735.cpp:1848
SI4735::setHardwareAudioMute
void setHardwareAudioMute(bool on)
Sets the Hardware Audio Mute.
Definition: SI4735.h:1784
SI4735::volumeUp
void volumeUp()
Set sound volume level Up
Definition: SI4735.cpp:1242
SI4735::setI2CLowSpeedMode
void setI2CLowSpeedMode(void)
Sets I2C buss to 10KHz.
Definition: SI4735.h:1712
si473x_gpio_ien::raw
uint16_t raw
Definition: SI4735.h:241
SI4735::firmwareInfo
si47x_firmware_information firmwareInfo
firmware information
Definition: SI4735.h:977
SI4735::getCurrentVolume
uint8_t getCurrentVolume()
Definition: SI4735.h:1414
SI4735::digitalOutputSampleRate
void digitalOutputSampleRate(uint16_t DOSR)
Enables digital audio output and configures digital audio output sample rate in samples per second (s...
Definition: SI4735.cpp:1186
SI4735::getNext2Block
void getNext2Block(char *)
Process data received from group 2B.
Definition: SI4735.cpp:1973
si47x_rds_status::raw
uint8_t raw[13]
Definition: SI4735.h:599
SI4735::getProperty
int32_t getProperty(uint16_t propertyValue)
Gets a property from the SI47XX.
Definition: SI4735.cpp:946
SI4735::getFirmware
void getFirmware(void)
Gets firmware information.
Definition: SI4735.cpp:472
RX_VOLUME
#define RX_VOLUME
Definition: SI4735.h:116
AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN
#define AM_AUTOMATIC_VOLUME_CONTROL_MAX_GAIN
Definition: SI4735.h:88
SI4735::controlMcuPin
int8_t controlMcuPin
Definition: SI4735.h:991
MIN_DELAY_WAIT_SEND_LOOP
#define MIN_DELAY_WAIT_SEND_LOOP
Definition: SI4735.h:158
SI4735::setSSBBfo
void setSSBBfo(int offset)
Sets the SSB Beat Frequency Offset (BFO).
Definition: SI4735.cpp:2264
AM_SEEK_SNR_THRESHOLD
#define AM_SEEK_SNR_THRESHOLD
Definition: SI4735.h:105
SI4735::getFirmwarePATCHL
uint8_t getFirmwarePATCHL()
RESP4 - Returns the Patch ID High byte (HEX).
Definition: SI4735.h:1405
si47x_rds_int_source::raw
uint8_t raw[2]
Definition: SI4735.h:622
SI4735::getFirmwareCHIPREV
uint8_t getFirmwareCHIPREV()
RESP7 - Returns the Component Minor Revision (ASCII).
Definition: SI4735.h:1408
SI4735::getStatus
void getStatus(uint8_t, uint8_t)
Gets the current status of the Si4735 (AM or FM)
Definition: SI4735.cpp:1300
POWER_DOWN
#define POWER_DOWN
Definition: SI4735.h:33
SI4735::sendSSBModeProperty
void sendSSBModeProperty()
Just send the property SSB_MOD to the device. Internal use (privete method).
Definition: SI4735.cpp:2508
SI4735::setFmBlendStereoThreshold
void setFmBlendStereoThreshold(uint8_t parameter)
Sets RSSI threshold for stereo blend (Full stereo above threshold, blend below threshold).
Definition: SI4735.cpp:990
AM_CHANNEL_FILTER
#define AM_CHANNEL_FILTER
Definition: SI4735.h:87
SI473X_ANALOG_AUDIO
#define SI473X_ANALOG_AUDIO
Definition: SI4735.h:146
SI4735::setSSBDspAfc
void setSSBDspAfc(uint8_t DSP_AFCDIS)
Sets DSP AFC disable or enable.
Definition: SI4735.cpp:2338
GPIO_CTL
#define GPIO_CTL
Definition: SI4735.h:69
SI4735::frequencyDown
void frequencyDown()
Decrements the current frequency on current band/function by using the current step.
Definition: SI4735.cpp:676
SI4735::getStatusMULT
uint8_t getStatusMULT()
Get the Status the M U L T.
Definition: SI4735.h:1167
SI4735::getCurrentRssiDetectHigh
bool getCurrentRssiDetectHigh()
Checks if RSSI detected is high.
Definition: SI4735.h:1297
FM_BLEND_MULTIPATH_STEREO_THRESHOLD
#define FM_BLEND_MULTIPATH_STEREO_THRESHOLD
Definition: SI4735.h:59
SI4735::setSeekAmSpacing
void setSeekAmSpacing(uint16_t spacing)
Selects frequency spacingfor AM seek. Default is 10 kHz spacing.
Definition: SI4735.cpp:1586
SI4735::setPowerUp
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:356
GET_INT_STATUS
#define GET_INT_STATUS
Definition: SI4735.h:36
si47x_agc_status::raw
uint8_t raw[3]
Definition: SI4735.h:803
SI4735::rds_buffer0A
char rds_buffer0A[9]
RDS Basic tuning and switching information (Type 0 groups)
Definition: SI4735.h:945
SI4735::setSSBAvcDivider
void setSSBAvcDivider(uint8_t AVC_DIVIDER)
Sets AVC Divider.
Definition: SI4735.cpp:2383
AM_SEEK_RSSI_THRESHOLD
#define AM_SEEK_RSSI_THRESHOLD
Definition: SI4735.h:106
SI4735::getFirmwareCMPMINOR
uint8_t getFirmwareCMPMINOR()
RESP6 - Returns the Component Major Revision (ASCII).
Definition: SI4735.h:1407
SSB_CURRENT_MODE
#define SSB_CURRENT_MODE
Definition: SI4735.h:154
FM_RDS_CONFIG
#define FM_RDS_CONFIG
Definition: SI4735.h:50
SI4735::currentWorkFrequency
uint16_t currentWorkFrequency
current frequency
Definition: SI4735.h:965
SI4735::setFrequency
void setFrequency(uint16_t)
Set the frequency to the corrent function of the Si4735 (FM, AM or SSB)
Definition: SI4735.cpp:621