3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
29#define MAX_DELAY_AFTER_OSCILLATOR 100
31#define I2C_ADDR_DIRECT_ACCESS 0x11
32#define I2C_ADDR_FULL_ACCESS 0x10
34#define OSCILLATOR_TYPE_CRYSTAL 0
35#define OSCILLATOR_TYPE_PASSIVE 0
36#define OSCILLATOR_TYPE_REFCLK 1
37#define OSCILLATOR_TYPE_ACTIVE 1
38#define RLCK_NO_CALIBRATE_MODE_ON 1
39#define RLCK_NO_CALIBRATE_MODE_OFF 0
41#define CLOCK_32K 0b000
42#define CLOCK_12M 0b001
43#define CLOCK_13M 0b010
44#define CLOCK_19_2M 0b011
45#define CLOCK_24M 0b101
46#define CLOCK_26M 0b110
47#define CLOCK_38_4M 0b111
52#define RDA_FM_BAND_USA_EU 0
53#define RDA_FM_BAND_JAPAN_WIDE 1
54#define RDA_FM_BAND_WORLD 2
55#define RDA_FM_BAND_SPECIAL 3
57#define RDA_SEEK_WRAP 0
58#define RDA_SEEK_STOP 1
59#define RDA_SEEK_DOWN 0
84#define I2S_WS_STEP_48 0b1000
85#define I2S_WS_STEP_44_1 0b0111
86#define I2S_WS_STEP_32 0b0110
87#define I2S_WS_STEP_24 0b0101
88#define I2S_WS_STEP_22_05 0b0100
89#define I2S_WS_STEP_16 0b0011
90#define I2S_WS_STEP_12 0b0010
91#define I2S_WS_STEP_11_025 0b0001
92#define I2S_WS_STEP_8 0b0000
95
96
97
98
99
100
103
104
105
106
111 uint8_t LOW_CHIP_ID : 8;
112 uint8_t HIGH_CHIP_ID : 8;
118
119
120
121
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
159 uint8_t SOFT_RESET : 1;
160 uint8_t NEW_METHOD : 1;
162 uint8_t CLK_MODE : 3;
166 uint8_t RCLK_DIRECT_IN : 1;
167 uint8_t NON_CALIBRATE : 1;
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
219 uint16_t DIRECT_MODE : 1;
226
227
228
229
230
231
239 uint8_t I2S_ENABLE : 1;
242 uint8_t SOFTMUTE_EN : 1;
243 uint8_t RDS_FIFO_CLR : 1;
245 uint8_t RDS_FIFO_EN : 1;
254
255
256
262 uint8_t LNA_ICSEL_BIT : 2;
263 uint8_t LNA_PORT_SEL : 2;
266 uint8_t SEEK_MODE : 2;
267 uint8_t INT_MODE : 1;
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
296 uint8_t SCLK_O_EDGE : 1;
297 uint8_t SW_O_EDGE : 1;
298 uint8_t I2S_SW_CNT : 4;
299 uint8_t WS_I_EDGE : 1;
300 uint8_t DATA_SIGNED : 1;
301 uint8_t SCLK_I_EDGE : 1;
303 uint8_t SLAVE_MASTER : 1;
304 uint8_t OPEN_MODE : 2;
311
312
313
318 uint8_t FREQ_MODE : 1;
319 uint8_t SOFTBLEND_EN : 1;
320 uint8_t SEEK_TH_OLD : 6;
322 uint8_t MODE_50_60 : 1;
323 uint8_t TH_SOFRBLEND : 5;
330
331
332
333
334
335
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
366 uint16_t READCHAN : 10;
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
401 uint8_t FM_READY : 1;
409
410
411
412
413
425
426
427
428
429
441
442
443
444
445
457
458
459
460
461
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
493 uint16_t address : 2;
497 uint16_t programType : 5;
498 uint16_t trafficProgramCode : 1;
499 uint16_t versionCode : 1;
500 uint16_t groupType : 4;
504 uint16_t address : 4;
505 uint16_t textABFlag : 1;
506 uint16_t programType : 5;
507 uint16_t trafficProgramCode : 1;
508 uint16_t versionCode : 1;
509 uint16_t groupType : 4;
513 uint16_t content : 4;
514 uint16_t textABFlag : 1;
515 uint16_t programType : 5;
516 uint16_t trafficProgramCode : 1;
517 uint16_t versionCode : 1;
518 uint16_t groupType : 4;
524
525
526
527
528
529
530
531
532
538 uint32_t offset_sense : 1;
547
548
549
561
562
563
564
565
566
627
628
629
630
631
635
636
637
638
639
640
652 void setGpio(uint8_t gpioPin, uint8_t gpioSetup = 0,
int mcuPin = -1);
671
672
673
674
675
676
677
680
681
682
683
684
690
691
692
693
694
695
699
700
701
702
703
707
708
709
710
711
715
716
717
718
719
732 void seek(uint8_t seek_mode, uint8_t direction);
733 void seek(uint8_t seek_mode, uint8_t direction,
void (*showFunc)());
736 void setBand(uint8_t band = 0);
738
739
740
741
742
746 void setStep(uint8_t step = 100);
748
749
750
751
760
761
762
763
764 inline bool isFmTrue() {
return reg0b->refined.FM_TRUE; };
767
768
769
770
771 inline bool isFmReady() {
return reg0b->refined.FM_READY; };
779
780
781
782
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
813
814
815
816
817 inline bool isMuted() {
return !reg02->refined.DMUTE; };
820
821
822
823
844 bool getRdsAllData(
char **stationName,
char **stationInformation,
char **programInformation,
char **utcTime);
855
856
857
858
859
860
861
866
867
868
869
870
871
872
877
878
879
880
881
882
889
890
891
892
893
894
895
896
899 return reg0b->refined.ABCD_E;
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
922 return reg0b->refined.BLERA;
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
946 return reg0b->refined.BLERB;
950
951
952
953
954
955
956
959 return (reg0a->refined.RDSS && reg0b->refined.ABCD_E == 0 && reg0b->refined.BLERB == 0);
963
964
965
966
967
968
971 return (reg0a->refined.RDSS && reg0b->refined.ABCD_E == 0 && reg0b->refined.BLERA == 0 && reg0b->refined.BLERB == 0);
975
976
977
978
979
980
981
984 return reg0a->refined.RDSS;
989 void setI2SAllParameters(uint8_t R_DELY, uint8_t L_DELY, uint8_t SCLK_O_EDGE, uint8_t SW_O_EDGE, uint8_t I2S_SW_CNT, uint8_t WS_I_EDGE, uint8_t DATA_SIGNED, uint8_t SCLK_I_EDGE, uint8_t WS_LR, uint8_t SLAVE_MASTER, uint8_t OPEN_MODE);
995 void convertToChar(uint16_t value,
char *strValue, uint8_t len, uint8_t dot, uint8_t separator,
bool remove_leading_zeros =
true);
998
999
1000
1001
1002
1003
1004
1005
1008 this->convertToChar(value, strValue, 5, 3, decimalSeparator,
true);
1013
1014
1015
1016
1017
1018
1019
1022 this->convertToChar(
this->currentFrequency,
this->strFrequency, 5, 3, decimalSeparator,
true);
1026 int checkI2C(uint8_t *addressArray);
#define OSCILLATOR_TYPE_PASSIVE
Passive Crystal.
#define REG02
Register 0x02.
#define REG07
Register 0x07.
#define I2C_ADDR_DIRECT_ACCESS
Can be used to access a given register at a time.
#define REG0A
Register 0x0A.
#define REG0B
Register 0x0B.
#define REG05
Register 0x05.
#define REG04
Register 0x04.
#define REG08
Register 0x08.
#define CLOCK_32K
32.768kHz
#define REG03
Register 0x03.
#define REG06
Register 0x06.
#define I2C_ADDR_FULL_ACCESS
Can be used to access a set of register at a time.
#define RLCK_NO_CALIBRATE_MODE_OFF
#define MAX_DELAY_AFTER_OSCILLATOR
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.
int checkI2C(uint8_t *addressArray)
Check the I2C bus address.
char * formatFrequency(uint16_t value, char *strValue, char decimalSeparator)
Convert a numeric frequency to a formated string (char *) frequency.
char * formatCurrentFrequency(char decimalSeparator=',')
Convert the current frequency to a formated string (char *) frequency.
char rds_buffer0A[9]
PS - RDS Basic tuning and switching information (Type 0 groups) - Station Name.
int gpio1Control
Can be used to add control to the system via GPIO1 pin.
uint16_t currentFrequency
int deviceAddressDirectAccess
char rds_time[25]
CT - RDS date time received information - UTC Time.
int deviceAddressFullAccess
char rds_buffer2B[33]
RDS Radio Text buffer - Station Information.
uint16_t maxDelayAftarCrystalOn
uint16_t RDSA
BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
int gpio2Control
Can be used to add control to the system via GPIO2 pin.
uint8_t rlckNoCalibrate
Default is 0.
int gpio3Control
Can be used to add control to the system via GPIO3 pin.
uint8_t oldTextABFlag
Saves the latest value of the textABFlag. Useful to check chanhes.
char rds_buffer2A[65]
RT - RDS Radio Text buffer - Program Information.
void setDelayAfterCrystalOn(uint8_t ms_value)
Set the Delay After Crystal On (default 500ms)
void * getStatus(uint8_t reg)
Gets the register content of a given status register (from 0x0A to 0x0F)
void powerDown()
Power the receiver off.
void setup(uint8_t clock_frequency=CLOCK_32K, uint8_t oscillator_type=OSCILLATOR_TYPE_PASSIVE, uint8_t rlck_no_calibrate=RLCK_NO_CALIBRATE_MODE_OFF)
Starts the device.
void powerUp()
Powers the receiver on.
void setRegister(uint8_t reg, uint16_t value)
Sets a given value to a specific device register.
void softReset()
Resets the device.
void waitAndFinishTune()
Waits for Seek or Tune finish.
void setGpio(uint8_t gpioPin, uint8_t gpioSetup=0, int mcuPin=-1)
Sets the Device GPIO pins.
word16_to_bytes getDirectRegister(uint8_t reg)
Gets the register content via direct access.
void setNewDemodulateMethod(bool value)
Sets new demodulate method. It can improve the receiver sensitivity about 1dB.
void getStatusRegisters()
Gets all current device status and RDS information registers (From 0x0A to 0x0F)
void setInterruptMode(uint8_t value)
Sets Interrupt Mode.
uint16_t getDeviceId()
Gets the Device identification.
void setI2CBusAddrs(int directAccess, int fullAccess)
Sets alternatives I2C bus address.
void setBand3_50_65_Mode(uint8_t band3Mode)
Sets the band 3 mode: 50 to 65 MHZ or 65 to 76 MHz.
uint16_t getRealFrequency()
Gets the current frequency bases on the current channel.
uint16_t getRealChannel()
Gets the current channel stored in 0x0A status register.
void setSeekThreshold(uint8_t value)
Sets RSSI Seek Threshold.
bool isFmReady()
Returns true if the FM is ready.
void setDirectFrequency(uint16_t frequency)
Sets the frequency using the reg08 (direct frequency)
void setFrequencyUp()
Increments the current frequency.
void setFmDeemphasis(uint8_t de)
Sets De-emphasis.
uint16_t getFrequency()
Gets the current frequency.
uint16_t getMinimumFrequencyOfTheBand()
gets the minimum frequency of the current band
void setSoftBlendEnable(bool value)
Sets Soft Blend.
void setSpace(uint8_t space=0)
Sets the FM channel space.
void setFrequencyToEndBand()
Tunes the receiver at the last channel/frequency of the current band.
bool isFmTrue()
Returns true if the current channel is a station.
void seek(uint8_t seek_mode, uint8_t direction)
Seek function.
void setBand(uint8_t band=0)
Sets the FM band. See table below.
void setStep(uint8_t step=100)
Sets the FM Step;.
void setAFC(bool value)
Sets AFC true or false.
uint16_t getMaximunFrequencyOfTheBand()
gets the maximun frequency of the current band
void setChannel(uint16_t channel)
Sets the channel.
uint8_t getSpace()
Returns the current Band Space.
uint8_t getBand()
Returns the current band.
void setFrequencyToBeginBand()
Tunes the receiver at the first channel/frequency of the current band.
void setFrequency(uint16_t frequency)
Sets the frequency.
void setFrequencyDown()
Decrements the current frequency.
void seek(uint8_t seek_mode, uint8_t direction, void(*showFunc)())
Seek function.
void setFrequencyMode(uint8_t value)
Sets the frequency mode. If 1, then freq setting changed.
uint8_t getBand3Status()
Gets the status of the Band3.
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B.
bool hasRdsInfo()
Returns true when the RDS system has valid information.
void clearRdsFifo(bool value=1)
Clear RDS fifo.
void clearRdsBuffer()
Clear RDS Information (Station Name, Station Information, Program Information and Time)
uint8_t getErrorBlockA()
Gets the current Status of block A.
bool getRdsSync()
Gets the Rds Sync.
uint8_t getBlockId()
Gets the current Block ID.
char * getRdsStationInformation(void)
Gets the Station Information.
uint16_t getRdsGroupType()
Return the group type.
void getNext4Block(char *c)
Process data received from group 2A.
char * getRdsText2A(void)
Gets the Program Information.
void setRDS(bool value)
Sets the RDS operation.
char * getRdsText0A(void)
Gets the station name and other messages.
void getNext2Block(char *c)
Process data received from group 2B.
char * getRdsProgramInformation(void)
Gets the Program Information.
char * getRdsLocalTime()
Gets the RDS time converted to local time.
char * getRdsStationName(void)
Gets the Station Name.
bool hasRdsInfoAB()
Returns true when the RDS system has valid information.
char * getRdsText2B(void)
Gets the Station Information.
bool getRdsReady()
Returns true if RDS Ready.
bool isNewRdsFlagAB(void)
Returns true if the Text Flag A/B has changed.
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
bool getRdsAllData(char **stationName, char **stationInformation, char **programInformation, char **utcTime)
Gets Station Name, Station Information, Program Information and utcTime.
uint8_t getErrorBlockB()
Gets the current Status of block B.
void setRdsFifo(bool value)
Sets RDS fifo mode enable.
uint8_t getRdsProgramType(void)
Returns the Program Type (extracted from the Block B)
void setRBDS(bool value)
Sets the RBDS operation.
char * getRdsTime()
Gets the RDS UTC time and date when the Group type is 4.
void setI2SAllParameters(uint8_t R_DELY, uint8_t L_DELY, uint8_t SCLK_O_EDGE, uint8_t SW_O_EDGE, uint8_t I2S_SW_CNT, uint8_t WS_I_EDGE, uint8_t DATA_SIGNED, uint8_t SCLK_I_EDGE, uint8_t WS_LR, uint8_t SLAVE_MASTER, uint8_t OPEN_MODE)
Configures all parameters for I2S.
void setI2SSpeed(uint8_t value)
Sets the speed in kbps. You can use the predefined constantes: I2S_WS_STEP_48, I2S_WS_STEP_44_1,...
void setI2SMaster(bool value)
void setI2SDataSigned(bool value)
If 0, I2S output unsigned 16-bit audio data. If 1, I2S output signed 16-bit audio data.
void setI2SOn(bool value)
Enables I2S setup.
bool isStereo()
Gets the current Stereo status.
bool isSoftmuted()
Gets the softmute status.
bool isAudioOutputHighImpedance()
Gets true if the output audio impedance is high.
void setVolume(uint8_t value)
Sets the audio volume level.
uint8_t getVolume()
Gets the current audio volume level.
void setLedStereoIndicator(bool value=true)
Sets the system to use a LED to indicate Stereo or Mono.
void setBass(bool value)
Sets Bass Boost.
void setVolumeUp()
Increments the audio volume.
void setVolumeDown()
Decrements the audio volume.
void setAudioOutputHighImpedance(bool value)
Sets audio output impedance high ow low.
void setMono(bool value)
Sets audio Mono or stereo.
void setSoftmute(bool value)
Sets Soft Mute Enable or disable.
bool isMuted()
Gets Audio Mute Status.
void setMute(bool value)
Sets Audio mute or unmute.
void setLnaIcSel(uint8_t value)
Sets LNA_ICSEL_BIT.
int getRssi()
Gets the current Rssi.
uint8_t getLnaIcSel()
Gets LNA_ICSEL_BIT current value.
void setLnaPortSel(uint8_t value)
Sets LNA input port selection bit.
uint8_t getLnaPortSel()
Gets current vaue of the LNA input port selection bit.