PU2CLR RDA5807 Arduino Library 1.1.4
Arduino Library for RDA5807 Devices - By Ricardo Lima Caratti
Loading...
Searching...
No Matches
RDA5807.cpp
Go to the documentation of this file.
1/**
2 * @mainpage RDA5807 Arduino Library implementation
3 * @details RDA5807 Arduino Library implementation. This is an Arduino library for the RDA5807, BROADCAST RECEIVER.
4 * @details It works with I2C protocol and can provide an easier interface to control the RDA5807 device.<br>
5 * @details This library was built based on "RDA5807M - SINGLE-CHIP BROADCAST FM RADIO TUNER - Rev.1.1–Aug.2015"
6 * @details and RDA microelectronics RDA5807FP - SINGLE-CHIP BROADCAST FM RADIO TUNER
7 * @details This library can be freely distributed using the MIT Free Software model.
8 * @copyright Copyright (c) 2020 Ricardo Lima Caratti.
9 * @author Ricardo LIma Caratti (pu2clr@gmail.com)
10 */
11
12#include <RDA5807.h>
13
14/**
15 * @defgroup GA02 Basic Functions
16 * @section GA02 Basic Functions
17 */
18
19/**
20 * @ingroup GA02
21 * @brief Sets the Device GPIO pins
22 * @details This method is useful to add control to the system via GPIO RDA devive pins.
23 * @details For example: You can use these pins to control RDS and SEEK via interrupt.
24 * @details GPIOs are General Purpose I/O pin.
25 * @details GPIO setup
26 * @details When GPIO1 (#1), gpioSetup can be: 00 = High impedance; 01 = Reserved; 10 = Low; 11 = High
27 * @details When GPIO2 (#2), gpioSetup can be: 00 = High impedance; 01 = Interrupt (INT) 10 = Low; 11 = High
28 * @details When GPIO3 (#3), gpioSetup can be: 00 = High impedance; 01 = Mono/Stereo indicator (ST) = Low; 11 = High
29 *
30 * @param gpioPin gpio number (1, 2 or 3)
31 * @param gpioSetup See description above
32 * @param mcuPip MCU (Arduino) pin connected to the gpio
33 */
34void RDA5807::setGpio(uint8_t gpioPin, uint8_t gpioSetup, int mcuPin)
35{
36
37 switch (gpioPin) {
38 case 1:
39 this->gpio1Control = mcuPin;
40 reg04->refined.GPIO1 = gpioSetup;
41 break;
42 case 2:
43 this->gpio2Control = mcuPin;
44 reg04->refined.GPIO2 = gpioSetup;
45 break;
46 case 3:
47 this->gpio3Control = mcuPin;
48 reg04->refined.GPIO3 = gpioSetup;
49 break;
50 default:
51 gpio1Control = gpio2Control = gpio3Control = -1;
52
53 }
54 setRegister(REG04,reg04->raw);
55}
56
57/**
58 * @ingroup GA02
59 * @brief Gets all current device status and RDS information registers (From 0x0A to 0x0F)
60 * @see RDA5807M - SINGLE-CHIP BROADCAST FMRADIO TUNER; pages 5, 9, 12 and 13.
61 * @see rda_reg0a, rda_reg0b, rda_reg0c, rda_reg0d, rda_reg0e, rda_reg0f
62 * @see shadowStatusRegisters;
63 */
65{
66 word16_to_bytes aux;
67 int i;
68
69 Wire.requestFrom(this->deviceAddressFullAccess, 12); // This call starts reading from 0x0A register
70 for (i = 0; i < 6; i++) {
71 aux.refined.highByte = Wire.read();
72 aux.refined.lowByte = Wire.read();
73 shadowStatusRegisters[i] = aux.raw;
74 }
75 Wire.endTransmission();
76}
77
78/**
79 * @ingroup GA02
80 * @brief Gets the register content via direct access
81 * @details this method is useful to deal with a specific register.
82 * @param uint8_t register number
83 * @return word16_to_bytes register content
84 * @see word16_to_bytes datatype in RDA5807.h
85 */
86word16_to_bytes RDA5807::getDirectRegister(uint8_t reg)
87{
88
89 word16_to_bytes aux;
90 Wire.beginTransmission(this->deviceAddressDirectAccess);
91 Wire.write(reg);
92 Wire.endTransmission(false);
93 Wire.requestFrom(this->deviceAddressDirectAccess, 2);
94 aux.refined.highByte = Wire.read();
95 aux.refined.lowByte = Wire.read();
96 Wire.endTransmission();
97
98 return aux;
99}
100
101/**
102 * @ingroup GA02
103 * @brief Gets the register content of a given status register (from 0x0A to 0x0F)
104 * @details Useful when you need just a specific status register content.
105 * @details This methos update the first element of the shadowStatusRegisters linked to the register
106 * @return rdax_reg0a the reference to current value of the 0x0A register.
107 */
108void *RDA5807::getStatus(uint8_t reg)
109{
110 word16_to_bytes aux;
111
112 if ( reg < 0x0A || reg > 0x0F ) return NULL; // Maybe not necessary.
113
114 Wire.beginTransmission(this->deviceAddressDirectAccess);
115 Wire.write(reg);
116 Wire.endTransmission(false);
117 Wire.requestFrom(this->deviceAddressDirectAccess, 2); // reading 0x0A register
118 delayMicroseconds(250);
119 aux.refined.highByte = Wire.read();
120 aux.refined.lowByte = Wire.read();
121 Wire.endTransmission(true);
122 shadowStatusRegisters[reg - 0x0A] = aux.raw;
123
124 return &shadowStatusRegisters[reg - 0x0A];
125}
126
127
128/**
129 * @ingroup GA02
130 * @brief Sets a given value to a specific device register
131 *
132 * @see RDA5807M - SINGLE-CHIP BROADCAST FMRADIO TUNER; pages 5, 9, 10 and 11.
133 * @see rda_reg02, rda_reg03, rda_reg04, rda_reg05, rda_reg06, rda_reg07
134 *
135 * @param reg register number (valid values is between 0x02 and 0x07)
136 * @param value the unsigned 16 bits word value (see rda_rec0x data types)
137 */
138void RDA5807::setRegister(uint8_t reg, uint16_t value)
139{
140 word16_to_bytes aux;
141 if (reg > 8) return; // Maybe not necessary.
142 Wire.beginTransmission(this->deviceAddressDirectAccess);
143 Wire.write(reg);
144 aux.raw = value;
145 Wire.write(aux.refined.highByte);
146 Wire.write(aux.refined.lowByte);
147 Wire.endTransmission();
148 shadowRegisters[reg] = aux.raw; // Updates the shadowRegisters element
149 delayMicroseconds(3000); // Check
150}
151
152/**
153 * @ingroup GA02
154 * @brief Waits for Seek or Tune finish
155 */
157{
158 do {
159 getStatus(REG0A);
160 } while (reg0a->refined.STC == 0);
161}
162
163/**
164 * @ingroup GA02
165 * @brief Resets the device
166 * @details The RDA5807M is RESET itself When VIO is Power up.
167 * @details Also, it support soft reset by triggering the 0x02 register (rda_reg02) bit 1 from 0 to 1.
168 */
170{
171 reg02->refined.SOFT_RESET = 1;
172 setRegister(REG02,reg02->raw);
173}
174
175/**
176 * @ingroup GA02
177 * @brief Powers the receiver on
178 */
180{
181 reg02->raw = 0;
182 reg02->refined.NEW_METHOD = 0;
183 reg02->refined.RDS_EN = 0; // RDS disable
184 reg02->refined.CLK_MODE = this->clockType;
185 reg02->refined.RCLK_DIRECT_IN = this->oscillatorType;
186 reg02->refined.MONO = 1; // Force mono
187 reg02->refined.DMUTE = 1; // Normal operation
188 reg02->refined.DHIZ = 1; // Normal operation
189 reg02->refined.ENABLE = 1;
190 reg02->refined.BASS = 1;
191 reg02->refined.SEEK = 0;
192
193 setRegister(REG02,reg02->raw);
194
195 reg05->raw = 0x00;
196 reg05->refined.INT_MODE = 0;
197 reg05->refined.LNA_PORT_SEL = 2;
198 reg05->refined.LNA_ICSEL_BIT = 0;
199 reg05->refined.SEEKTH = 8; // 0b1000
200 reg05->refined.VOLUME = 0;
201
202 setRegister(REG05, reg05->raw);
203}
204
205/**
206 * @ingroup GA02
207 * @brief Sets new demodulate method. It can improve the receiver sensitivity about 1dB
208 *
209 * @param value true or false
210 */
212 reg02->refined.NEW_METHOD = value;
213 setRegister(REG02,reg02->raw);
214}
215
216/**
217 * @ingroup GA02
218 * @brief Power the receiver off
219 */
221{
222 reg02->refined.SEEK = 0;
223 reg02->refined.ENABLE = 0;
224 setRegister(REG02, reg02->raw);
225}
226
227
228/**
229 * @ingroup GA02
230 * @brief Starts the device
231 * @details You can select the colck type and the frequency
232 * @details oscillator type: OSCILLATOR_TYPE_CRYSTAL = passive crystal; OSCILLATOR_TYPE_REFCLK = active crystal or signal generator
233 * @details Clock type: CLOCK_32K, CLOCK_12M, CLOCK_13M, CLOCK_19_2M, CLOCK_24M, CLOCK_26M and CLOCK_38_4M
234 * @param clock_type Clock used.
235 * @param oscillator_type optional. Sets the Oscillator type used (default: passive Crystal).
236 */
237void RDA5807::setup(uint8_t clock_type, uint8_t oscillator_type)
238{
239 this->oscillatorType = oscillator_type;
240 this->clockType = clock_type;
241
242 Wire.begin();
243 delay(1);
244 powerUp();
245
246}
247
248/**
249 * @ingroup GA02
250 * @brief Gets the Device identification
251 * @return device number Id
252 */
254{
255 word16_to_bytes aux;
256 aux = getDirectRegister(0x0);
257 reg00->raw = aux.raw;
258 return reg00->raw;
259}
260
261
262/**
263 * @defgroup GA03 FM Tune Functions
264 * @section GA03 FM Tune
265 */
266
267
268/**
269 * @ingroup GA03
270 * @brief Sets Soft Blend.
271 *
272 * @param value true or false
273 */
274 void RDA5807::setSoftBlendEnable(bool value) {
275 reg07->refined.SOFTBLEND_EN = value;
276 setRegister(REG07,reg07->raw);
277 }
278
279/**
280 * @ingroup GA03
281 * @brief Sets AFC true or false
282 *
283 * @param value true or false
284 */
285void RDA5807::setAFC(bool value) {
286 reg04->refined.AFCD = value;
287 setRegister(REG04,reg04->raw);
288}
289
290
291/**
292 * @ingroup GA03
293 * @brief Sets the channel
294 * @details This method tunes the rteceiver in a given channel.
295 * @details The channel can be calculated by using the follow formula
296 * @details channel = (desired frequency - start band frequency) / space channel in use / 10.0);
297 *
298 * @see setFrequency, setBand, setSpace
299 * @see RDA5807M - SINGLE-CHIP BROADCAST FM RADIO TUNER - Rev.1.1–Aug.2015; pages 9 and 12.
300 *
301 * @param channel
302 */
303void RDA5807::setChannel(uint16_t channel)
304{
305 reg03->refined.CHAN = channel;
306 reg03->refined.TUNE = 1;
307 reg03->refined.BAND = this->currentFMBand;
308 reg03->refined.SPACE = this->currentFMSpace;
309 reg03->refined.DIRECT_MODE = 0;
310 setRegister(REG03, reg03->raw);
312}
313
314/**
315 * @ingroup GA03
316 * @brief Sets the frequency
317 * @param frequency
318 */
319void RDA5807::setFrequency(uint16_t frequency)
320{
321 uint16_t channel = (frequency - this->startBand[currentFMBand] ) / (this->fmSpace[this->currentFMSpace] );
322 setChannel(channel);
323 this->currentFrequency = frequency;
324}
325
326/**
327 * @ingroup GA03
328 * @brief Increments the current frequency
329 * @details The increment uses the band space as step. See array: uint16_t fmSpace[4] = {100/10, 200/10, 50/10, 25/10};
330 */
332{
333 if (this->currentFrequency < this->endBand[this->currentFMBand])
334 this->currentFrequency += (this->fmSpace[currentFMSpace] );
335 else
336 this->currentFrequency = this->startBand[this->currentFMBand];
337
338 setFrequency(this->currentFrequency);
339}
340
341/**
342 * @ingroup GA03
343 * @brief Decrements the current frequency
344 * @details The drecrement uses the band space as step. See array: uint16_t fmSpace[4] = {20, 10, 5, 1};
345 */
347{
348 if (this->currentFrequency > this->startBand[this->currentFMBand])
349 this->currentFrequency -= (this->fmSpace[currentFMSpace] );
350 else
351 this->currentFrequency = this->endBand[this->currentFMBand];
352
353 setFrequency(this->currentFrequency);
354}
355
356
357
358/**
359 * @ingroup GA03
360 * @brief Gets the current frequency.
361 * @return uint16_t
362 */
364{
365 return this->currentFrequency;
366}
367
368/**
369 * @ingroup GA03
370 * @brief Gets the current channel stored in 0x0A status register.
371 *
372 * @see setChannel, setFrequency, setBand, setSpace
373 * @see RDA5807M - SINGLE-CHIP BROADCAST FM RADIO TUNER - Rev.1.1–Aug.2015; pages 9 and 12.
374 *
375 * @return uint16_t current channel value
376 */
378{
379 getStatus(REG0A);
380 return reg0a->refined.READCHAN;
381}
382
383/**
384 * @ingroup GA03
385 * @brief Gets the current frequency bases on the current channel.
386 * @details The current channel is stored in the 0x0A register. This value is updated after a tune or seek operation.
387 * @details The current frequency can be calculated by the formula below
388 *
389 * | Band | Formula |
390 * | ------ | ------- |
391 * | 0 | Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 87.0 MHz |
392 * | 1 or 2 | Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 76.0 MHz |
393 * | 3 | Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 65.0 MHz |
394 *
395 * @see setChannel, setFrequency, setBand, setSpace
396 * @see RDA5807M - SINGLE-CHIP BROADCAST FM RADIO TUNER - Rev.1.1–Aug.2015; pages 9 and 12.
397 * @return uint16_t
398 */
400 return getRealChannel() * (this->fmSpace[this->currentFMSpace]) + this->startBand[currentFMBand];
401 }
402
403/**
404 * @ingroup GA03
405 * @brief Seek function
406 *
407 * @param seek_mode if 0, wrap at the upper or lower band limit and continue seeking; 1 = stop seeking at the upper or lower band limit
408 * @param direction if 0, seek down; if 1, seek up.
409 */
410void RDA5807::seek(uint8_t seek_mode, uint8_t direction)
411 {
412 reg02->refined.SEEK = 1;
413 reg02->refined.SKMODE = seek_mode;
414 reg02->refined.SEEKUP = direction;
415 setRegister(REG02,reg02->raw);
416}
417
418/**
419 * @ingroup GA03
420 * @brief Seek function
421 * @details Seeks a station up or down.
422 * @details Seek up or down a station and call a function defined by the user to show the frequency during the seek process.
423 * @details Seek begins at the current channel, and goes in the direction specified with the SEEKUP bit. Seek operation stops when a channel is qualified as valid according to the seek parameters, the entire band has been searched (SKMODE = 0), or the upper or lower band limit has been reached (SKMODE = 1).
424 * @details The STC bit is set high when the seek operation completes and/or the SF/BL bit is set high if the seek operation was unable to find a channel qualified as valid according to the seek parameters. The STC and SF/BL bits must be set low by setting the SEEK bit low before the next seek or tune may begin.
425 * @details The SEEK bit is set low and the STC bit is set high when the seek operation completes.
426 * @details It is important to say you have to implement a show frequency function. This function have to get the frequency via getFrequency function.
427 * @details Example:
428 * @code
429 *
430 * SI470X rx;
431 *
432 * void showFrequency() {
433 * uint16_t freq = rx.getFrequency();
434 * Serial.print(freq);
435 * Serial.println("MHz ");
436 * }
437 *
438 * void loop() {
439 * .
440 * .
441 * rx.seek(SI470X_SEEK_WRAP, SI470X_SEEK_UP, showFrequency); // Seek Up
442 * .
443 * .
444 * }
445 * @endcode
446 * @param seek_mode Seek Mode; 0 = Wrap at the upper or lower band limit and continue seeking (default); 1 = Stop seeking at the upper or lower band limit.
447 * @param direction Seek Direction; 0 = Seek down (default); 1 = Seek up.
448 * @param showFunc function that you have to implement to show the frequency during the seeking process. Set NULL if you do not want to show the progress.
449 */
450void RDA5807::seek(uint8_t seek_mode, uint8_t direction, void (*showFunc)())
451{
452 getStatus(REG0A);
453 do
454 {
455 reg02->refined.SEEK = 1;
456 reg02->refined.SKMODE = seek_mode;
457 reg02->refined.SEEKUP = direction;
458 setRegister(REG02, reg02->raw);
459 this->currentFrequency = getRealFrequency(); // gets the current seek frequency
460 if (showFunc != NULL)
461 {
462 showFunc();
463 }
464 delay(10);
465 getStatus(REG0A);
466 } while (reg0a->refined.STC == 0);
468 setFrequency(getRealFrequency()); // Fixes station found.
469}
470
471
472
473/**
474 * @ingroup GA03
475 * @brief Sets RSSI Seek Threshold
476 * @param value
477 */
478void RDA5807::setSeekThreshold(uint8_t value)
479{
480 reg05->refined.SEEKTH = value;
481 setRegister(REG05,reg05->raw);
482}
483
484/**
485 * @ingroup GA03
486 * @brief Sets the FM band. See table below.
487 *
488 * FM band table
489 *
490 * | Value | Description |
491 * | ----- | --------------------------- |
492 * | 00 | 87–108 MHz (US/Europe) |
493 * | 01 | 76–91 MHz (Japan) |
494 * | 10 | 76–108 MHz (world wide) |
495 * | 11 | 65 –76 MHz (East Europe) or 50-65MHz (see bit 9 of gegister 0x06) |
496 *
497 * @param band FM band index. See table above.
498 */
499void RDA5807::setBand(uint8_t band)
500{
501 // reg03->refined.BAND = band;
502 reg03->refined.BAND = this->currentFMBand = band; // Adjusted by anonimous developer
503 setRegister(REG03,reg03->raw);
504}
505
506/**
507 * @ingroup GA03
508 * @brief Sets the FM channel space.
509 *
510 * Channel space table
511 *
512 * | Value | Description |
513 * | ----- | ----------- |
514 * | 00 | 100KHz |
515 * | 01 | 200KHz |
516 * | 10 | 50KHz |
517 * | 11 | 25KHz |
518 *
519 * @param space FM channel space. See table above.
520 * @todo make the space 01 (200kHz) work.
521 */
522void RDA5807::setSpace(uint8_t space)
523{
524 reg03->refined.SPACE = space;
525 this->currentFMSpace = space;
526 setRegister(REG03, reg03->raw);
527}
528
529/**
530 * @ingroup GA03 - Frequency step
531 * @brief Sets the FM Step;
532 * @details Converts the step frequency (25, 50, 100 or 200 kHz) to Space. Invalid values will be converted to 0 (100 kHz)
533 * @param step 25, 50, 100 or 200 kHz
534 * @todo Make the step 200kHz work well
535 */
536void RDA5807::setStep(uint8_t step)
537{
538 uint8_t space;
539 switch (step) {
540 case 100:
541 space = 0; // b00
542 break;
543 case 200:
544 space = 1; // b01
545 break;
546 case 50:
547 space = 2; // b10
548 break;
549 case 25:
550 space = 3; // b11
551 break;
552 default:
553 space = 0;
554 }
555 this->setSpace(space);
556}
557
558
559/**
560 * @ingroup GA03
561 * @brief Sets De-emphasis.
562 * @details 75 μs. Used in USA (default); 50 μs. Used in Europe, Australia, Japan.
563 *
564 * @param de 0 = 75 μs; 1 = 50 μs
565 */
566void RDA5807::setFmDeemphasis(uint8_t de) {
567 reg04->refined.DE = de;
568 setRegister(REG04,reg04->raw);
569}
570
571/**
572 * @defgroup GA04 RDS Functions
573 * @section GA04 RDS/RBDS
574 * @todo Need optimizing the method to get the RDS informastion - getStatusRegisters should be called just once at a cicle.
575 */
576
577/**
578 * @ingroup GA04
579 * @brief Sets the RDS operation
580 * @details Enable or Disable the RDS
581 *
582 * @param true = turns the RDS ON; false = turns the RDS OFF
583 */
584void RDA5807::setRDS(bool value)
585{
586 reg02->refined.SEEK = 0;
587 reg02->refined.RDS_EN = value;
588 setRegister(REG02, reg02->raw);
589}
590
591/**
592 * @ingroup GA04
593 * @brief Sets the RBDS operation
594 * @details Enable or Disable the RDS
595 *
596 * @param true = turns the RBDS ON; false = turns the RBDS OFF
597 */
598void RDA5807::setRBDS(bool value)
599{
600 reg02->refined.SEEK = 0;
601 reg02->refined.RDS_EN = 1;
602 setRegister(REG02, reg02->raw);
603 reg04->refined.RBDS = value;
604 setRegister(REG04, reg04->raw);
605}
606
607
608/**
609 * @ingroup GA04
610 * @brief Returns true if RDS Ready
611 * @details Read address 0Ah and check the bit RDSR.
612 * @details When using the polling method, it is best not to poll continuously. The data will appear in intervals.
613 * @return true
614 * @return false
615 */
617{
618 getStatus(REG0A);
619
620 return reg0a->refined.RDSR;
621}
622
623/**
624 * @ingroup GA04
625 *
626 * @brief Returns the current Text Flag A/B
627 * @return uint8_t current Text Flag A/B
628 */
630{
631 rds_blockb blkb;
632 getStatusRegisters(); // TODO: Should be called just once and be processed by all RDS functions at a time.
633 blkb.blockB = reg0d->RDSB;
634 return blkb.refined.textABFlag;
635}
636
637/**
638 * @ingroup GA04
639 * @brief Return the group type
640 *
641 * @return uint16_t
642 */
644{
645 rds_blockb blkb;
646
647 getStatusRegisters(); // TODO: Should be called just once and be processed by all RDS functions at a time.
648 blkb.blockB = reg0d->RDSB;
649 return blkb.group0.groupType;
650}
651
652/**
653 * @ingroup GA04
654 *
655 * @brief Gets the version code (extracted from the Block B)
656 * @returns 0=A or 1=B
657 */
659{
660 rds_blockb blkb;
661 getStatusRegisters(); // TODO: Should be called just once and be processed by all RDS functions at a time.
662 blkb.blockB = reg0d->RDSB;
663 return blkb.refined.versionCode;
664}
665
666/**
667 * @ingroup GA04
668 * @brief Returns the Program Type (extracted from the Block B)
669 * @see https://en.wikipedia.org/wiki/Radio_Data_System
670 * @return program type (an integer betwenn 0 and 31)
671 */
673{
674 rds_blockb blkb;
675 getStatusRegisters(); // TODO: Should be called just once and be processed by all RDS functions at a time.
676 blkb.blockB = reg0d->RDSB;
677 return blkb.refined.programType;
678}
679
680/**
681 * @ingroup GA04
682 *
683 * @brief Process data received from group 2B
684 * @param c char array reference to the "group 2B" text
685 */
686void RDA5807::getNext2Block(char *c)
687{
688 char raw[2];
689 int i, j;
690 word16_to_bytes blk;
691
692 blk.raw = reg0f->RDSD;
693
694 raw[1] = blk.refined.lowByte;
695 raw[0] = blk.refined.highByte;
696
697 for (i = j = 0; i < 2; i++)
698 {
699 if (raw[i] == 0xD || raw[i] == 0xA)
700 {
701 c[j] = '\0';
702 return;
703 }
704 if (raw[i] >= 32)
705 {
706 c[j] = raw[i];
707 j++;
708 }
709 else
710 {
711 c[i] = ' ';
712 }
713 }
714}
715
716/**
717 * @ingroup GA04
718 *
719 * @brief Process data received from group 2A
720 *
721 * @param c char array reference to the "group 2A" text
722 */
723void RDA5807::getNext4Block(char *c)
724{
725 char raw[4];
726 int i, j;
727 word16_to_bytes blk_c, blk_d;
728
729 blk_c.raw = reg0e->RDSC;
730 blk_d.raw = reg0f->RDSD;
731
732 raw[0] = blk_c.refined.highByte;
733 raw[1] = blk_c.refined.lowByte;
734 raw[2] = blk_d.refined.highByte;
735 raw[3] = blk_d.refined.lowByte;
736
737 for (i = j = 0; i < 4; i++)
738 {
739 if (raw[i] == 0xD || raw[i] == 0xA)
740 {
741 c[j] = '\0';
742 return;
743 }
744 if (raw[i] >= 32)
745 {
746 c[j] = raw[i];
747 j++;
748 }
749 else
750 {
751 c[i] = ' ';
752 }
753 }
754}
755
756/**
757 * @ingroup GA04
758 *
759 * @brief Gets the RDS Text when the message is of the Group Type 2 version A
760 * @return char* The string (char array) with the content (Text) received from group 2A
761 */
762char *RDA5807::getRdsText(void)
763{
764 static int rdsTextAdress2A;
765 rds_blockb blkb;
766
768
769 blkb.blockB = reg0d->RDSB;
770 rdsTextAdress2A = blkb.group2.address;
771
772 if (rdsTextAdress2A >= 16)
773 rdsTextAdress2A = 0;
774
775 getNext4Block(&rds_buffer2A[rdsTextAdress2A * 4]);
776 rdsTextAdress2A += 4;
777 return rds_buffer2A;
778}
779
780/**
781 * @ingroup GA04
782 * @todo RDS Dynamic PS or Scrolling PS support
783 * @brief Gets the station name and other messages.
784 *
785 * @return char* should return a string with the station name.
786 * However, some stations send other kind of messages
787 */
789{
790 static int rdsTextAdress0A;
791 rds_blockb blkb;
792
794 blkb.blockB = reg0d->RDSB;
795
796 if (blkb.group0.groupType == 0)
797 {
798 // Process group type 0
799 rdsTextAdress0A = blkb.group0.address;
800 if (rdsTextAdress0A >= 0 && rdsTextAdress0A < 4)
801 {
802 getNext2Block(&rds_buffer0A[rdsTextAdress0A * 2]);
803 rds_buffer0A[8] = '\0';
804 return rds_buffer0A;
805 }
806 }
807 return NULL;
808}
809
810/**
811 * @ingroup @ingroup GA04
812 *
813 * @brief Gets the Text processed for the 2A group
814 *
815 * @return char* string with the Text of the group A2
816 */
818{
819 static int rdsTextAdress2A;
820 rds_blockb blkb;
821
823
824 blkb.blockB = reg0d->RDSB;
825 rdsTextAdress2A = blkb.group2.address;
826
827 if (blkb.group2.groupType == 2)
828 {
829 // Process group 2A
830 // Decode B block information
831 if (rdsTextAdress2A >= 0 && rdsTextAdress2A < 16)
832 {
833 getNext4Block(&rds_buffer2A[rdsTextAdress2A * 4]);
834 rds_buffer2A[63] = '\0';
835 return rds_buffer2A;
836 }
837 }
838 return NULL;
839}
840
841/**
842 * @ingroup GA04
843 * @brief Gets the Text processed for the 2B group
844 * @return char* string with the Text of the group AB
845 */
847{
848 static int rdsTextAdress2B;
849 rds_blockb blkb;
850
852 blkb.blockB = reg0d->RDSB;
853 if (blkb.group2.groupType == 2)
854 {
855 // Process group 2B
856 rdsTextAdress2B = blkb.group2.address;
857 if (rdsTextAdress2B >= 0 && rdsTextAdress2B < 16)
858 {
859 getNext2Block(&rds_buffer2B[rdsTextAdress2B * 2]);
860 return rds_buffer2B;
861 }
862 }
863 return NULL;
864}
865
866/**
867 * @ingroup GA04
868 * @todo Need to check. It is working on SI4735 and Si4703. Why not here?
869 * @brief Gets the RDS time and date when the Group type is 4
870 * @return char* a string with hh:mm +/- offset
871 */
873{
874 // Under Test and construction
875 // Need to check the Group Type before.
876 rds_date_time dt;
877 word16_to_bytes blk_b, blk_c, blk_d;
878 rds_blockb blkb;
879
881
882 blk_b.raw = blkb.blockB = reg0d->RDSB;
883 blk_c.raw = reg0e->RDSC;
884 blk_d.raw = reg0f->RDSD;
885
886 uint16_t minute;
887 uint16_t hour;
888
889 if (blkb.group0.groupType == 4)
890 {
891 char offset_sign;
892 int offset_h;
893 int offset_m;
894
895 // uint16_t y, m, d;
896
897 dt.raw[4] = blk_b.refined.lowByte;
898 dt.raw[5] = blk_b.refined.highByte;
899
900 dt.raw[2] = blk_c.refined.lowByte;
901 dt.raw[3] = blk_c.refined.highByte;
902
903 dt.raw[0] = blk_d.refined.lowByte;
904 dt.raw[1] = blk_d.refined.highByte;
905
906 // Unfortunately it was necessary to wotk well on the GCC compiler on 32-bit
907 // platforms. See si47x_rds_date_time (typedef union) and CGG “Crosses boundary” issue/features.
908 // Now it is working on Atmega328, STM32, Arduino DUE, ESP32 and more.
909 minute = (dt.refined.minute2 << 2) | dt.refined.minute1;
910 hour = (dt.refined.hour2 << 4) | dt.refined.hour1;
911
912 offset_sign = (dt.refined.offset_sense == 1) ? '+' : '-';
913 offset_h = (dt.refined.offset * 30) / 60;
914 offset_m = (dt.refined.offset * 30) - (offset_h * 60);
915
916 sprintf(rds_time, "%02u:%02u %c%02u:%02u", hour, minute, offset_sign, offset_h, offset_m);
917
918 return rds_time;
919 }
920
921 return NULL;
922}
923
924/**
925 * @ingroup GA04
926 * @brief Gets the Rds Sync
927 * @details Returns true if RDS currently synchronized.
928 * @return true or false
929 */
931{
932 getStatus(REG0A);
933 return reg0a->refined.RDSS;
934}
935
936/**
937 * @ingroup GA04
938 * @brief Gets the current Block ID
939 * @details 1= the block id of register 0cH,0dH,0eH,0fH is E
940 * @details 0= the block id of register 0cH, 0dH, 0eH,0fH is A, B, C, D
941 * @return 0= the block id of register 0cH, 0dH, 0eH,0fH is A, B, C, D; 1 = the block id of register 0cH,0dH,0eH,0fH is E
942 */
944{
945 getStatus(REG0B);
946 return reg0b->refined.ABCD_E;
947}
948
949/**
950 * @ingroup GA04
951 * @brief Gets the current Status of block B
952 *
953 * Block Errors Level of RDS_DATA_1, and is always read as Errors Level of RDS BLOCK B (in RDS mode ) or E (in RBDS mode when ABCD_E flag is 1).
954 * | value | description |
955 * | ----- | ----------- |
956 * | 00 | 0 errors requiring correction |
957 * | 01 | 1~2 errors requiring correction |
958 * | 10 | 3~5 errors requiring correction |
959 * | 11 | 6+ errors or error in checkword, correction not possible |
960 *
961 * **Available only in RDS Verbose mode**
962 *
963 * @return value See table above.
964 */
966{
967 getStatus(REG0B);
968 return reg0b->refined.BLERB;
969}
970
971/**
972 * @ingroup GA04
973 * @brief Returns true when the RDS system has valid information
974 * @details Returns true if RDS currently synchronized; the information are A, B, C and D blocks; and no errors
975 * @return true or false
976 */
978 getStatus(REG0B);
979 return (reg0a->refined.RDSS && reg0b->refined.ABCD_E == 0 && reg0b->refined.BLERB == 0 );
980}
981
982/**
983 * @ingroup GA04
984 * @brief Sets RDS fifo mode enable
985 *
986 * @param value If true, it makes the the fifo mode enable.
987 * @return true or false
988 */
989void RDA5807::setRdsFifo(bool value) {
990 reg04->refined.RDS_FIFO_EN = value;
991 setRegister(REG04,reg04->raw);
992}
993
994/**
995 * @ingroup GA04
996 * @brief Clear RDS fifo
997 *
998 * @param value If true, it makes the the fifo mode enable.
999 * @return true or false
1000 */
1002{
1003 reg04->refined.RDS_FIFO_CLR = 1;
1004 setRegister(REG04, reg04->raw);
1005}
1006
1007
1008
1009
1010
1011/** @defgroup G05 Tools method
1012 * @details A set of functions used to support other functions
1013*/
1014
1015/**
1016 * @ingroup G05 Covert numbers to char array
1017 * @brief Converts a number to a char array
1018 * @details It is useful to mitigate memory space used by functions like sprintf or othetr generic similar functions
1019 * @details You can use it to format frequency using decimal or tousand separator and also to convert smalm numbers.
1020 *
1021 * @param value value to be converted
1022 * @param strValue char array that will be receive the converted value
1023 * @param len final string size (in bytes)
1024 * @param dot the decimal or tousand separator position
1025 * @param separator symbol "." or ","
1026 * @param remove_leading_zeros if true removes up to two leading zeros (default is true)
1027 */
1028void RDA5807::convertToChar(uint16_t value, char *strValue, uint8_t len, uint8_t dot, uint8_t separator, bool remove_leading_zeros)
1029{
1030 char d;
1031 for (int i = (len - 1); i >= 0; i--)
1032 {
1033 d = value % 10;
1034 value = value / 10;
1035 strValue[i] = d + 48;
1036 }
1037 strValue[len] = '\0';
1038 if (dot > 0)
1039 {
1040 for (int i = len; i >= dot; i--)
1041 {
1042 strValue[i + 1] = strValue[i];
1043 }
1044 strValue[dot] = separator;
1045 }
1046
1047 if (remove_leading_zeros) {
1048 if (strValue[0] == '0')
1049 {
1050 strValue[0] = ' ';
1051 if (strValue[1] == '0')
1052 strValue[1] = ' ';
1053 }
1054 }
1055}
1056
1057
1058/**
1059 * @ingroup G05 Check the I2C buss address
1060 * @brief Check the I2C bus address
1061 *
1062 * @param uint8_t address Array - this array will be populated with the I2C bus addresses found (minimum three elements)
1063 * @return 0 if no i2c device is found; -1 if error is found or n > 0, where n is the number of I2C bus address found
1064 */
1065int RDA5807::checkI2C(uint8_t *addressArray) {
1066 Wire.begin();
1067 int error, address;
1068 int idx = 0;
1069 for(address = 1; address < 127; address++ ) {
1070 Wire.beginTransmission(address);
1071 error = Wire.endTransmission();
1072 if (error == 0) {
1073 addressArray[idx] = address;
1074 idx++;
1075 }
1076 else if (error==4)
1077 return -1;
1078 }
1079 return idx;
1080}
1081
1082
1083
1084
1085/**
1086 * @defgroup GA06 I2S Functions
1087 * @section GA06 I2S
1088 * @details When setting I2S_ENABLE (register 04) bit is high, the RDA5807FP can get the output signals SCK, WS, SD signals from GPIO3, GPIO1 and GPIO2 (I2S master)
1089 */
1090
1091
1092/**
1093 * @ingroup GA06 set I2S
1094 * @brief Configures all parameters for I2S
1095 * @details I2S setup must be enabled
1096 * @details I2S_SW_CNT can be: I2S_WS_STEP_48, I2S_WS_STEP_44_1, I2S_WS_STEP_32, I2S_WS_STEP_24, I2S_WS_STEP_22_05, I2S_WS_STEP_16, I2S_WS_STEP_12, I2S_WS_STEP_11_025 or I2S_WS_STEP_8
1097 *
1098 * @param R_DELY If 1, R channel data delay 1T
1099 * @param L_DELY If 1, L channel data delay 1T
1100 * @param SCLK_O_EDGE If 1, invert sclk output when as master
1101 * @param SW_O_EDGE If 1, invert ws output when as master
1102 * @param I2S_SW_CNT Only valid in master mode. See table above
1103 * @param WS_I_EDGE If 0, use normal ws internally; If 1, inverte ws internally
1104 * @param DATA_SIGNED If 0, I2S output unsigned 16-bit audio data. If 1, I2S output signed 16-bit audio data.
1105 * @param SCLK_I_EDGE If 0, use normal sclk internally;If 1, inverte sclk internally
1106 * @param WS_LR Ws relation to l/r channel; If 0, ws=0 ->r, ws=1 ->l; If 1, ws=0 ->l, ws=1 ->r
1107 * @param SLAVE_MASTER I2S slave or master; 1 = slave; 0 = master
1108 * @param OPEN_MODE Open reserved register mode; 11=open behind registers writing function others: only open behind registers reading function
1109 *
1110 * @see RDA microelectronics RDA5807FP - SINGLE-CHIP BROADCAST FM RADIO TUNER pages 11 and 12
1111 *
1112 * @see setI2SOn
1113 */
1114void RDA5807::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 ) {
1115 reg06->refined.R_DELY = R_DELY;
1116 reg06->refined.L_DELY = L_DELY;
1117 reg06->refined.SCLK_O_EDGE = SCLK_O_EDGE;
1118 reg06->refined.SW_O_EDGE = SW_O_EDGE;
1119 reg06->refined.I2S_SW_CNT = I2S_SW_CNT;
1120 reg06->refined.WS_I_EDGE = WS_I_EDGE;
1121 reg06->refined.DATA_SIGNED = DATA_SIGNED;
1122 reg06->refined.SCLK_I_EDGE = SCLK_I_EDGE;
1123 reg06->refined.WS_LR = WS_LR;
1124 reg06->refined.SLAVE_MASTER = SLAVE_MASTER;
1125 reg06->refined.OPEN_MODE = OPEN_MODE;
1126
1127 setRegister(REG06,reg06->raw);
1128}
1129
1130
1131
1132/**
1133 * @ingroup GA06 set I2S on or off
1134 * @brief Enables I2S setup
1135 * @details When setting I2S_ENABLE (register 04) bit is high, the RDA5807FP you can get the output signals SCK, WS, SD signals from GPIO3, GPIO1 and GPIO2 (I2S master)
1136 *
1137 * @param value true or false
1138 */
1139void RDA5807::setI2SOn(bool value) {
1140 reg04->refined.I2S_ENABLE = value;
1141 setRegister(REG04,reg04->raw);
1142}
1143
1144
1145/**
1146 * @ingroup GA06 Sets I2S Slave or Master
1147 * @brief
1148 *
1149 * @param value true or false
1150 */
1151void RDA5807::setI2SMaster(bool value) {
1152 reg06->refined.SLAVE_MASTER = !value;
1153 setRegister(REG06,reg06->raw);
1154}
1155
1156
1157
1158/**
1159 * @ingroup GA06 Sets I2S STEP/SPEED
1160 * @brief Sets the speed in kbps. You can use the predefined constantes: I2S_WS_STEP_48, I2S_WS_STEP_44_1, I2S_WS_STEP_32,
1161 * @brief I2S_WS_STEP_24, I2S_WS_STEP_22_05, I2S_WS_STEP_16, I2S_WS_STEP_12, I2S_WS_STEP_11_025 or I2S_WS_STEP_8
1162 *
1163 * @param value value
1164 */
1165void RDA5807::setI2SSpeed(uint8_t value) {
1166 reg06->refined.I2S_SW_CNT = value;
1167 setRegister(REG06,reg06->raw);
1168}
1169
1170
1171/**
1172 * @ingroup GA06 Sets I2S Data Signed
1173 * @brief If 0, I2S output unsigned 16-bit audio data. If 1, I2S output signed 16-bit audio data.
1174 *
1175 * @param value true (1) or false (0)
1176 */
1177void RDA5807::setI2SDataSigned(bool value) {
1178 reg06->refined.DATA_SIGNED = value;
1179 setRegister(REG06,reg06->raw);
1180}
1181
1182
1183
1184
1185/**
1186 * @defgroup GA07 Audio Functions
1187 * @section GA07 Audio
1188 */
1189
1190
1191
1192/**
1193 * @ingroup GA07
1194 * @brief Sets Soft Mute Enable or disable
1195 * @param value true = enable; false=disable
1196 */
1197void RDA5807::setSoftmute(bool value)
1198{
1199 reg04->refined.SOFTMUTE_EN = value;
1200 setRegister(REG04, reg04->raw);
1201}
1202
1203
1204
1205
1206/**
1207 * @ingroup GA07
1208 * @brief Sets Audio mute or unmute
1209 * @param value TRUE = mute; FALSE = unmute
1210 */
1211void RDA5807::setMute(bool value)
1212{
1213 reg02->refined.SEEK = 0;
1214 reg02->refined.DMUTE = !value; // 1 = Normal operation; 0 = Mute
1215 setRegister(REG02,reg02->raw);
1216}
1217
1218/**
1219 * @ingroup GA07
1220 * @brief Sets audio output impedance high ow low
1221 * @param value TRUE = High; FALSE = Low
1222 */
1224{
1225 reg02->refined.SEEK = 0;
1226 reg02->refined.DHIZ = !value; // 0 = High impedance; 1 = Normal operation
1227 setRegister(REG02,reg02->raw);
1228}
1229
1230
1231/**
1232 * @ingroup GA07
1233 * @brief Sets audio Mono or stereo
1234 *
1235 * @param value TRUE = Mono; FALSE force stereo
1236 */
1237void RDA5807::setMono(bool value)
1238{
1239 reg02->refined.SEEK = 0;
1240 reg02->refined.MONO = value;
1241 setRegister(REG02, reg02->raw);
1242}
1243
1244/**
1245 * @ingroup GA07
1246 * @brief Sets Bass Boost
1247 *
1248 * @param value FALSE = Disable; TRUE = Enable
1249 */
1250void RDA5807::setBass(bool value)
1251{
1252 reg02->refined.SEEK = 0;
1253 reg02->refined.BASS = value;
1254 setRegister(REG02, reg02->raw);
1255}
1256
1257/**
1258 * @ingroup GA07
1259 * @brief Gets the current Stereo status
1260 *
1261 * @return TRUE if stereo;
1262 */
1264{
1265 getStatus(REG0A);
1266 return reg0a->refined.ST;
1267}
1268
1269
1270
1271/**
1272 * @ingroup GA07
1273 * @brief Sets the audio volume level
1274 *
1275 * @param value
1276 */
1277void RDA5807::setVolume(uint8_t value)
1278{
1279 if ( value > 15 ) value = 15;
1280
1281 reg05->refined.VOLUME = this->currentVolume = value;
1282 setRegister(REG05, reg05->raw);
1283}
1284
1285/**
1286 * @ingroup GA07
1287 * @brief Gets the current audio volume level
1288 *
1289 * @return uint8_t 0 to 15
1290 */
1292{
1293 return this->currentVolume;
1294}
1295
1296/**
1297 * @ingroup GA07
1298 * @brief Increments the audio volume
1299 *
1300 */
1302{
1303 if (this->currentVolume < 15)
1304 {
1305 this->currentVolume++;
1306 setVolume(this->currentVolume);
1307 }
1308}
1309
1310/**
1311 * @ingroup GA07
1312 * @brief Decrements the audio volume
1313 *
1314 */
1316{
1317 if (this->currentVolume > 0)
1318 {
1319 this->currentVolume--;
1320 setVolume(this->currentVolume);
1321 }
1322}
1323
1324
1325/**
1326 * @defgroup GA08 LNA setup and Signal status
1327 * @section GA08 LNA and Signal
1328 */
1329
1330/**
1331 * @ingroup GA08
1332 * @brief Sets LNA_ICSEL_BIT
1333 * @details Lna working current bit: 0=1.8mA; 1=2.1mA; 2=2.5mA; 3=3.0mA (default 0).
1334 * @param value - 0=1.8mA; 1=2.1mA; 2=2.5mA; 3=3.0mA
1335 */
1336void RDA5807::setLnaIcSel(uint8_t value ) {
1337 reg05->refined.LNA_ICSEL_BIT = value;
1338 setRegister(REG05,reg05->raw);
1339}
1340
1341/**
1342 * @ingroup GA08
1343 * @brief Sets LNA input port selection bit
1344 * @details YOu can select: 0 = no input; 1 = LNAN; 2 = LNAP; 3: dual port input
1345 * @param value - 0 = no input; 1 = LNAN; 2 = LNAP; 3: dual port input
1346 */
1347void RDA5807::setLnaPortSel(uint8_t value ) {
1348 reg05->refined.LNA_PORT_SEL = value;
1349 setRegister(REG05,reg05->raw);
1350}
1351
1352
1353/**
1354 * @ingroup GA08
1355 * @brief Gets the current Rssi
1356 * @details RSSI; 000000 = min; 111111 = max; RSSI scale is logarithmic.
1357 *
1358 * @return int
1359 */
1361{
1362 getStatus(REG0B);
1363 return reg0b->refined.RSSI;
1364}
#define REG02
Definition: RDA5807.h:61
#define REG07
Definition: RDA5807.h:66
#define REG0A
Definition: RDA5807.h:67
#define REG0B
Definition: RDA5807.h:68
#define REG05
Definition: RDA5807.h:64
#define REG04
Definition: RDA5807.h:63
#define REG03
Definition: RDA5807.h:62
#define REG06
Definition: RDA5807.h:65
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.
Definition: RDA5807.cpp:1028
int checkI2C(uint8_t *addressArray)
Check the I2C bus address.
Definition: RDA5807.cpp:1065
KT0915 Class.
Definition: RDA5807.h:556
void * getStatus(uint8_t reg)
Gets the register content of a given status register (from 0x0A to 0x0F)
Definition: RDA5807.cpp:108
void powerDown()
Power the receiver off.
Definition: RDA5807.cpp:220
void powerUp()
Powers the receiver on.
Definition: RDA5807.cpp:179
void setRegister(uint8_t reg, uint16_t value)
Sets a given value to a specific device register.
Definition: RDA5807.cpp:138
void softReset()
Resets the device.
Definition: RDA5807.cpp:169
void waitAndFinishTune()
Waits for Seek or Tune finish.
Definition: RDA5807.cpp:156
void setGpio(uint8_t gpioPin, uint8_t gpioSetup=0, int mcuPin=-1)
Sets the Device GPIO pins.
Definition: RDA5807.cpp:34
void setNewDemodulateMethod(bool value)
Sets new demodulate method. It can improve the receiver sensitivity about 1dB.
Definition: RDA5807.cpp:211
void getStatusRegisters()
Gets all current device status and RDS information registers (From 0x0A to 0x0F)
Definition: RDA5807.cpp:64
void setup(uint8_t clock_type=CLOCK_32K, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL)
Starts the device.
Definition: RDA5807.cpp:237
uint16_t getDeviceId()
Gets the Device identification.
Definition: RDA5807.cpp:253
uint16_t getRealFrequency()
Gets the current frequency bases on the current channel.
Definition: RDA5807.cpp:399
uint16_t getRealChannel()
Gets the current channel stored in 0x0A status register.
Definition: RDA5807.cpp:377
void setSeekThreshold(uint8_t value)
Sets RSSI Seek Threshold.
Definition: RDA5807.cpp:478
void setFrequencyUp()
Increments the current frequency.
Definition: RDA5807.cpp:331
void setFmDeemphasis(uint8_t de)
Sets De-emphasis.
Definition: RDA5807.cpp:566
uint16_t getFrequency()
Gets the current frequency.
Definition: RDA5807.cpp:363
void setSoftBlendEnable(bool value)
Sets Soft Blend.
Definition: RDA5807.cpp:274
void setSpace(uint8_t space=0)
Sets the FM channel space.
Definition: RDA5807.cpp:522
void seek(uint8_t seek_mode, uint8_t direction)
Seek function.
Definition: RDA5807.cpp:410
void setBand(uint8_t band=0)
Sets the FM band. See table below.
Definition: RDA5807.cpp:499
void setStep(uint8_t step=100)
Sets the FM Step;.
Definition: RDA5807.cpp:536
void setAFC(bool value)
Sets AFC true or false.
Definition: RDA5807.cpp:285
void setChannel(uint16_t channel)
Sets the channel.
Definition: RDA5807.cpp:303
void setFrequency(uint16_t frequency)
Sets the frequency.
Definition: RDA5807.cpp:319
void setFrequencyDown()
Decrements the current frequency.
Definition: RDA5807.cpp:346
void seek(uint8_t seek_mode, uint8_t direction, void(*showFunc)())
Seek function.
Definition: RDA5807.cpp:450
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B
Definition: RDA5807.cpp:629
bool hasRdsInfo()
Returns true when the RDS system has valid information.
Definition: RDA5807.cpp:977
bool getRdsSync()
Gets the Rds Sync.
Definition: RDA5807.cpp:930
uint8_t getBlockId()
Gets the current Block ID.
Definition: RDA5807.cpp:943
uint16_t getRdsGroupType()
Return the group type.
Definition: RDA5807.cpp:643
void getNext4Block(char *c)
Process data received from group 2A.
Definition: RDA5807.cpp:723
char * getRdsText2A(void)
Gets the Text processed for the 2A group.
Definition: RDA5807.cpp:817
void setRDS(bool value)
Sets the RDS operation.
Definition: RDA5807.cpp:584
char * getRdsText0A(void)
Gets the station name and other messages.
Definition: RDA5807.cpp:788
void getNext2Block(char *c)
Process data received from group 2B.
Definition: RDA5807.cpp:686
char * getRdsText(void)
Gets the RDS Text when the message is of the Group Type 2 version A.
Definition: RDA5807.cpp:762
void clearRdsFifo()
Clear RDS fifo.
Definition: RDA5807.cpp:1001
char * getRdsText2B(void)
Gets the Text processed for the 2B group.
Definition: RDA5807.cpp:846
bool getRdsReady()
Returns true if RDS Ready.
Definition: RDA5807.cpp:616
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
Definition: RDA5807.cpp:658
uint8_t getErrorBlockB()
Gets the current Status of block B.
Definition: RDA5807.cpp:965
void setRdsFifo(bool value)
Sets RDS fifo mode enable.
Definition: RDA5807.cpp:989
uint8_t getRdsProgramType(void)
Returns the Program Type (extracted from the Block B)
Definition: RDA5807.cpp:672
void setRBDS(bool value)
Sets the RBDS operation.
Definition: RDA5807.cpp:598
char * getRdsTime()
Gets the RDS time and date when the Group type is 4.
Definition: RDA5807.cpp:872
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.
Definition: RDA5807.cpp:1114
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,...
Definition: RDA5807.cpp:1165
void setI2SMaster(bool value)
Definition: RDA5807.cpp:1151
void setI2SDataSigned(bool value)
If 0, I2S output unsigned 16-bit audio data. If 1, I2S output signed 16-bit audio data.
Definition: RDA5807.cpp:1177
void setI2SOn(bool value)
Enables I2S setup.
Definition: RDA5807.cpp:1139
bool isStereo()
Gets the current Stereo status.
Definition: RDA5807.cpp:1263
void setVolume(uint8_t value)
Sets the audio volume level.
Definition: RDA5807.cpp:1277
uint8_t getVolume()
Gets the current audio volume level.
Definition: RDA5807.cpp:1291
void setBass(bool value)
Sets Bass Boost.
Definition: RDA5807.cpp:1250
void setVolumeUp()
Increments the audio volume.
Definition: RDA5807.cpp:1301
void setVolumeDown()
Decrements the audio volume.
Definition: RDA5807.cpp:1315
void setAudioOutputHighImpedance(bool value)
Sets audio output impedance high ow low.
Definition: RDA5807.cpp:1223
void setMono(bool value)
Sets audio Mono or stereo.
Definition: RDA5807.cpp:1237
void setSoftmute(bool value)
Sets Soft Mute Enable or disable.
Definition: RDA5807.cpp:1197
void setMute(bool value)
Sets Audio mute or unmute.
Definition: RDA5807.cpp:1211
void setLnaIcSel(uint8_t value)
Sets LNA_ICSEL_BIT.
Definition: RDA5807.cpp:1336
int getRssi()
Gets the current Rssi.
Definition: RDA5807.cpp:1360
void setLnaPortSel(uint8_t value)
Sets LNA input port selection bit.
Definition: RDA5807.cpp:1347