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 500
32#define I2C_ADDR_DIRECT_ACCESS 0x11
33#define I2C_ADDR_FULL_ACCESS 0x10
36#define OSCILLATOR_TYPE_CRYSTAL 0
37#define OSCILLATOR_TYPE_REFCLK 1
50#define RDA_FM_BAND_USA_EU 0
51#define RDA_FM_BAND_JAPAN_WIDE 1
52#define RDA_FM_BAND_WORLD 2
53#define RDA_FM_BAND_SPECIAL 3
55#define RDA_SEEK_WRAP 0
56#define RDA_SEEK_STOP 1
57#define RDA_SEEK_DOWN 0
82#define I2S_WS_STEP_48 0b1000
83#define I2S_WS_STEP_44_1 0b0111
84#define I2S_WS_STEP_32 0b0110
85#define I2S_WS_STEP_24 0b0101
86#define I2S_WS_STEP_22_05 0b0100
87#define I2S_WS_STEP_16 0b0011
88#define I2S_WS_STEP_12 0b0010
89#define I2S_WS_STEP_11_025 0b0001
90#define I2S_WS_STEP_8 0b0000
94
95
96
97
98
99
102
103
104
105
108 uint8_t LOW_CHIP_ID: 8;
109 uint8_t HIGH_CHIP_ID: 8;
115
116
117
118
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
155 uint8_t SOFT_RESET : 1;
156 uint8_t NEW_METHOD : 1;
158 uint8_t CLK_MODE : 3;
162 uint8_t RCLK_DIRECT_IN : 1;
163 uint8_t NON_CALIBRATE : 1;
173
174
175
176
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
214 uint16_t DIRECT_MODE : 1;
221
222
223
224
225
226
233 uint8_t I2S_ENABLE : 1;
236 uint8_t SOFTMUTE_EN : 1;
237 uint8_t RDS_FIFO_CLR : 1;
239 uint8_t RDS_FIFO_EN : 1;
248
249
250
255 uint8_t LNA_ICSEL_BIT : 2;
256 uint8_t LNA_PORT_SEL : 2;
259 uint8_t SEEK_MODE : 2;
260 uint8_t INT_MODE : 1;
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
288 uint8_t SCLK_O_EDGE : 1;
289 uint8_t SW_O_EDGE : 1;
290 uint8_t I2S_SW_CNT : 4;
291 uint8_t WS_I_EDGE : 1;
292 uint8_t DATA_SIGNED : 1;
293 uint8_t SCLK_I_EDGE : 1;
295 uint8_t SLAVE_MASTER : 1;
296 uint8_t OPEN_MODE : 2;
303
304
305
309 uint8_t FREQ_MODE : 1;
310 uint8_t SOFTBLEND_EN : 1;
311 uint8_t SEEK_TH_OLD : 6;
313 uint8_t MODE_50_60 : 1;
314 uint8_t TH_SOFRBLEND : 5;
321
322
323
324
325
326
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
357 uint16_t READCHAN : 10;
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
391 uint8_t FM_READY : 1;
400
401
402
403
404
414
415
416
417
418
431
432
433
434
435
447
448
449
450
451
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
482 uint16_t address : 2;
486 uint16_t programType : 5;
487 uint16_t trafficProgramCode : 1;
488 uint16_t versionCode : 1;
489 uint16_t groupType : 4;
493 uint16_t address : 4;
494 uint16_t textABFlag : 1;
495 uint16_t programType : 5;
496 uint16_t trafficProgramCode : 1;
497 uint16_t versionCode : 1;
498 uint16_t groupType : 4;
502 uint16_t content : 4;
503 uint16_t textABFlag : 1;
504 uint16_t programType : 5;
505 uint16_t trafficProgramCode : 1;
506 uint16_t versionCode : 1;
507 uint16_t groupType : 4;
513
514
515
516
517
518
519
520
521
526 uint8_t offset_sense : 1;
537
538
539
550
551
552
553
554
555
587 char rds_buffer2A[65];
588 char rds_buffer2B[33];
589 char rds_buffer0A[9];
615
616
617
618
619
623
624
625
626
627
628
640 void setGpio(uint8_t gpioPin, uint8_t gpioSetup = 0,
int mcuPin = -1);
658
659
660
661
662
663
664
667
668
669
670
671
679
680
681
682
683
687
688
689
690
691
701 void seek(uint8_t seek_mode, uint8_t direction);
702 void seek(uint8_t seek_mode, uint8_t direction,
void (*showFunc)());
705 void setBand(uint8_t band = 0);
707 void setStep(uint8_t step = 100);
709
710
711
712
719
720
721
722
723 inline bool isFmTrue() {
return reg0b->refined.FM_TRUE;};
726
727
728
729
730 inline bool isFmReady() {
return reg0b->refined.FM_READY;};
738
739
740
741
751
752
753
754
755 inline bool isMuted() {
return !reg02->refined.DMUTE;};
758
759
760
761
800 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 );
806 void convertToChar(uint16_t value,
char *strValue, uint8_t len, uint8_t dot, uint8_t separator,
bool remove_leading_zeros =
true );
809
810
811
812
813
814
815
816
818 this->convertToChar(value, strValue, 5, 3, decimalSeparator,
true);
822 int checkI2C(uint8_t *addressArray);
#define I2C_ADDR_DIRECT_ACCESS
Can be used to access a given register at a time.
#define CLOCK_32K
32.768kHz
#define I2C_ADDR_FULL_ACCESS
Can be used to access a set of register at a time.
#define OSCILLATOR_TYPE_CRYSTAL
Crystal.
#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.
int gpio1Control
Can be used to add control to the system via GPIO1 pin.
uint16_t currentFrequency
int deviceAddressDirectAccess
int deviceAddressFullAccess
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.
int gpio3Control
Can be used to add control to the system via GPIO3 pin.
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 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)
Set 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 setup(uint8_t clock_type=CLOCK_32K, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL)
Starts the device.
uint16_t getDeviceId()
Gets the Device identification.
void setI2CBusAddrs(int directAccess, int fullAccess)
Sets alternatives I2C bus address.
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 setFrequencyUp()
Increments the current frequency.
void setFmDeemphasis(uint8_t de)
Sets De-emphasis.
uint16_t getFrequency()
Gets the current frequency.
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.
void setChannel(uint16_t channel)
Sets the channel.
uint8_t getSpace()
Returns the current Band Space.
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.
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B
bool hasRdsInfo()
Returns true when the RDS system has valid information.
bool getRdsSync()
Get the Rds Sync.
uint8_t getBlockId()
Get the current Block ID.
uint16_t getRdsGroupType()
Return the group type.
void getNext4Block(char *c)
Process data received from group 2A.
char * getRdsText2A(void)
Gets the Text processed for the 2A group.
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 * getRdsText(void)
Gets the RDS Text when the message is of the Group Type 2 version A.
void clearRdsFifo()
Clear RDS fifo.
char * getRdsText2B(void)
Gets the Text processed for the 2B group.
bool getRdsReady()
Returns true if RDS Ready.
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
uint8_t getErrorBlockB()
Get 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 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)
Configure 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)
Enable 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 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.