2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
23#define SI4844_ADDRESS 0x11
28#define ATDD_POWER_DOWN 0x11
29#define ATDD_POWER_UP 0xE1
30#define ATDD_AUDIO_MODE 0xE2
32#define ATDD_XOSCEN 0x80
33#define ATDD_XOWAIT 0x40
34#define ATDD_GET_STATUS 0xE0
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
43#define FM_SOFT_MUTE_MAX_ATTENUATION 0x1302
44#define AM_SOFT_MUTE_MAX_ATTENUATION 0x3302
45#define FM_DEEMPHASIS 0x1100
46#define FM_SOFT_MUTE_RATE 0x1300
47#define FM_SOFT_MUTE_SLOPE 0x1301
48#define FM_STEREO_IND_BLEND_THRESHOLD 0x1207
49#define FM_BLEND_RSSI_STEREO_THRESHOLD 0x1800
50#define FM_BLEND_RSSI_MONO_THRESHOLD 0x1801
52#define REFCLK_FREQ 0x0201
53#define REFCLK_PRESCALE 0x0202
55#define AM_SOFT_MUTE_RATE 0x3300
56#define AM_SOFT_MUTE_SLOPE 0x3301
57#define AM_SOFT_MUTE_SNR_THRESHOLD 0x3303
60#define DEVICE_LAST_VALID_INDEX_BAND 40
63
64
65
66
67
68
69
70
74
75
76
77
78
87} si4844_arg_band_index;
90
91
92
93
94
101 uint8_t BANDBOT_HIGH;
103 uint8_t BANDTOP_HIGH;
115
116
117
118
134
135
136
137
138
146 uint8_t HOSTPWRUP : 1;
151} si4844_device_status;
154
155
156
157
158
180} si4844_get_channel_frequency;
183
184
185
186
191} si4844_status_response;
194
195
196
197
209} si4844_firmware_info;
212
213
214
218} si4844_firmware_response;
221
222
223
227 uint8_t AUDIOMODE : 2;
229 uint8_t ADJPT_ATTN : 1;
230 uint8_t ADJPT_STEO : 1;
231 uint8_t Reserved : 2;
238
239
240
245 uint8_t ADJPT_ATTN:1;
246 uint8_t ADJPT_STEO:1;
252} si4844_audiomode_status_response;
255
256
257
258
269
270
271
272
273
274volatile static bool data_from_device;
278
279
280
281
288 si4844_device_status device_status;
289 si4844_status_response all_receiver_status;
290 si4844_firmware_response firmware_response;
292 uint16_t interruptPin;
293 uint8_t currentBand = 0;
297 uint32_t clockSpeed = 50000;
300 uint8_t system_error = 0;
304
305
306
307
308 inline void setClockSpeed(uint16_t clock) {
this->clockSpeed = clock; };
311
312
313
314 inline void setClockLow(
void) { Wire.setClock(10000); };
317
318
319
320
321 inline void setClockHigh() { Wire.setClock(
this->clockSpeed); };
324 inline void waitInterrupt(
void);
325 inline bool isClearToSend(
void);
326 inline void waitToSend(
void);
327 void waitDetectFrequency();
331 const char *bandmode_table[3] = {
"FM",
"AM",
"SW"};
332 const char *stereo_indicator_table[2] = {
"ST",
"MO"};
333 char strFormattedCurrentFrequenct[8];
336 uint8_t bassTreble = 4;
340
341
342
343
344
345
346
350
351
352
353
354
358 void setProperty(uint16_t propertyNumber, uint16_t parameter);
360 void sendCommand(uint8_t cmd,
int parameter_size,
const uint8_t *parameter);
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));
367 void setBand(uint8_t newBand = 0);
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);
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 );
427
428
429
430
431
435
436
437
438
439
444
445
446
447
448
449 inline char *
getBandMode(){
return (
char *) bandmode_table[all_receiver_status.refined.BANDMODE]; };
452
453
454
455
456
457
458 inline char *
getStereoIndicator(){
return (
char *) stereo_indicator_table[device_status.refined.STEREO]; };
461
462
463
464
465
466
470
471
472
473
474
478
479
480
481
482
483
484
489
490
491
492
493
497
498
499
500
501
502
503
504
505
509
510
511
512
513
514
518
519
520
521
522
523
528
529
530
531
532
533
534
535
536
537
542
543
544
545
546
550
551
552
553
576 void convertToChar(uint32_t value,
char *strValue, uint8_t len, uint8_t dot, uint8_t separator,
bool remove_leading_zeros =
true);
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