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