PU2CLR SI4844 Arduino Library 1.1.8
Arduino Library for Si4844 Devices - By Ricardo Lima Caratti
Loading...
Searching...
No Matches
SI4844.h
Go to the documentation of this file.
1/**
2 * @brief SI4844 ARDUINO LIBRARY
3 *
4 * @details This is an Arduino library for the SI4822, SI4826, SI4827, SI4840, 4844A, and 4844B, BROADCAST AM/FM/SW RADIO RECEIVER IC family from Silicon Labs.
5 * @details When appropriate, this documentation will use the acronym SI48XX to refer to the following devices: SI4822, SI4826, SI4827, SI4840, SI4844A, and SI4844B.
6 * @details In most cases, references to the SI4844 device also apply to the other aforementioned devices.
7 * @details This library is intended to provide an easier interface for controlling the SI47XX by using Arduino platform.
8 * @details The communication used by this library is I2C.
9 * @details This file contains: const (#define), Defined Data type and Methods declarations
10 * @details You can see a complete documentation on <https://github.com/pu2clr/SI4844>
11 *
12 * @see https://pu2clr.github.io/SI4844/
13 * @see Si48XX ATDD PROGRAMMING GUIDE - AN610
14 * @see BROADCAST ANALOG TUNING DIGITAL DISPLAY AM/FM/SW RADIO RECEIVER - Si4844-B20
15 * @see Si4822/26/27/40/44 A NTENNA , SCHEMATIC , LAYOUT, AND DESIGN GUIDELINES - AN602
16 * @author PU2CLR - Ricardo Lima Caratti
17 * @date 2019-2020
18 */
19
20#include <Arduino.h>
21#include <Wire.h>
22
23#define SI4844_ADDRESS 0x11
24
25// English...: Si4844 Commands
26// Portuguese: Comando usado no Si4844
27// Reference.: Si48XX ATDD PROGRAMMING GUIDE, page 12
28#define ATDD_POWER_DOWN 0x11
29#define ATDD_POWER_UP 0xE1
30#define ATDD_AUDIO_MODE 0xE2
31#define GET_REV 0x10
32#define ATDD_XOSCEN 0x80
33#define ATDD_XOWAIT 0x40
34#define ATDD_GET_STATUS 0xE0
35
36#define SET_PROPERTY 0x12
37#define GET_PROPERTY 0x13
38#define RX_VOLUME 0x4000
39#define RX_HARD_MUTE 0x4001
40#define RX_BASS_TREBLE 0x4002
41#define RX_ACTUAL_VOLUME 0x4003
42
43#define FM_SOFT_MUTE_MAX_ATTENUATION 0x1302
44#define AM_SOFT_MUTE_MAX_ATTENUATION 0x3302
45#define FM_DEEMPHASIS 0x1100 // You can use setProperty(FM_DEEMPHASIS, value);
46#define FM_SOFT_MUTE_RATE 0x1300 // You can use setProperty(FM_SOFT_MUTE_RATE, value);
47#define FM_SOFT_MUTE_SLOPE 0x1301 // You can use setProperty(FM_SOFT_MUTE_SLOPE, value);
48#define FM_STEREO_IND_BLEND_THRESHOLD 0x1207 // You can use setProperty(FM_STEREO_IND_BLEND_THRESHOLD, value);
49#define FM_BLEND_RSSI_STEREO_THRESHOLD 0x1800 // You can use setProperty(FM_BLEND_RSSI_STEREO_THRESHOLD, value);
50#define FM_BLEND_RSSI_MONO_THRESHOLD 0x1801 // You can use setProperty(FM_BLEND_RSSI_MONO_THRESHOLD, value);
51
52#define REFCLK_FREQ 0x0201 // You can use setProperty(REFCLK_FREQ, value);
53#define REFCLK_PRESCALE 0x0202 // You can use setProperty(REFCLK_PRESCALE, value);
54
55#define AM_SOFT_MUTE_RATE 0x3300
56#define AM_SOFT_MUTE_SLOPE 0x3301
57#define AM_SOFT_MUTE_SNR_THRESHOLD 0x3303
58
59
60#define DEVICE_LAST_VALID_INDEX_BAND 40
61
62/** @defgroup GA1 Union and Structures
63 * @section GA1
64 *
65 * @brief SI4844 data representation
66 *
67 * @details The goal of this approach is separating data from code.
68 * The SI4844 works with many internal data that can be represented by data structure
69 * or defined data type in C/C++.
70 */
71
72
73/**
74 * @ingroup GA1
75 * @brief Configures band parameter
76 * @details Represents searching for a valid frequency data type.
77 * @see Page 18 of the Si48XX ATDD PROGRAMMING GUIDE - AN610
78 */
79
80typedef union {
81 struct {
82 uint8_t BANDIDX:6; // Band Index to Set. See Table 8. Pre-defined Band Table
83 uint8_t XOWAIT: 1; // Crystal Oscillator Stabilization Wait Time After Reset. 0 = 600 ms; 1 = 900 ms
84 uint8_t XOSCEN: 1; // Crystal Oscillator Enable. 0 = Use external RCLK; 1 = Use crystal oscillator (XTALI and XTALO with external 32.768 kHz crystal).
85 } refined;
87} si4844_arg_band_index;
88
89/**
90 * @ingroup GA1
91 * @brief Configures all SI48XX parameters
92 * @details Represents searching for a valid frequency data type.
93 * @see Page 18 of the Si48XX ATDD PROGRAMMING GUIDE - AN610
94 */
95typedef union {
96 struct
97 {
98 uint8_t BANDIDX : 6; // Band Index to Set. See Table 8. Pre-defined Band Table
99 uint8_t XOWAIT : 1; // Crystal Oscillator Stabilization Wait Time After Reset. 0 = 600 ms; 1 = 900 ms
100 uint8_t XOSCEN : 1; // Crystal Oscillator Enable. 0 = Use external RCLK; 1 = Use crystal oscillator (XTALI and XTALO with external 32.768 kHz crystal).
101 uint8_t BANDBOT_HIGH; // Band Bottom Frequency Limit; FM 6400..10900 (64.0–109.0 MHz); AM 510..1750 (510–1750 kHz); SW 2300..28500 (2.3–28.5 MHz)
102 uint8_t BANDBOT_LOW; // Band Bottom Frequency Limit; FM 6400..10900 (64.0–109.0 MHz); AM 510..1750 (510–1750 kHz); SW 2300..28500 (2.3–28.5 MHz)
103 uint8_t BANDTOP_HIGH; // Band Top Frequency Limit; FM 6400..10900 (64.0–109.0 MHz); AM 510..1750 (510–1750 kHz); SW 2300..28500 (2.3–28.5 MHz)
104 uint8_t BANDTOP_LOW; // Band Top Frequency Limit; FM 6400..10900 (64.0–109.0 MHz); AM 510..1750 (510–1750 kHz); SW 2300..28500 (2.3–28.5 MHz)
105 uint8_t CHSPC; // Channel Spacing; FM 10 (e.g.,100 kHz); AM 9 or 10 (e.g., 9 kHz or 10 kHz); SW 5 (e.g., 5 kHz)
106 uint8_t DUMMY : 5; // Set it to 00000
107 uint8_t DFBAND : 1; // Default Band Settings; 0 = Allow host controller to override the band property settings; 1 = Force to use tuner default band property settings (Applicable to Si4827 part only)
108 uint8_t UNI_AM : 1; // Universal AM Band. 0 = Disable universal AM band (default AFC range of 1.1 kHz); 1 = Enable universal AM band (wider AFC range in tuning); Applicable to Si4827 and Si4844B parts and AMRX mode only
109 uint8_t TVFREQ : 1; // TV Audio Channel Frequency Display; 0 = Disable TV audio channel frequency display format; 1 = Enable TV audio channel frequency display format; Applicable to Si4827 and Si4844B parts and FMRX mode only
110 } refined;
112} SI4844_arg_band;
113
114/**
115 * @ingroup GA1
116 * @brief Status
117 * @details Represents searching for a valid frequency data type.
118 */
119typedef union {
120 struct
121 {
122 uint8_t D_0 : 1;
123 uint8_t D_1 : 1;
124 uint8_t D_2 : 1;
125 uint8_t D_3 : 1;
126 uint8_t D_4 : 1;
127 uint8_t ERR : 1; //!< 1 = Error.
128 uint8_t CTS : 1; //!< 0 = Wait before sending next command; 1 = Clear to send next command.
129 } refined;
131} si4844_status;
132
133/**
134 * @ingroup GA1
135 * @brief Device Status (The first byte of the device ststus register)
136 * @details The structure below represents the first byte response got by command ATDD_GET_STATUS
137 * @see PROGRAMMING GUIDE, pages 14 and 15
138 */
139typedef union {
140 struct {
141 uint8_t BCFG0 : 1; // Bit 0 - 0 = ATDD device detects band; 1 = Host detects band
142 uint8_t BCFG1 : 1; // bit 1
143 uint8_t STEREO : 1; // bit 2
144 uint8_t STATION : 1; // bit 3
145 uint8_t INFORDY : 1; // bit 4
146 uint8_t HOSTPWRUP : 1; // bit 5
147 uint8_t HOSTRST : 1; // bit 6
148 uint8_t CTS : 1; // bit 7
149 } refined;
151} si4844_device_status;
152
153/**
154 * @ingroup GA1
155 * @brief All Device Information (All Status)
156 * @details The structure below represents the four bytes response got by command ATDD_GET_STATUS
157 * @see PROGRAMMING GUIDE, pages 14 and 15
158 */
159typedef struct
160{
161 uint8_t BCFG0 : 1; // Bit 0 - 0 = ATDD device detects band; 1 = Host detects band
162 uint8_t BCFG1 : 1; // bit 1
163 uint8_t STEREO : 1; // bit 2
164 uint8_t STATION : 1; // bit 3
165 uint8_t INFORDY : 1; // bit 4
166 uint8_t HOSTPWRUP : 1; // bit 5
167 uint8_t HOSTRST : 1; // bit 6
168 uint8_t CTS : 1; // bit 7
169 uint8_t BANDIDX : 6; // Form bit 0 to 5
170 uint8_t BANDMODE : 2; // From bit 6 to 7
171 uint8_t d2 : 4; // Frequency digit 2
172 uint8_t d1 : 4; // Frequency digit 1
173 uint8_t d4 : 4; // Frequency digit 4
174 uint8_t d3 : 4; // frequency digit 3
175} si4844_get_status;
176
177typedef struct {
180} si4844_get_channel_frequency;
181
182/**
183 * @ingroup GA1
184 * @brief Status response
185 * @see See Si48XX ATDD PROGRAMMING GUIDE, pages 14 and 15
186*/
187typedef union {
188 si4844_get_status refined;
189 si4844_get_channel_frequency rawStatus;
191} si4844_status_response;
192
193/**
194 * @ingroup GA1
195 * @brief Firmware Information
196 * @see Si48XX ATDD PROGRAMMING GUIDE, page 22.
197 */
198typedef struct
199{
200 uint8_t RESERVED : 6; // Bit 0 to 5
201 uint8_t ERR : 1; // bit 6
202 uint8_t CTS : 1; // bit 2
203 uint8_t PN; // Final 2 digits of Part Number (HEX).
204 uint8_t FWMAJOR; // Firmware Major Revision (ASCII).
205 uint8_t FWMINOR; // Firmware Minor Revision (ASCII).
206 uint8_t CMPMAJOR; // Component Major Revision (ASCII).
207 uint8_t CMPMINOR; // Component Minor Revision (ASCII).
208 uint8_t CHIPREV; // Chip Revision (ASCII).
209} si4844_firmware_info;
210
211/**
212 * @brief Firmware Response
213 *
214 */
215typedef union {
216 si4844_firmware_info refined;
218} si4844_firmware_response;
219
220/**
221 * @ingroup GA1
222 * @brief Audio Mode
223 */
224typedef union {
225 struct
226 {
227 uint8_t AUDIOMODE : 2;
228 uint8_t FM_MONO : 1;
229 uint8_t ADJPT_ATTN : 1;
230 uint8_t ADJPT_STEO : 1;
231 uint8_t Reserved : 2;
232 uint8_t OPCODE : 1;
233 } arg1;
235} si4844_audiomode;
236
237/**
238 * @ingroup GA1
239 * @brief Audio Status Response
240 */
241typedef union {
242 struct {
243 uint8_t AUDIOMODE:2;
244 uint8_t FM_MONO:1;
245 uint8_t ADJPT_ATTN:1;
246 uint8_t ADJPT_STEO:1;
247 uint8_t Reserved:1;
248 uint8_t ERR:1;
249 uint8_t CTS:1;
250 } status;
252} si4844_audiomode_status_response;
253
254/**
255 * @brief Data type to deal with SET_PROPERTY command
256 *
257 * @details Property Data type (help to deal with SET_PROPERTY command on si473X)
258 */
259typedef union {
260 struct
261 {
262 uint8_t byteLow;
263 uint8_t byteHigh;
264 } raw;
266} si4844_property;
267
268/**
269 * @brief Interrupt status
270 * @details This variable must be true every time an interruption occurs and then must return to the false every time an action resulting from the interruption is performed.
271 * @details The variable below indicates a change of the ATDD status. When it occurs, it means the system needs to process some action (for example show on LCD this change).
272 * @see interrupt_hundler() function in SI44.cpp.
273 */
274volatile static bool data_from_device;
275
276
277/**
278 * @brief SI4844 Class
279 *
280 * @details This class implements all functions to help you to control the Si4844 devices.
281 */
282
284{
285
286private:
287
288 si4844_device_status device_status; // Stores the first currente status of the device
289 si4844_status_response all_receiver_status; // Stores all current receiver information
290 si4844_firmware_response firmware_response;
291 uint16_t resetPin;
292 uint16_t interruptPin;
293 uint8_t currentBand = 0;
294
295 uint8_t xoscen = 1;
296 uint8_t xowait = 0;
297 uint32_t clockSpeed = 50000;
298
299
300 uint8_t system_error = 0;
301
302
303 /**
304 * @ingroup BF
305 * @brief Sets hight clock speed to be used on I2C bus
306 * @param clock (10000 = 10kHz; 50000 = 50kHz; 100000 = 100kHz ... )
307 */
308 inline void setClockSpeed(uint16_t clock) { this->clockSpeed = clock; };
309
310 /**
311 * @ingroup BF
312 * @brief Sets I2C bus speed to 10kHz
313 */
314 inline void setClockLow(void) { Wire.setClock(10000); };
315
316 /**
317 * @ingroup BF
318 * @brief Sets I2C bus speed to hight previous defined speed
319 * @see setClockSpeed
320 */
321 inline void setClockHigh() { Wire.setClock(this->clockSpeed); };
322
323
324 inline void waitInterrupt(void);
325 inline bool isClearToSend(void);
326 inline void waitToSend(void);
327 void waitDetectFrequency();
328
329
330 // SI4844 band description (FM = 0; AM = 1; SW = 2)
331 const char *bandmode_table[3] = {"FM", "AM", "SW"};
332 const char *stereo_indicator_table[2] = {"ST","MO"};
333 char strFormattedCurrentFrequenct[8];
334
335 uint8_t volume = 30;
336 uint8_t bassTreble = 4;
337
338public :
339 /**
340 * @ingroup BF
341 * @brief Set the Data Status From Device
342 * @details It is a flag that means the device triggered an interrupt.
343 * @details You can use this function to back the flag status to false. This way you can check when the device triggers the next interrupt.
344 * @details It is very useful when the user wants to control the interrupt instead of give this control to the library.
345 * @param value true or false
346 */
347 inline void setStatusInterruptFromDevice( bool value ) { data_from_device = value; };
348
349 /**
350 * @ingroup BF
351 * @brief Get the Data Status From Device
352 * @details It returns true when the device has triggered an interrupt.
353 * @return true or false
354 */
355 inline bool getDataStatusInterruptFromDevice() { return data_from_device; };
356
357
358 void setProperty(uint16_t propertyNumber, uint16_t parameter);
360 void sendCommand(uint8_t cmd, int parameter_size, const uint8_t *parameter);
361 void getCommandResponse(int response_size, uint8_t *response);
362
363 void setupSlideSwitch(uint16_t resetPin, int interruptPin, uint32_t hightClockSpeed = 50000);
364 void setup(uint16_t resetPin, int interruptPin, int8_t defaultBand = 0, uint32_t hightClockSpeed = 50000);
365 void debugDevice(uint16_t resetPin, uint16_t interruptPin, uint8_t defaultBand, void (*showFunc)(char *msg));
366 void reset(void );
367 void setBand(uint8_t newBand = 0);
368 void setBandSlideSwitch();
369
370 void changeVolume(char); // deprecated
371 void volumeUp(void);
372 void volumeDown(void);
373 void setVolume(byte);
374 void setBassTreble(uint8_t bass_treble);
375 void bassTrebleUp();
376 void bassTrebleDown();
377 uint8_t inline getBassTreble() {return this->bassTreble;};
378 void audioMute(uint8_t value);
379 void setAudioMute(bool on);
380
381 void setAmSoftMuteMaxAttenuation(uint8_t value);
382 void setFmSoftMuteMaxAttenuation(uint8_t value);
383 void setFmDeemphasis(uint8_t value);
384 void setFmSoftMuteRate(uint8_t value);
385 void setFmSoftMuteSlope(uint8_t value);
386
387 void setAmSoftMuteRate(uint8_t value);
388 void setAmSoftMuteSlope(uint8_t value);
389 void setAmSoftMuteSnrThreshold(uint8_t value);
390
391
392 void setBlendThresholdStereoIndicator(uint16_t value);
393
394 void setCrystalOscillatorEnable(uint8_t XOSCEN );
396 void setReferenceClockFrequency(uint16_t value);
397 void setReferenceClockPrescaler(uint16_t value);
398
399
400
401 si4844_audiomode_status_response
402 setAudioMode(uint8_t audiomode, uint8_t fm_mono, uint8_t adjpt_attn, uint8_t adjpt_steo, uint8_t opcode);
403
404 si4844_device_status *getStatus();
405 si4844_status_response *getAllReceiverInfo(void);
406 si4844_firmware_response *getFirmware(void);
407
410
411
412 // customize the frequency range of a band
413 void setCustomBand(uint8_t bandIndex, uint16_t botton, uint16_t top, uint8_t bandSpace, uint8_t dfband = 0, uint8_t uni_am = 0, uint8_t tvreq = 0 );
414
415 void setDefaultBandIndx( uint8_t bandidx);
416
417 void powerDown(void);
418 void powerUp(void);
419
420 float getFrequency(void);
422 bool hasStatusChanged(void);
423 bool hasBandChanged(void);
424 void resetStatus(void);
425
426 /**
427 * @ingroup GB1
428 * @brief Gets the latest band set by the microcontroller.
429 * @details It can be used as a feature to detect if the current band has been changed via Slide
430 * @return latest band
431 */
432 uint8_t inline getCurrentBand() {return this->currentBand; };
433
434 /**
435 * @ingroup GB1
436 * @brief Gets the current audio volume level
437 *
438 * @return Volume level
439 */
440 inline uint8_t getVolume() {return volume; };
442
443 /**
444 * @ingroup GB1
445 * @brief Get the Band Mode
446 * @return char* "FM", "AM" or "SW"
447 * @see getStatusBandMode()
448 */
449 inline char * getBandMode(){ return (char *) bandmode_table[all_receiver_status.refined.BANDMODE]; };
450
451 /**
452 * @ingroup GB1
453 * @brief Get the Stereo Indicator
454 * @details **Call getStatus or getAllReceiverInfo before calling this function**
455 * @return char* "ON" or "OFF"
456 * @see getStatusStereo()
457 */
458 inline char * getStereoIndicator(){ return (char *) stereo_indicator_table[device_status.refined.STEREO]; };
459
460 /**
461 * @ingroup GB1
462 * @brief Gets Band CFG0 (Band Detection Configuration).
463 * @details 0 = ATDD device detects band; 1 = Host detects band
464 * @details **Call getStatus or getAllReceiverInfo before calling this function**
465 * @return 0 = ATDD device detects band; 1 = Host detects band
466 */
467 inline uint16_t getStatusBCFG0() { return device_status.refined.BCFG0; };
468
469 /**
470 * @ingroup GB1
471 * @brief Gets Band CFG1 (Band Properties Priority)
472 * @details **Call getStatus or getAllReceiverInfo before calling this function**
473 * @return 0 = ATDD device accepts host customized band properties; 1 = ATDD device ignores host customized band properties
474 */
475 inline uint16_t getStatusBCFG1() { return device_status.refined.BCFG1; };
476
477 /**
478 * @ingroup GB1
479 * @brief Gets Stereo indicator.
480 * @details Applicable to Si4840/44 parts FM function only (id does not make sense for Si4827).
481 * @details **Call getStatus or getAllReceiverInfo before calling this function**
482 * @return 0 = Stereo off; 1 = Stereo on
483 * @see getStereoIndicator()
484 */
485 inline uint16_t getStatusStereo() { return device_status.refined.STEREO; };
486
487
488 /**
489 * @ingroup GB1
490 * @brief Gets Station Indicator.
491 * @details **Call getStatus or getAllReceiverInfo before calling this function**
492 * @return 0 = Invalid Station; 1 = Valid Station
493 */
494 inline uint16_t getStatusStationIndicator() { return device_status.refined.STATION; };
495
496 /**
497 * @ingroup GB1
498 * @brief Gets Information Ready
499 * @details During power up case, the system controller should not display any of the channel frequency, band mode, band index,
500 * @details station, or stereo statuses until the INFORDY bit is set.
501 * @details The host controller should not display the channel frequency when CHFREQ remains zero even when INFORDY=1.
502 * @details 0 = Tune info not ready yet; 1 = Tune info ready (i.e., Band mode, band index, channel frequency, sta-tion, and stereo indicators)
503 * @details **Call getStatus or getAllReceiverInfo before calling this function**
504 * @return 0 = Tune info not ready yet; 1 = Tune info ready
505 */
506 inline uint16_t getStatusInformationReady() { return device_status.refined.INFORDY; };
507
508 /**
509 * @ingroup GB1
510 * @brief Checks Host Power Up Status
511 * @details if True, the system needs to Power Up the device
512 * @details **Call getStatus or getAllReceiverInfo before calling this function**
513 * @return True: issue the ATDD_POWER_UP command with the valid band index detected.
514 */
515 inline bool needHostPowerUp() { return device_status.refined.HOSTPWRUP; };
516
517 /**
518 * @ingroup GB1
519 * @brief Checks HOST Reset Status
520 * @details Check if the host (microcontroler) needs to reset the device.
521 * @details **Call getStatus or getAllReceiverInfo before calling this function**
522 * @return True or False.
523 */
524 inline bool needHostReset() { return device_status.refined.HOSTRST; };
525
526
527 /**
528 * @ingroup GB1
529 * @brief Gets the Channel Frequency.
530 * @details The channel frequency is a 16-bit word of 4 digits in BCD format:
531 * @details FM 0640..1090 (64.0–109.0 MHz)
532 * @details AM 0504..1750 (504–1750 kHz)
533 * @details SW4 *0230..2850 (2.3– 28.5 MHz)
534 * @details For FM band, if the China TV channel audio sub-carrier display feature is enabled, the CHFREQ bit[15] MSB = 1 means the host controller needs to add an additional 50 kHz for the channel frequency.
535 * @details For SW band, the CHFREQ bit[15] MSB = 1 means the host controller needs to add an additional 5 kHz for the channel frequency.
536 * @return 0 = Tune info not ready yet; 1 = Tune info ready
537 */
538 inline uint16_t getRawChannelFrequency() { return all_receiver_status.rawStatus.CHFREQ; };
539
540
541 /**
542 * @ingroup GB1
543 * @brief Gets the current Band Mode
544 * @return 0 = FM mode; 1 = AM mode; 2 = SW mode
545 * @see getBandMode()
546 */
547 inline uint16_t getStatusBandMode() { return all_receiver_status.refined.BANDMODE; };
548
549 /**
550 * @ingroup GB1
551 * @brief Gets the current Band Index Detected.
552 * @return 0~19: FM band; 20~24: AM band; 25~40: SW band
553 */
554 inline uint16_t getStatusBandIndex() { return all_receiver_status.refined.BANDIDX; };
555
556
557
558 inline uint16_t getStatusCTS() { return all_receiver_status.refined.CTS; };
559
560
561 inline uint16_t getFirmwareReserved() { return firmware_response.refined.RESERVED; };
562 inline uint16_t getFirmwareErr() { return firmware_response.refined.ERR; };
563 inline uint16_t getFirmwareCTS() { return firmware_response.refined.CTS; };
564 inline uint16_t getFirmwarePartNumber() { return firmware_response.refined.PN; };
565 inline uint16_t getFirmwareMajorRevision() { return firmware_response.refined.FWMAJOR; };
566 inline uint16_t getFirmwareMinorRevision() { return firmware_response.refined.FWMINOR; };
567 inline uint16_t getFirmwareComponentMajorRevision() { return firmware_response.refined.CMPMAJOR; };
568 inline uint16_t getFirmwareComponentMinorRevision() { return firmware_response.refined.CMPMINOR; };
569 inline uint16_t getFirmwareChipRevision() { return firmware_response.refined.CHIPREV; };
570
571 void setResetPin(uint16_t resetPin);
572 void setInterruptPin(int interruptPin);
573
575 bool detectDevice();
576 void convertToChar(uint32_t value, char *strValue, uint8_t len, uint8_t dot, uint8_t separator, bool remove_leading_zeros = true);
577 char* getFormattedFrequency(uint8_t removeRightDigit = 0, uint8_t thousandsSeparator = ',');
578
579};
void interrupt_hundler()
Library handle interrupt.
Definition: SI4844.cpp:38
#define FM_SOFT_MUTE_RATE
Definition: SI4844.h:46
#define AM_SOFT_MUTE_SLOPE
Definition: SI4844.h:56
uint16_t value
Definition: SI4844.h:265
#define DEVICE_LAST_VALID_INDEX_BAND
Definition: SI4844.h:60
#define AM_SOFT_MUTE_MAX_ATTENUATION
Definition: SI4844.h:44
#define FM_STEREO_IND_BLEND_THRESHOLD
Definition: SI4844.h:48
#define RX_HARD_MUTE
Definition: SI4844.h:39
#define REFCLK_PRESCALE
Definition: SI4844.h:53
#define RX_ACTUAL_VOLUME
Definition: SI4844.h:41
#define ATDD_GET_STATUS
Definition: SI4844.h:34
#define ATDD_POWER_DOWN
Definition: SI4844.h:28
si4844_firmware_info refined
Definition: SI4844.h:216
uint8_t raw[9]
Definition: SI4844.h:217
#define FM_SOFT_MUTE_MAX_ATTENUATION
Definition: SI4844.h:43
#define SET_PROPERTY
Definition: SI4844.h:36
#define GET_REV
Definition: SI4844.h:31
#define ATDD_POWER_UP
Definition: SI4844.h:29
#define FM_DEEMPHASIS
Definition: SI4844.h:45
#define AM_SOFT_MUTE_SNR_THRESHOLD
Definition: SI4844.h:57
#define AM_SOFT_MUTE_RATE
Definition: SI4844.h:55
uint16_t dummy
Definition: SI4844.h:178
#define SI4844_ADDRESS
SI4844 ARDUINO LIBRARY
Definition: SI4844.h:23
#define GET_PROPERTY
Definition: SI4844.h:37
#define REFCLK_FREQ
Definition: SI4844.h:52
#define RX_VOLUME
Definition: SI4844.h:38
#define RX_BASS_TREBLE
Definition: SI4844.h:40
uint16_t CHFREQ
Definition: SI4844.h:179
#define ATDD_AUDIO_MODE
Definition: SI4844.h:30
SI4844 Class.
Definition: SI4844.h:284
uint16_t getFirmwareComponentMajorRevision()
Definition: SI4844.h:567
uint16_t getFirmwareCTS()
Definition: SI4844.h:563
uint16_t getStatusCTS()
Definition: SI4844.h:558
uint16_t getFirmwareChipRevision()
Definition: SI4844.h:569
uint16_t getFirmwareErr()
Definition: SI4844.h:562
uint16_t getFirmwareMinorRevision()
Definition: SI4844.h:566
uint16_t getFirmwareComponentMinorRevision()
Definition: SI4844.h:568
uint16_t getFirmwareMajorRevision()
Definition: SI4844.h:565
uint16_t getFirmwarePartNumber()
Definition: SI4844.h:564
void setDefaultBandIndx(uint8_t bandidx)
Definition: SI4844.cpp:394
uint8_t getBassTreble()
Definition: SI4844.h:377
uint16_t getFirmwareReserved()
Definition: SI4844.h:561
void setStatusInterruptFromDevice(bool value)
Set the Data Status From Device.
Definition: SI4844.h:347
bool getDataStatusInterruptFromDevice()
Get the Data Status From Device.
Definition: SI4844.h:355
void sendCommand(uint8_t cmd, int parameter_size, const uint8_t *parameter)
Sends a given command to the SI4844 device.
Definition: SI4844.cpp:125
void setResetPin(uint16_t resetPin)
Sets the MCU RESET pin.
Definition: SI4844.cpp:293
void setProperty(uint16_t propertyNumber, uint16_t parameter)
Sends (sets) property to the SI48XX.
Definition: SI4844.cpp:54
void getCommandResponse(int response_size, uint8_t *response)
Returns with the command response.
Definition: SI4844.cpp:147
void setInterruptPin(int interruptPin)
Sets the MCU Interrupt pin.
Definition: SI4844.cpp:305
uint16_t getProperty(uint16_t propertyNumber)
Gets a given property from the SI4844.
Definition: SI4844.cpp:83
uint8_t raw
Definition: SI4844.h:150
uint8_t raw
Definition: SI4844.h:234
uint8_t BCFG1
Definition: SI4844.h:162
uint8_t raw
Definition: SI4844.h:130
uint8_t CHIPREV
Definition: SI4844.h:208
uint8_t CMPMINOR
Definition: SI4844.h:207
uint8_t HOSTPWRUP
Definition: SI4844.h:166
uint8_t FWMAJOR
Definition: SI4844.h:204
uint8_t STEREO
Definition: SI4844.h:163
uint8_t PN
Definition: SI4844.h:203
uint8_t CMPMAJOR
Definition: SI4844.h:206
uint8_t raw[4]
Definition: SI4844.h:190
uint8_t d1
Definition: SI4844.h:172
uint8_t raw[7]
Definition: SI4844.h:111
uint8_t ERR
Definition: SI4844.h:201
uint8_t RESERVED
Definition: SI4844.h:200
uint8_t d3
Definition: SI4844.h:174
uint8_t HOSTRST
Definition: SI4844.h:167
uint8_t BANDMODE
Definition: SI4844.h:170
uint8_t d4
Definition: SI4844.h:173
si4844_get_status refined
Definition: SI4844.h:188
uint8_t raw
Definition: SI4844.h:251
uint8_t raw
Definition: SI4844.h:86
uint8_t STATION
Definition: SI4844.h:164
uint8_t BANDIDX
Definition: SI4844.h:169
uint8_t CTS
Definition: SI4844.h:202
uint8_t FWMINOR
Definition: SI4844.h:205
si4844_get_channel_frequency rawStatus
Definition: SI4844.h:189
uint8_t d2
Definition: SI4844.h:171
uint8_t INFORDY
Definition: SI4844.h:165
uint8_t CTS
Definition: SI4844.h:168
uint8_t BCFG0
Definition: SI4844.h:161
void setAmSoftMuteMaxAttenuation(uint8_t value)
Sets AM Soft Mute Max Attenuation..
Definition: SI4844.cpp:1122
float getFrequency(void)
Get the current frequency of the radio in KHz.
Definition: SI4844.cpp:993
uint32_t getFrequencyInteger(void)
Get the current frequency of the radio in KHz in uint32_t (long integer) .
Definition: SI4844.cpp:1039
uint16_t getStatusBCFG0()
Gets Band CFG0 (Band Detection Configuration).
Definition: SI4844.h:467
void setup(uint16_t resetPin, int interruptPin, int8_t defaultBand=0, uint32_t hightClockSpeed=50000)
Initiates the SI4844 instance and connect the device (SI4844) to Arduino.
Definition: SI4844.cpp:254
void setBandSlideSwitch()
Sets a new band to the device configured as Slide Switch.
Definition: SI4844.cpp:511
void setFmDeemphasis(uint8_t value)
Sets de-emphasis time constant.
Definition: SI4844.cpp:1145
void changeVolume(char)
Up or down the sound volume level.
Definition: SI4844.cpp:667
bool hasBandChanged(void)
Checks whether the current band detected by the device changed.
Definition: SI4844.cpp:1099
si4844_firmware_response * getFirmware(void)
Get part number, chip revision, firmware, patch, and component revision numbers.
Definition: SI4844.cpp:965
void setFmSoftMuteRate(uint8_t value)
Sets the attack and decay rates when entering and leaving soft mute.
Definition: SI4844.cpp:1158
void setAmSoftMuteSnrThreshold(uint8_t value)
Sets the SNR threshold to engage soft mute.
Definition: SI4844.cpp:1229
uint16_t getStatusBandMode()
Gets the current Band Mode.
Definition: SI4844.h:547
void setFmSoftMuteSlope(uint8_t value)
Configures attenuation slope during soft mute in dB attenuation per dB SNR below the soft mute SNR th...
Definition: SI4844.cpp:1173
void resetStatus(void)
set the interrupr status to false. It will turn true after next interrupr
Definition: SI4844.cpp:1108
bool needHostPowerUp()
Checks Host Power Up Status.
Definition: SI4844.h:515
uint16_t getStatusBandIndex()
Gets the current Band Index Detected.
Definition: SI4844.h:554
uint8_t getVolume()
Gets the current audio volume level.
Definition: SI4844.h:440
uint16_t getStatusStationIndicator()
Gets Station Indicator.
Definition: SI4844.h:494
void bassTrebleUp()
More treble, less bass.
Definition: SI4844.cpp:778
si4844_device_status * getStatus()
Gets current status of the device.
Definition: SI4844.cpp:875
void setBassTreble(uint8_t bass_treble)
Set the sound volume level, bass and treble.
Definition: SI4844.cpp:758
void setReferenceClockFrequency(uint16_t value)
Sets the frequency of the REFCLK from the output of the prescaler.
Definition: SI4844.cpp:1243
uint8_t getVolumeProperty()
Gets the current volume value stored in SI4844 device.
Definition: SI4844.cpp:734
bool needHostReset()
Checks HOST Reset Status
Definition: SI4844.h:524
void setBlendThresholdStereoIndicator(uint16_t value)
Sets the blend threshold for stereo indicator.
Definition: SI4844.cpp:1186
void setCustomBand(uint8_t bandIndex, uint16_t botton, uint16_t top, uint8_t bandSpace, uint8_t dfband=0, uint8_t uni_am=0, uint8_t tvreq=0)
This method allows you to customize the frequency range of a band.
Definition: SI4844.cpp:567
void setVolume(byte)
Sets the volume level.
Definition: SI4844.cpp:717
void reset(void)
Resets the SI4844 device.
Definition: SI4844.cpp:362
bool isHostDetectionBandConfig()
Band CFG0 (Band Detection Configuration)
Definition: SI4844.cpp:925
int8_t getValidBandIndex()
Retrieves the current valid BAND INDEX.
Definition: SI4844.cpp:939
void setAmSoftMuteSlope(uint8_t value)
Configures attenuation slope during soft mute in dB attenuation per dB SNR below the soft mute SNR th...
Definition: SI4844.cpp:1216
uint16_t getStatusStereo()
Gets Stereo indicator.
Definition: SI4844.h:485
si4844_status_response * getAllReceiverInfo(void)
Gets all current information of the receiver (tune freq, band, and others information,...
Definition: SI4844.cpp:894
char * getStereoIndicator()
Get the Stereo Indicator.
Definition: SI4844.h:458
char * getBandMode()
Get the Band Mode.
Definition: SI4844.h:449
uint8_t getCurrentBand()
Gets the latest band set by the microcontroller.
Definition: SI4844.h:432
uint16_t getRawChannelFrequency()
Gets the Channel Frequency.
Definition: SI4844.h:538
void powerUp(void)
Power the device up.
Definition: SI4844.cpp:405
void volumeUp(void)
Increases the volume level.
Definition: SI4844.cpp:692
void setCrystalOscillatorStabilizationWaitTime(uint8_t XOWAIT)
Sets Crystal Oscillator Stabilization Wait Time After Reset.
Definition: SI4844.cpp:453
void volumeDown(void)
Decreases the volume level.
Definition: SI4844.cpp:703
void setCrystalOscillatorEnable(uint8_t XOSCEN)
Sets Crystal Oscillator Enable.
Definition: SI4844.cpp:439
uint16_t getStatusInformationReady()
Gets Information Ready.
Definition: SI4844.h:506
uint16_t getStatusBCFG1()
Gets Band CFG1 (Band Properties Priority)
Definition: SI4844.h:475
void debugDevice(uint16_t resetPin, uint16_t interruptPin, uint8_t defaultBand, void(*showFunc)(char *msg))
Used to debug
Definition: SI4844.cpp:319
void audioMute(uint8_t value)
Mutes the audio output.
Definition: SI4844.cpp:847
void bassTrebleDown()
Less treble, more bass.
Definition: SI4844.cpp:767
void setFmSoftMuteMaxAttenuation(uint8_t value)
FM Soft Mute Maximum Attenuation.
Definition: SI4844.cpp:1133
void setBand(uint8_t newBand=0)
Sets a new band to the device.
Definition: SI4844.cpp:468
si4844_audiomode_status_response setAudioMode(uint8_t audiomode, uint8_t fm_mono, uint8_t adjpt_attn, uint8_t adjpt_steo, uint8_t opcode)
Set audio mode.
Definition: SI4844.cpp:810
void setReferenceClockPrescaler(uint16_t value)
Sets the number used by the prescaler to divide the external reference clock frequency down to the in...
Definition: SI4844.cpp:1258
bool hasStatusChanged(void)
Checks whether the SI4844 has its status changed.
Definition: SI4844.cpp:1087
void setupSlideSwitch(uint16_t resetPin, int interruptPin, uint32_t hightClockSpeed=50000)
Initiates the SI48XX instance and connect the device (SI4844) to a microcontroller.
Definition: SI4844.cpp:188
void setAudioMute(bool on)
Mutes the audio output.
Definition: SI4844.cpp:858
void setAmSoftMuteRate(uint8_t value)
Sets the attack and decay rates when entering or leaving soft mute.
Definition: SI4844.cpp:1202
void powerDown(void)
Power the device down.
Definition: SI4844.cpp:383
char * getFormattedFrequency(uint8_t removeRightDigit=0, uint8_t thousandsSeparator=',')
Gets Formatted Frequency.
Definition: SI4844.cpp:1363
void convertToChar(uint32_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: SI4844.cpp:1325
bool detectDevice()
Checks communication with SI4844 via I2C.
Definition: SI4844.cpp:1272
uint8_t scanI2CBus(uint8_t *device, uint8_t limit)
Scans the I2C bus and returns the addresses of the devices found.
Definition: SI4844.cpp:1288