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