PU2CLR RDA5807 Arduino Library 1.1.8
Arduino Library for RDA5807 Devices - By Ricardo Lima Caratti
Loading...
Searching...
No Matches
RDA5807.h
Go to the documentation of this file.
1
2/**
3 * @mainpage PU2CLR rda Arduino Library
4 * @brief PU2CLR rda Arduino Library implementation. <br>
5 * @details This library works with I2C protocol and can provide an easier interface for controlling the RDA5807M devices.<br>
6 * @details This is an Arduino library was implemented based on RDA5807M - SINGLE-CHIP BROADCAST FMRADIO TUNER document from RDA microeletronics.
7 * @details and RDA microelectronics RDA5807FP - SINGLE-CHIP BROADCAST FM RADIO TUNER
8 *
9 * @details IMPORTANT:
10 * @details The RDA5807M can be accessed by using two I2C bus address.
11 * @details If you need to access a specific register, use the 0x11 buss adress.
12 * @details If you need to access a set o register, use the 0x10 buss adress.
13 *
14 * @see RDA5807M - SINGLE-CHIP BROADCAST FMRADIO TUNER; page 5.
15 * @see the methods setRegister, getDirectRegister and getStatusRegisters
16 *
17 * This library can be freely distributed using the MIT Free Software model.
18 * Copyright(c) 2020 Ricardo Lima Caratti.
19 * Contact : pu2clr @gmail.com
20 *
21 */
22
23#ifndef _RDA5807_H // Prevent this file from being compiled more than once
24#define _RDA5807_H
25
26#include <Arduino.h>
27#include <Wire.h>
28
29#define MAX_DELAY_AFTER_OSCILLATOR 100 // Max delay after the crystal oscilator becomes active
30
31#define I2C_ADDR_DIRECT_ACCESS 0x11 //!< Can be used to access a given register at a time.
32#define I2C_ADDR_FULL_ACCESS 0x10 //!< Can be used to access a set of register at a time.
33
34#define OSCILLATOR_TYPE_CRYSTAL 0 //!< Same OSCILLATOR_TYPE_PASSIVE (Legacy)
35#define OSCILLATOR_TYPE_PASSIVE 0 //!< Passive Crystal
36#define OSCILLATOR_TYPE_REFCLK 1 //!< Same OSCILLATOR_TYPE_ACTIVE (Lagacy)
37#define OSCILLATOR_TYPE_ACTIVE 1 //!< Reference clock (active crystal oscillator or signal generator)
38#define RLCK_NO_CALIBRATE_MODE_ON 1
39#define RLCK_NO_CALIBRATE_MODE_OFF 0
40
41#define CLOCK_32K 0b000 //!< 32.768kHz
42#define CLOCK_12M 0b001 //!< 12Mhz
43#define CLOCK_13M 0b010 //!< 13Mhz
44#define CLOCK_19_2M 0b011 //!< 19.2Mhz
45#define CLOCK_24M 0b101 //!< 24Mhz
46#define CLOCK_26M 0b110 //!< 26Mhz
47#define CLOCK_38_4M 0b111 //!< 38.4Mhz
48
49#define RDS_STANDARD 0 //!< RDS Mode.
50#define RDS_VERBOSE 1 //!< RDS Mode.
51
52#define RDA_FM_BAND_USA_EU 0 //!< 87.5–108 MHz (US / Europe, Default)
53#define RDA_FM_BAND_JAPAN_WIDE 1 //!< 76–91 MHz (Japan wide band)
54#define RDA_FM_BAND_WORLD 2 //!< 76–108 MHz (world wide)
55#define RDA_FM_BAND_SPECIAL 3 //!< 65 –76 MHz(East Europe) or 50 - 65MHz(see bit 9 of gegister 0x07)
56
57#define RDA_SEEK_WRAP 0 //!< Wrap at the upper or lower band limit and continue seeking
58#define RDA_SEEK_STOP 1 //!< Stop seeking at the upper or lower band limit
59#define RDA_SEEK_DOWN 0 //!< Seek Down
60#define RDA_SEEK_UP 1 //!< Seek UP
61
62#define REG00 0x00 //!< Register 0x00
63#define REG02 0x02 //!< Register 0x02
64#define REG03 0x03 //!< Register 0x03
65#define REG04 0x04 //!< Register 0x04
66#define REG05 0x05 //!< Register 0x05
67#define REG06 0x06 //!< Register 0x06
68#define REG07 0x07 //!< Register 0x07
69#define REG08 0x08 //!< Register 0x08
70#define REG0A 0x0A //!< Register 0x0A
71#define REG0B 0x0B //!< Register 0x0B
72#define REG0C 0x0C //!< Register 0x0C
73#define REG0D 0x0D //!< Register 0x0D
74#define REG0E 0x0E //!< Register 0x0E
75#define REG0F 0x0F //!< Register 0x0F
76
77#define SH_REG0A 0 //!< Shadow array position for register 0x0A
78#define SH_REG0B 1 //!< Shadow array position for register 0x0B
79#define SH_REG0C 2 //!< Shadow array position for register 0x0C - RDS Block A
80#define SH_REG0D 3 //!< Shadow array position for register 0x0D - RDS Block B
81#define SH_REG0E 4 //!< Shadow array position for register 0x0E - RDS Block C
82#define SH_REG0F 5 //!< Shadow array position for register 0x0F - RDS Block D
83
84#define I2S_WS_STEP_48 0b1000 //<! 48 kbps
85#define I2S_WS_STEP_44_1 0b0111 //<! 41.1 kbps
86#define I2S_WS_STEP_32 0b0110 //<! 32 kbps
87#define I2S_WS_STEP_24 0b0101 //<! 24 kbps
88#define I2S_WS_STEP_22_05 0b0100 //<! 22.05 kbps
89#define I2S_WS_STEP_16 0b0011 //<! 16 kbps
90#define I2S_WS_STEP_12 0b0010 //<! 12 kbps
91#define I2S_WS_STEP_11_025 0b0001 //<! 11.025 kbps
92#define I2S_WS_STEP_8 0b0000 //<! 8 kbps
93
94/**
95 * @defgroup GA01 Union, Structure and Defined Data Types
96 * @brief rda Defined Data Types
97 * @details Defined Data Types is a way to represent the rda registers information
98 * @details The information shown here was extracted from Datasheet:
99 * @details rda stereo FM digital tuning radio documentation.
100 */
101
102/**
103 * @ingroup GA01
104 * @brief Register 0x00
105 *
106 */
107typedef union
108{
109 struct
110 {
111 uint8_t LOW_CHIP_ID : 8; //!< Chip ifdef
112 uint8_t HIGH_CHIP_ID : 8;
113 } refined;
115} rda_reg00;
116
117/**
118 * @ingroup GA01
119 * @brief Register 0x01 - Dummy
120 * @details It is not documented by the RDA.
121 */
122typedef union
123{
124 struct
125 {
126 uint8_t lowByte;
127 uint8_t highByte;
128 } refined;
130} rda_reg01;
131
132/**
133 * @ingroup GA01
134 * @brief Register 0x02 - Basic setup: RESET configuration;
135 * @details Clock type configuration; seek operation; Sterio/Mono; Bass; and Audio configuration
136 * @details The RDA5807M is RESET itself when power up. You also can use soft reset by triggering SOFT_RESET bit to 1.
137 * @details Seek begins in the direction specified by SEEKUP and ends when a channel is found, or the entire band has been searched.
138 * @details The SEEK bit is set low and the STC bit is set high when the seek operation completes.
139 * @details RCLK NON-CALIBRATE MODE. if 0=RCLK clock is always supply; if 1=RCLK clock is not always supply when FM work ( when 1, RDA5807M can’t directly support -20 °C ~70 °C temperature.
140 * @details Only suppory ±20°C temperature swing from tune point).
141 *
142 * Clock CLK_MODE table
143 *
144 * | Value | Clock |
145 * | ----- | --------- |
146 * | 000 | 32.768kHz |
147 * | 001 | 12Mhz |
148 * | 101 | 24Mhz |
149 * | 010 | 13Mhz |
150 * | 110 | 26Mhz |
151 * | 011 | 19.2Mhz |
152 * | 111 | 38.4Mhz |
153 */
154typedef union
155{
156 struct
157 {
158 uint8_t ENABLE : 1; //!< Power Up Enable; 0 = Disabled; 1 = Enabled
159 uint8_t SOFT_RESET : 1; //!< Soft reset; If 0, not reset; If 1, reset.
160 uint8_t NEW_METHOD : 1; //!< New Demodulate Method Enable, can improve 0 the receive sensitivity about 1dB.
161 uint8_t RDS_EN : 1; //!< RDS/RBDS enable; If 1, rds/rbds enable
162 uint8_t CLK_MODE : 3; //!< See table above
163 uint8_t SKMODE : 1; //!< Seek Mode; 0 = wrap at the upper or lower band limit and continue seeking; 1 = stop seeking at the upper or lower band limit
164 uint8_t SEEK : 1; //!< Seek; 0 = Disable stop seek; 1 = Enable;
165 uint8_t SEEKUP : 1; //!< Seek Up; 0 = Seek down; 1 = Seek up
166 uint8_t RCLK_DIRECT_IN : 1; //!< RCLK clock use the directly input mode. 1 = enable
167 uint8_t NON_CALIBRATE : 1; //!< 0=RCLK clock is always supply; 1=RCLK clock is not always supply when FM work
168 uint8_t BASS : 1; //!< Bass Boost; 0 = Disabled; 1 = Bass boost enabled
169 uint8_t MONO : 1; //!< Mono Select; 0 = Stereo; 1 = Force mono
170 uint8_t DMUTE : 1; //!< Mute Disable; 0 = Mute; 1 = Normal operation
171 uint8_t DHIZ : 1; //!< Audio Output High-Z Disable; 0 = High impedance; 1 = Normal operation
172 } refined;
174} rda_reg02;
175
176/**
177 * @ingroup GA01
178 * @brief Register 0x03
179 * @details Receiver configuratio
180 * @details The tune operation begins when the TUNE bit is set high. The STC bit is set high when the tune operation completes.
181 * @details The tune bit is reset to low automatically when the tune operation completes
182 *
183 * Channel space table
184 *
185 * | Value | Description |
186 * | ----- | ----------- |
187 * | 00 | 100KHz |
188 * | 01 | 200KHz |
189 * | 10 | 50KHz |
190 * | 11 | 25KHz |
191 *
192 *
193 * FM band table
194 *
195 * | Value | Description |
196 * | ----- | --------------------------- |
197 * | 00 | 87–108 MHz (US/Europe) |
198 * | 01 | 76–91 MHz (Japan) |
199 * | 10 | 76–108 MHz (world wide) |
200 * | 11 | 65 –76 MHz (East Europe) or 50-65MHz (see bit 9 of gegister 0x06) |
201 *
202 * Channel select table
203 *
204 * | BAND | Description |
205 * | ------ | -------------------------------------------------- |
206 * | 0 | Frequency = Channel Spacing (kHz) x CHAN+ 87.0 MHz |
207 * | 1 or 2 | Frequency = Channel Spacing (kHz) x CHAN + 76.0 MHz |
208 * | 3 | Frequency = Channel Spacing (kHz) x CHAN + 65.0 MHz |
209 * IMPORTANT: CHAN is updated after a seek operation.
210 *
211 */
212typedef union
213{
214 struct
215 {
216 uint16_t SPACE : 2; //!< See Channel space table above
217 uint16_t BAND : 2; //!< Seet band table above
218 uint16_t TUNE : 1; //!< Tune; 0 = Disable; 1 = Enable
219 uint16_t DIRECT_MODE : 1; //!< Directly Control Mode, Only used when test
220 uint16_t CHAN : 10; //!< Channel Select.
221 } refined;
223} rda_reg03;
224
225/**
226 * @ingroup GA01
227 * @brief Register 0x04
228 * @details Receiver properties
229 * @details Volume scale is logarithmic When 0000, output mute and output impedance is very large
230 * @details Setting STCIEN = 1 will generate a low pulse on GPIO2 when the interrupt occurs.
231 */
232typedef union
233{
234 struct
235 {
236 uint8_t GPIO1 : 2; //!< General Purpose I/O 1. when gpio_sel=01; 00 = High impedance; 01 = Reserved; 10 = Low; 11 = High
237 uint8_t GPIO2 : 2; //!< General Purpose I/O 2. when gpio_sel=01; 00 = High impedance; 01 = Reserved; 10 = Low; 11 = High
238 uint8_t GPIO3 : 2; //!< General Purpose I/O 1. when gpio_sel=01; 00 = High impedance; 01 = Mono/Stereo indicator (ST); 10 = Low; 11 = High
239 uint8_t I2S_ENABLE : 1; //!< I2S enable; 0 = disabled; 1 = enabled.
240 uint8_t RSVD1 : 1;
241 uint8_t AFCD : 1; //!< AFC disable; If 0, afc work; If 1, afc disabled.
242 uint8_t SOFTMUTE_EN : 1; //!< If 1, softmute enable.
243 uint8_t RDS_FIFO_CLR : 1; //!< 1 = clear RDS fifo
244 uint8_t DE : 1; //!< De-emphasis; 0 = 75 μs; 1 = 50 μs
245 uint8_t RDS_FIFO_EN : 1; //!< 1 = RDS fifo mode enable.
246 uint8_t RBDS : 1; //!< 1 = RBDS mode enable; 0 = RDS mode only
247 uint8_t STCIEN : 1; //!< Seek/Tune Complete Interrupt Enable; 0 = Disable Interrupt; 1 = Enable Interrupt;
248 uint8_t RSVD2 : 1;
249 } refined;
251} rda_reg04;
252
253/**
254 * @ingroup GA01
255 * @brief Register 0x05
256 */
257typedef union
258{
259 struct
260 {
261 uint8_t VOLUME : 4; //!< DAC Gain Control Bits (Volume); 0000 = min volume; 1111 = max volume.
262 uint8_t LNA_ICSEL_BIT : 2; //!< Lna working current bit: 00=1.8mA; 01=2.1mA; 10=2.5mA; 11=3.0mA.
263 uint8_t LNA_PORT_SEL : 2; //!< LNA input port selection bit: 00: no input; 01: LNAN; 10: LNAP; 11: dual port input
264 uint8_t SEEKTH : 4; //!< Seek SNR Threshold value
265 uint8_t RSVD2 : 1;
266 uint8_t SEEK_MODE : 2; //!< Default value is 00; When = 10, will add the RSSI seek mode
267 uint8_t INT_MODE : 1; //!< If 0, generate 5ms interrupt; If 1, interrupt last until read reg0CH action occurs.
268 } refined;
270} rda_reg05;
271
272/**
273 * @ingroup GA01
274 * @brief Register 0x06
275 *
276 * I2S_SW_CNT values table
277 *
278 * | Value | Description |
279 * | ------- | ------------------ |
280 * | 0b1000 | WS_STEP_48 |
281 * | 0b0111 | WS_STEP=44.1kbps |
282 * | 0b0110 | WS_STEP=32kbps |
283 * | 0b0101 | WS_STEP=24kbps |
284 * | 0b0100 | WS_STEP=22.05kbps |
285 * | 0b0011 | WS_STEP=16kbps |
286 * | 0b0010 | WS_STEP=12kbps |
287 * | 0b0001 | WS_STEP=11.025kbps |
288 * | 0b0000 | WS_STEP=8kbps |
289 */
290typedef union
291{
292 struct
293 {
294 uint8_t R_DELY : 1; //!< If 1, R channel data delay 1T.
295 uint8_t L_DELY : 1; //!< If 1, L channel data delay 1T.
296 uint8_t SCLK_O_EDGE : 1; //!< If 1, invert sclk output when as master.
297 uint8_t SW_O_EDGE : 1; //!< If 1, invert ws output when as master.
298 uint8_t I2S_SW_CNT : 4; //!< Only valid in master mode. See table above
299 uint8_t WS_I_EDGE : 1; //!< If 0, use normal ws internally; If 1, inverte ws internally.
300 uint8_t DATA_SIGNED : 1; //!< If 0, I2S output unsigned 16-bit audio data. If 1, I2S output signed 16-bit audio data.
301 uint8_t SCLK_I_EDGE : 1; //!< If 0, use normal sclk internally;If 1, inverte sclk internally.
302 uint8_t WS_LR : 1; //!< Ws relation to l/r channel; If 0, ws=0 ->r, ws=1 ->l; If 1, ws=0 ->l, ws=1 ->r.
303 uint8_t SLAVE_MASTER : 1; //!< I2S slave or master; 1 = slave; 0 = master.
304 uint8_t OPEN_MODE : 2; //!< Open reserved register mode; 11=open behind registers writing function others: only open behind registers reading function.
305 uint8_t RSVD : 1;
306 } refined;
308} rda_reg06;
309
310/**
311 * @ingroup GA01
312 * @brief Register 0x07
313 */
314typedef union
315{
316 struct
317 {
318 uint8_t FREQ_MODE : 1; //!< If 1, then freq setting changed. Freq = 76000(or 87000) kHz + freq_direct (08H) kHz.
319 uint8_t SOFTBLEND_EN : 1; //!< If 1, Softblend enable
320 uint8_t SEEK_TH_OLD : 6; //!< Seek threshold for old seek mode, Valid when Seek_Mode=001
321 uint8_t RSVD1 : 1;
322 uint8_t MODE_50_60 : 1; //!< 1 = 65~76 MHz; 0 = 50~76MHz
323 uint8_t TH_SOFRBLEND : 5; //!< Threshold for noise soft blend setting, unit 2dB (default 0b10000).
324 uint8_t RSVD2 : 1;
325 } refined;
327} rda_reg07;
328
329/**
330 * @ingroup GA01
331 * @brief Register 0x08 - Direct Frequency
332 * @details Valid when freq_mode = 1
333 * @details Freq = 7600(or 8700) kHz + freq_direct (08H) kHz.
334 * @details Value to be stores is frequency - 7600 or 8700
335 */
336typedef union
337{
338 struct
339 {
340 uint8_t lowByte;
341 uint8_t highByte;
342 } refined;
344} rda_reg08;
345
346/**
347 * @ingroup GA01
348 * @brief Register 0x0A - Device current status
349 * @details The seek fail flag (SF) is set when the seek operation fails to find a channel with an RSSI level greater than SEEKTH[5:0].
350 * @details The seek/tune complete (STC) flag is set when the seek or tune operation completes.
351 *
352 *
353 * Channel table
354 *
355 * | BAND | Description |
356 * | ------ | -------------------------------------------------- |
357 * | 0 | Frequency = Channel Spacing (kHz) x CHAN+ 87.0 MHz |
358 * | 1 or 2 | Frequency = Channel Spacing (kHz) x CHAN + 76.0 MHz |
359 * | 3 | Frequency = Channel Spacing (kHz) x CHAN + 65.0 MHz |
360 *
361 */
362typedef union
363{
364 struct
365 {
366 uint16_t READCHAN : 10; //!< See Channel table . See table above
367 uint16_t ST : 1; //!< Stereo Indicator; 0 = Mono; 1 = Stereo
368 uint16_t BLK_E : 1; //!< When RDS enable: 1 = Block E has been found; 0 = no Block E has been found
369 uint16_t RDSS : 1; //!< RDS Synchronization; 0 = RDS decoder not synchronized(default); 1 = RDS decoder synchronized; Available only in RDS Verbose mode
370 uint16_t SF : 1; //!< Seek Fail. 0 = Seek successful; 1 = Seek failure;
371 uint16_t STC : 1; //!< Seek/Tune Complete. 0 = Not complete; 1 = Complete;
372 uint16_t RDSR : 1; //!< RDS ready; 0 = No RDS/RBDS group ready(default); 1 = New RDS/RBDS group ready.
373 } refined;
375} rda_reg0a;
376
377/**
378 * @ingroup GA01
379 * @brief Register 0x0B
380 * @details Current RDS and device status
381 *
382 * Errors Level table (Block Errors Level of RDS_DATA_0 and RDS_DATA_1.
383 * Always read as Errors Level of RDS BLOCKs A and B (in RDS mode ) or E (in RBDS mode when ABCD_E flag is 1).
384 *
385 * | Value | Description |
386 * | ----- | ----------- |
387 * | 00 | 0 errors requiring correction |
388 * | 01 | 1~2 errors requiring correction |
389 * | 10 | 3~5 errors requiring correction |
390 * | 10 | 6+ errors or error in checkword, correction not possible |
391 *
392 */
393typedef union
394{
395 struct
396 {
397 uint8_t BLERB : 2; //!< Block Errors Level of RDS_DATA_1
398 uint8_t BLERA : 2; //!< Block Errors Level of RDS_DATA_0
399 uint8_t ABCD_E : 1; //!< 1 = the block id of register 0cH,0dH,0eH,0fH is E; 0 = the block id of register 0cH, 0dH, 0eH,0fH is A, B, C, D
400 uint8_t RSVD1 : 2;
401 uint8_t FM_READY : 1; //!< 1=ready; 0=not ready.
402 uint8_t FM_TRUE : 1; //!< 1 = the current channel is a station; 0 = the current channel is not a station.
403 uint8_t RSSI : 7; //!< RSSI; 000000 = min; 111111 = max; RSSI scale is logarithmic.
404 } refined;
406} rda_reg0b;
407
408/**
409 * @ingroup GA01
410 * @brief Register 0x0C
411 * @details BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
412 *
413 */
414typedef union
415{
416 struct
417 {
418 uint8_t lowByte;
419 uint8_t highByte;
420 } refined;
421 uint16_t RDSA; //!< BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
422} rda_reg0c;
423
424/**
425 * @ingroup GA01
426 * @brief Register 0x0D
427 * @details BLOCK B ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
428 *
429 */
430typedef union
431{
432 struct
433 {
434 uint8_t lowByte;
435 uint8_t highByte;
436 } refined;
438} rda_reg0d;
439
440/**
441 * @ingroup GA01
442 * @brief Register 0x0E
443 * @details BLOCK C ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
444 *
445 */
446typedef union
447{
448 struct
449 {
450 uint8_t lowByte;
451 uint8_t highByte;
452 } refined;
454} rda_reg0e;
455
456/**
457 * @ingroup GA01
458 * @brief Register 0x0F
459 * @details BLOCK D ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
460 *
461 */
462typedef union
463{
464 struct
465 {
466 uint8_t lowByte;
467 uint8_t highByte;
468 } refined;
470} rda_reg0f;
471
472/**
473 * @ingroup GA01
474 * @brief RDS Block B data type
475 *
476 * @details For GCC on System-V ABI on 386-compatible (32-bit processors), the following stands:
477 *
478 * 1) Bit-fields are allocated from right to left (least to most significant).
479 * 2) A bit-field must entirely reside in a storage unit appropriate for its declared type.
480 * Thus a bit-field never crosses its unit boundary.
481 * 3) Bit-fields may share a storage unit with other struct/union members, including members that are not bit-fields.
482 * Of course, struct members occupy different parts of the storage unit.
483 * 4) Unnamed bit-fields' types do not affect the alignment of a structure or union, although individual
484 * bit-fields' member offsets obey the alignment constraints.
485 *
486 * @see also https://en.wikipedia.org/wiki/Radio_Data_System
487 */
488typedef union
489{
490 // using uint16_t instead uint8_t to avoid Crossing boundary
491 struct
492 {
493 uint16_t address : 2; // Depends on Group Type and Version codes. If 0A or 0B it is the Text Segment Address.
494 uint16_t DI : 1; // Decoder Controll bit
495 uint16_t MS : 1; // Music/Speech
496 uint16_t TA : 1; // Traffic Announcement
497 uint16_t programType : 5; // PTY (Program Type) code
498 uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
499 uint16_t versionCode : 1; // (B0) => 0=A; 1=B
500 uint16_t groupType : 4; // Group Type code.
501 } group0;
502 struct
503 {
504 uint16_t address : 4; // Depends on Group Type and Version codes. If 2A or 2B it is the Text Segment Address.
505 uint16_t textABFlag : 1; // Do something if it chanhes from binary "0" to binary "1" or vice-versa
506 uint16_t programType : 5; // PTY (Program Type) code
507 uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
508 uint16_t versionCode : 1; // (B0) => 0=A; 1=B
509 uint16_t groupType : 4; // Group Type code.
510 } group2;
511 struct
512 {
513 uint16_t content : 4; // Depends on Group Type and Version codes.
514 uint16_t textABFlag : 1; // Do something if it chanhes from binary "0" to binary "1" or vice-versa
515 uint16_t programType : 5; // PTY (Program Type) code
516 uint16_t trafficProgramCode : 1; // (TP) => 0 = No Traffic Alerts; 1 = Station gives Traffic Alerts
517 uint16_t versionCode : 1; // (B0) => 0=A; 1=B
518 uint16_t groupType : 4; // Group Type code.
519 } refined;
521} rds_blockb;
522
523/**
524 * @ingroup GA01
525 * Group RDS type 4A ( RDS Date and Time)
526 * When group type 4A is used by the station, it shall be transmitted every minute according to EN 50067.
527 * This Structure uses blocks 2,3 and 5 (B,C,D)
528 *
529 * ATTENTION:
530 * To make it compatible with 8, 16 and 32 bits platforms and avoid Crossing boundary, it was necessary to
531 * split minute and hour representation.
532 */
533typedef union
534{
535 struct
536 {
537 uint32_t offset : 5; // Local Time Offset
538 uint32_t offset_sense : 1; // Local Offset Sign ( 0 = + , 1 = - )
539 uint32_t minute : 6; // UTC Minutes - 2 bits less significant (avoid Crossing boundary”).
540 uint32_t hour : 5; // UTC Hours - 4 bits less significant (avoid Crossing boundary”)
541 uint32_t mjd : 17; // Modified Julian Day Code
542 } refined;
544} rds_date_time;
545
546/**
547 * @ingroup GA01
548 * @brief Converts 16 bits word to two bytes
549 */
550typedef union
551{
552 struct
553 {
554 uint8_t lowByte;
555 uint8_t highByte;
556 } refined;
558} word16_to_bytes;
559
560/**
561 * @ingroup GA01
562 * @brief KT0915 Class
563 * @details This class implements all functions that will help you to control the KT0915 devices.
564 *
565 * @author PU2CLR - Ricardo Lima Caratti
566 */
568{
569
570protected:
571 uint16_t shadowStatusRegisters[6]; //!< shadow status registers
572 uint16_t shadowRegisters[9]; //!< shadow configuration registers
573
574 // Shadow device configuration register references (writable registers)
575 rda_reg00 *reg00 = (rda_reg00 *)&shadowRegisters[0]; // REG00;
576 rda_reg01 *reg01 = (rda_reg01 *)&shadowRegisters[1]; // REG01;
577 rda_reg02 *reg02 = (rda_reg02 *)&shadowRegisters[2]; // REG02;
578 rda_reg03 *reg03 = (rda_reg03 *)&shadowRegisters[3]; // REG03;
579 rda_reg04 *reg04 = (rda_reg04 *)&shadowRegisters[4]; // REG04;
580 rda_reg05 *reg05 = (rda_reg05 *)&shadowRegisters[5]; // REG05;
581 rda_reg06 *reg06 = (rda_reg06 *)&shadowRegisters[6]; // REG06;
582 rda_reg07 *reg07 = (rda_reg07 *)&shadowRegisters[7]; // REG07;
583 rda_reg08 *reg08 = (rda_reg08 *)&shadowRegisters[8]; // REG08;
584
585 // Shadow device status register references (read only registers)
586 rda_reg0a *reg0a = (rda_reg0a *)&shadowStatusRegisters[0]; // SH_REG0A;
587 rda_reg0b *reg0b = (rda_reg0b *)&shadowStatusRegisters[1]; // SH_REG0B;
588 rda_reg0c *reg0c = (rda_reg0c *)&shadowStatusRegisters[2]; // SH_REG0C;
589 rda_reg0d *reg0d = (rda_reg0d *)&shadowStatusRegisters[3]; // SH_REG0D;
590 rda_reg0e *reg0e = (rda_reg0e *)&shadowStatusRegisters[4]; // SH_REG0E;
591 rda_reg0f *reg0f = (rda_reg0f *)&shadowStatusRegisters[5]; // SH_REG0F;
592
593 uint16_t startBand[4] = {8700, 7600, 7600, 6500};
594 uint16_t endBand[4] = {10800, 9100, 10800, 7600}; //!< End FM band limit
595 uint16_t fmSpace[4] = {10, 20, 5, 1}; // Actually 100, 200, 50 and 25 kHz Channel Spacing. Just 100 and 50 kHz is working well.
596
597 char rds_buffer2A[65]; //!< RT - RDS Radio Text buffer - Program Information
598 char rds_buffer2B[33]; //!< RDS Radio Text buffer - Station Information
599 char rds_buffer0A[9]; //!< PS - RDS Basic tuning and switching information (Type 0 groups) - Station Name
600 char rds_time[25]; //!< CT - RDS date time received information - UTC Time
601 uint8_t oldTextABFlag; //!< Saves the latest value of the textABFlag. Useful to check chanhes.
602
603 char strFrequency[8]; // Used to store formated frequency
604
605protected:
608
614
615 int gpio1Control = -1; //!< Can be used to add control to the system via GPIO1 pin
616 int gpio2Control = -1; //!< Can be used to add control to the system via GPIO2 pin
617 int gpio3Control = -1; //!< Can be used to add control to the system via GPIO3 pin
618
622
624
625public:
626 /**
627 * @ingroup GA02
628 * @brief Set the Delay After Crystal On (default 500ms)
629 * @details Minimum time required for the oscillator to become stable
630 * @param ms_value Value in milliseconds
631 */
632 inline void setDelayAfterCrystalOn(uint8_t ms_value) { maxDelayAftarCrystalOn = ms_value; };
633
634 /**
635 * @ingroup GA02
636 * @brief Sets alternatives I2C bus address
637 * @details You do not need use this function on RDA5807M
638 * @param directAccess
639 * @param fullAccess
640 */
641 inline void setI2CBusAddrs(int directAccess, int fullAccess)
642 {
643 this->deviceAddressDirectAccess = directAccess;
644 this->deviceAddressFullAccess = fullAccess;
645 }
646
647 void getStatusRegisters();
648 word16_to_bytes getDirectRegister(uint8_t reg);
649 void *getStatus(uint8_t reg);
650 void setRegister(uint8_t reg, uint16_t value);
651
652 void setGpio(uint8_t gpioPin, uint8_t gpioSetup = 0, int mcuPin = -1);
653 void setInterruptMode(uint8_t value);
654
655 void waitAndFinishTune();
656
657 void softReset();
658
659 void powerUp();
660 void powerDown();
661
662 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);
663
664 void setNewDemodulateMethod(bool value);
665
666 void setAFC(bool value);
667
668 void setLnaIcSel(uint8_t value);
669 void setLnaPortSel(uint8_t value);
670 /**
671 * @ingroup GA08
672 * @brief Gets LNA_ICSEL_BIT current value
673 * @details Lna working current bit: 0=1.8mA; 1=2.1mA; 2=2.5mA; 3=3.0mA (default 0).
674 * @return 0=1.8mA; 1=2.1mA; 2=2.5mA; 3=3.0mA
675 *
676 * @return uint8_t
677 */
678 inline uint8_t getLnaIcSel() { return reg05->refined.LNA_ICSEL_BIT; };
679 /**
680 * @ingroup GA08
681 * @brief Gets current vaue of the LNA input port selection bit
682 * @details Values: 0 = no input; 1 = LNAN; 2 = LNAP; 3: dual port input
683 * @return 0 = no input; 1 = LNAN; 2 = LNAP; 3: dual port input
684 */
685 inline uint8_t getLnaPortSel() { return reg05->refined.LNA_PORT_SEL; };
686
687 void setFrequency(uint16_t frequency);
688
689 /**
690 * @ingroup GA03
691 * @brief Tunes the receiver at the first channel/frequency of the current band
692 * @details If the current band is 0, the lowest frequency is 87Mhz (8700)
693 * @see setFrequency, getFrequency, setFrequencyToEndBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand
694
695 */
696 inline void setFrequencyToBeginBand() { this->setFrequency(startBand[currentFMBand]); };
697
698 /**
699 * @ingroup GA03
700 * @brief Tunes the receiver at the last channel/frequency of the current band
701 * @details If the current band is 0, the highest frequency is 108MHz (10800)
702 * @see setFrequency, getFrequency, setFrequencyToBeginBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand
703 */
704 inline void setFrequencyToEndBand() { this->setFrequency(endBand[currentFMBand]); };
705
706 /**
707 * @ingroup GA03
708 * @brief gets the maximun frequency of the current band
709 * @return the last valid frequency of the current band
710 * @see setFrequency, getFrequency, setFrequencyToBeginBand, setFrequencyToEndBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand
711 */
712 inline uint16_t getMaximunFrequencyOfTheBand() { return endBand[currentFMBand]; };
713
714 /**
715 * @ingroup GA03
716 * @brief gets the minimum frequency of the current band
717 * @return the first valid frequency of the current band
718 * @see setFrequency, getFrequency, setFrequencyToBeginBand, setFrequencyToEndBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand
719 */
720 inline uint16_t getMinimumFrequencyOfTheBand() { return startBand[currentFMBand]; };
721
723 void setFrequencyUp();
724 void setFrequencyDown();
725
726 void setDirectFrequency(uint16_t frequency);
727 void setFrequencyMode(uint8_t value);
728
731 void setChannel(uint16_t channel);
732 void seek(uint8_t seek_mode, uint8_t direction);
733 void seek(uint8_t seek_mode, uint8_t direction, void (*showFunc)());
734 void setSeekThreshold(uint8_t value);
735
736 void setBand(uint8_t band = 0);
737 /**
738 * @ingroup GA03
739 * @brief Returns the current band
740 * @see FM Band table
741 * @return uint8_t
742 */
743 inline uint8_t getBand() { return reg03->refined.BAND; };
744
745 void setSpace(uint8_t space = 0);
746 void setStep(uint8_t step = 100);
747 /**
748 * @ingroup GA03
749 * @brief Returns the current Band Space
750 * @return uint8_t value (0 = 100kHz, 1 = 200kHz, 2 = 50kHz e 3 = 25kHz)
751 */
752 inline uint8_t getSpace() { return reg03->refined.SPACE; };
753
754 void setBand3_50_65_Mode(uint8_t band3Mode);
756
757 int getRssi();
758
759 /**
760 * @ingroup GA03
761 * @brief Returns true if the current channel is a station.
762 * @return true or false
763 */
764 inline bool isFmTrue() { return reg0b->refined.FM_TRUE; };
765
766 /**
767 * @ingroup GA03
768 * @brief Returns true if the FM is ready.
769 * @return true or false
770 */
771 inline bool isFmReady() { return reg0b->refined.FM_READY; };
772
774
775 // Audio setup
776
777 void setSoftmute(bool value);
778 /**
779 * @ingroup GA07
780 * @brief Gets the softmute status
781 * @return true if enabled
782 */
783 inline bool isSoftmuted() { return reg04->refined.SOFTMUTE_EN; };
784
785 void setMono(bool value);
786 void setBass(bool value);
787 bool isStereo();
788
789 /**
790 * @ingroup GA07
791 * @brief Sets the system to use a LED to indicate Stereo or Mono.
792 * @details Call this function to setup the GPIO3 of the RDA5807FP (pin 15) to turn a LED on or OFF.
793 * @details When Stereo, the GPIO3 is HIGH.
794 * @code {.cpp}
795 * #include <RDA5807.h>
796 * RDA5807 rx;
797 * void setup() {
798 * rx.setup();
799 * rx.setFrequency(10390); // Tunes in 103.9 MHz
800 * rx.setLedStereoIndicator(true); // The GPIO3 (pin 15 of the RDA5807) can use to turn a LED on when Stereo
801 * }
802 * void loop() {
803 * }
804 * @endcode
805 *
806 * @param value true or false.
807 * @see setGpio, isStereo
808 */
809 inline void setLedStereoIndicator(bool value = true) { this->setGpio(3, value); };
810
811 void setMute(bool value);
812 /**
813 * @ingroup GA07
814 * @brief Gets Audio Mute Status
815 * @return True if muted
816 */
817 inline bool isMuted() { return !reg02->refined.DMUTE; };
818
819 /**
820 * @ingroup GA07
821 * @brief Gets true if the output audio impedance is high
822 * @return True or false
823 */
824 inline bool isAudioOutputHighImpedance() { return !reg02->refined.DHIZ; };
825
826 void setAudioOutputHighImpedance(bool value);
827 void setSoftBlendEnable(bool value);
828
829 void setVolume(uint8_t value);
831 void setVolumeUp();
832 void setVolumeDown();
833
834 void setFmDeemphasis(uint8_t de);
835
836 //******** RDS methods
837 void setRDS(bool value);
838 void setRBDS(bool value);
839 void setRdsFifo(bool value);
840 void clearRdsFifo(bool value = 1);
841 void clearRdsBuffer();
842
843 bool getRdsReady();
844 bool getRdsAllData(char **stationName, char **stationInformation, char **programInformation, char **utcTime);
845 uint8_t getRdsFlagAB(void);
846 bool isNewRdsFlagAB(void);
850 void getNext2Block(char *c);
851 void getNext4Block(char *c);
852
853 char *getRdsText0A(void);
854 /**
855 * @ingroup GA04
856 * @brief Gets the Station Name
857 * @details Alias for getRdsText0A
858 * @details ATTENTION: You must call getRdsReady before calling this function.
859 * @return char* should return a string with the station name. However, some stations send other kind of messages
860 * @see getRdsText0A
861 */
862 inline char *getRdsStationName(void) { return getRdsText0A(); };
863
864 char *getRdsText2A(void);
865 /**
866 * @ingroup @ingroup GA04
867 * @brief Gets the Program Information
868 * @details Process the program information data. Same getRdsText2A(). It is a alias for getRdsText2A.
869 * @details ATTENTION: You must call getRdsReady before calling this function.
870 * @return char array with the program information (63 bytes)
871 * @see getRdsText2A
872 */
873 inline char *getRdsProgramInformation(void) { return getRdsText2A(); };
874
875 char *getRdsText2B(void);
876 /**
877 * @ingroup GA04
878 * @brief Gets the Station Information.
879 * @details ATTENTION: You must call getRdsReady before calling this function.
880 * @return char array with the Text of Station Information (33 bytes)
881 * @see getRdsReady
882 */
883 inline char *getRdsStationInformation(void) { return getRdsText2B(); };
884
885 char *getRdsTime();
886 char *getRdsLocalTime();
887
888 /**
889 * @ingroup GA04
890 * @brief Gets the current Block ID
891 * @details You must call getRdsReady before calling this function
892 * @see getRdsReady
893 * @details 1= the block id of register 0cH,0dH,0eH,0fH is E
894 * @details 0= the block id of register 0cH, 0dH, 0eH,0fH is A, B, C, D
895 * @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
896 */
898 {
899 return reg0b->refined.ABCD_E;
900 }
901
902 /**
903 * @ingroup GA04
904 * @brief Gets the current Status of block A
905 * @details You must call getRdsReady before calling this function
906 * @see getRdsReady
907 * Block Errors Level of RDS_DATA_0, and is always read as Errors Level of RDS BLOCK A (in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
908 *
909 * | Bin | Dec | description |
910 * | ----- | ----- | ----------- |
911 * | 00 | 0 | 0 errors requiring correction |
912 * | 01 | 1 | 1~2 errors requiring correction |
913 * | 10 | 2 | 3~5 errors requiring correction |
914 * | 11 | 3 | 6+ errors or error in checkword, correction not possible |
915 *
916 * **Available only in RDS Verbose mode**
917 *
918 * @return value See table above.
919 */
921 {
922 return reg0b->refined.BLERA;
923 }
924
925 /**
926 * @ingroup GA04
927 * @brief Gets the current Status of block B
928 * @details You must call getRdsReady before calling this function
929 * @see getRdsReady
930 *
931 * 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).
932 *
933 * | Bin | Dec | description |
934 * | ----- | ----- | ----------- |
935 * | 00 | 0 | 0 errors requiring correction |
936 * | 01 | 1 | 1~2 errors requiring correction |
937 * | 10 | 2 | 3~5 errors requiring correction |
938 * | 11 | 3 | 6+ errors or error in checkword, correction not possible |
939 *
940 * **Available only in RDS Verbose mode**
941 *
942 * @return value See table above.
943 */
945 {
946 return reg0b->refined.BLERB;
947 }
948
949 /**
950 * @ingroup GA04
951 * @brief Returns true when the RDS system has valid information
952 * @details Returns true if RDS currently synchronized; the information are A, B, C and D blocks; and no errors
953 * @details You must call getRdsReady before calling this function
954 * @see getRdsReady
955 * @return true or false
956 */
957 inline bool hasRdsInfo()
958 {
959 return (reg0a->refined.RDSS && reg0b->refined.ABCD_E == 0 && reg0b->refined.BLERB == 0);
960 }
961
962 /**
963 * @ingroup GA04
964 * @brief Returns true when the RDS system has valid information
965 * @details You must call getRdsReady before calling this function
966 * @see getRdsReady
967 * @return true or false
968 */
969 inline bool hasRdsInfoAB()
970 {
971 return (reg0a->refined.RDSS && reg0b->refined.ABCD_E == 0 && reg0b->refined.BLERA == 0 && reg0b->refined.BLERB == 0);
972 }
973
974 /**
975 * @ingroup GA04
976 * @brief Gets the Rds Sync
977 * @details You must call getRdsReady before calling this function
978 * @see getRdsReady
979 * @details Returns true if RDS currently synchronized.
980 * @return true or false
981 */
982 inline bool getRdsSync()
983 {
984 return reg0a->refined.RDSS;
985 }
986
987 // I2S
988 void setI2SOn(bool value);
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);
990 void setI2SMaster(bool value);
991 void setI2SSpeed(uint8_t value);
992 void setI2SDataSigned(bool value);
993
994 // Tools (Helper)
995 void convertToChar(uint16_t value, char *strValue, uint8_t len, uint8_t dot, uint8_t separator, bool remove_leading_zeros = true);
996
997 /**
998 * @ingroup G05 Format the Frequency
999 * @brief Convert a numeric frequency to a formated string (char *) frequency
1000 *
1001 * @param uint16_t value - A given frequency to be formated
1002 * @param char *strValue - Formated frequency (Exe: 103,90) - Array of char ( minimal 7 elements )
1003 * @param char decimalSeparator - the symbol that separates the decimal part (Exe: . or ,)
1004 * @return point of strValue
1005 */
1006 inline char *formatFrequency(uint16_t value, char *strValue, char decimalSeparator)
1007 {
1008 this->convertToChar(value, strValue, 5, 3, decimalSeparator, true);
1009 return strValue;
1010 };
1011
1012 /**
1013 * @ingroup G05 Format the Frequency
1014 * @brief Convert the current frequency to a formated string (char *) frequency
1015 * @details The current frequency is the latest setted frequency by setFrequency, seek, setFrequencyUp and setFrequencyDown.
1016 * @param char decimalSeparator - the symbol that separates the decimal part (Exe: . or ,)
1017 * @return point char string strFrequency (member variable)
1018 * @see setFrequency, seek, setFrequencyUp and setFrequencyDown
1019 */
1020 inline char *formatCurrentFrequency(char decimalSeparator = ',')
1021 {
1022 this->convertToChar(this->currentFrequency, this->strFrequency, 5, 3, decimalSeparator, true);
1023 return this->strFrequency;
1024 };
1025
1026 int checkI2C(uint8_t *addressArray);
1027};
1028
1029#endif // _RDA5807_H
#define OSCILLATOR_TYPE_PASSIVE
Passive Crystal.
Definition: RDA5807.h:35
#define REG02
Register 0x02.
Definition: RDA5807.h:63
#define REG07
Register 0x07.
Definition: RDA5807.h:68
#define I2C_ADDR_DIRECT_ACCESS
Can be used to access a given register at a time.
Definition: RDA5807.h:31
#define REG0A
Register 0x0A.
Definition: RDA5807.h:70
#define REG0B
Register 0x0B.
Definition: RDA5807.h:71
#define REG05
Register 0x05.
Definition: RDA5807.h:66
#define REG04
Register 0x04.
Definition: RDA5807.h:65
#define REG08
Register 0x08.
Definition: RDA5807.h:69
#define CLOCK_32K
32.768kHz
Definition: RDA5807.h:41
#define REG03
Register 0x03.
Definition: RDA5807.h:64
#define REG06
Register 0x06.
Definition: RDA5807.h:67
#define I2C_ADDR_FULL_ACCESS
Can be used to access a set of register at a time.
Definition: RDA5807.h:32
#define RLCK_NO_CALIBRATE_MODE_OFF
Definition: RDA5807.h:39
#define MAX_DELAY_AFTER_OSCILLATOR
Definition: RDA5807.h:29
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:1301
int checkI2C(uint8_t *addressArray)
Check the I2C bus address.
Definition: RDA5807.cpp:1338
char * formatFrequency(uint16_t value, char *strValue, char decimalSeparator)
Convert a numeric frequency to a formated string (char *) frequency.
Definition: RDA5807.h:1006
char * formatCurrentFrequency(char decimalSeparator=',')
Convert the current frequency to a formated string (char *) frequency.
Definition: RDA5807.h:1020
char rds_buffer0A[9]
PS - RDS Basic tuning and switching information (Type 0 groups) - Station Name.
Definition: RDA5807.h:599
int gpio1Control
Can be used to add control to the system via GPIO1 pin.
Definition: RDA5807.h:615
uint16_t raw
Definition: RDA5807.h:405
rda_reg03 * reg03
Definition: RDA5807.h:578
uint16_t currentFrequency
Definition: RDA5807.h:610
rda_reg0f * reg0f
Definition: RDA5807.h:591
int deviceAddressDirectAccess
Definition: RDA5807.h:606
uint16_t raw
Definition: RDA5807.h:173
rda_reg0a * reg0a
Definition: RDA5807.h:586
uint16_t raw
Definition: RDA5807.h:326
uint8_t currentVolume
Definition: RDA5807.h:613
rda_reg07 * reg07
Definition: RDA5807.h:582
char rds_time[25]
CT - RDS date time received information - UTC Time.
Definition: RDA5807.h:600
uint16_t raw
Definition: RDA5807.h:114
uint16_t RDSD
Definition: RDA5807.h:469
uint16_t raw
Definition: RDA5807.h:374
uint8_t oscillatorType
Definition: RDA5807.h:620
uint16_t RDSC
Definition: RDA5807.h:453
int resetPin
Definition: RDA5807.h:609
uint16_t raw
Definition: RDA5807.h:129
rda_reg08 * reg08
Definition: RDA5807.h:583
uint16_t raw
Definition: RDA5807.h:250
uint16_t blockB
Definition: RDA5807.h:520
rda_reg0e * reg0e
Definition: RDA5807.h:590
rda_reg0d * reg0d
Definition: RDA5807.h:589
rda_reg04 * reg04
Definition: RDA5807.h:579
rda_reg01 * reg01
Definition: RDA5807.h:576
uint16_t raw
Definition: RDA5807.h:307
rda_reg02 * reg02
Definition: RDA5807.h:577
rda_reg0c * reg0c
Definition: RDA5807.h:588
uint16_t directFrequency
Definition: RDA5807.h:343
char strFrequency[8]
Definition: RDA5807.h:603
int deviceAddressFullAccess
Definition: RDA5807.h:607
char rds_buffer2B[33]
RDS Radio Text buffer - Station Information.
Definition: RDA5807.h:598
uint16_t raw
Definition: RDA5807.h:222
uint16_t maxDelayAftarCrystalOn
Definition: RDA5807.h:623
uint16_t RDSB
Definition: RDA5807.h:437
rda_reg05 * reg05
Definition: RDA5807.h:580
uint16_t RDSA
BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Definition: RDA5807.h:421
uint16_t raw
Definition: RDA5807.h:269
uint8_t currentFMBand
Definition: RDA5807.h:611
rda_reg0b * reg0b
Definition: RDA5807.h:587
int gpio2Control
Can be used to add control to the system via GPIO2 pin.
Definition: RDA5807.h:616
uint8_t raw[6]
Definition: RDA5807.h:543
uint16_t raw
Definition: RDA5807.h:557
uint8_t rlckNoCalibrate
Default is 0.
Definition: RDA5807.h:621
uint8_t currentFMSpace
Definition: RDA5807.h:612
int gpio3Control
Can be used to add control to the system via GPIO3 pin.
Definition: RDA5807.h:617
uint8_t oldTextABFlag
Saves the latest value of the textABFlag. Useful to check chanhes.
Definition: RDA5807.h:601
uint8_t clockFrequency
Definition: RDA5807.h:619
rda_reg06 * reg06
Definition: RDA5807.h:581
char rds_buffer2A[65]
RT - RDS Radio Text buffer - Program Information.
Definition: RDA5807.h:597
rda_reg00 * reg00
Definition: RDA5807.h:575
KT0915 Class.
Definition: RDA5807.h:568
void setDelayAfterCrystalOn(uint8_t ms_value)
Set the Delay After Crystal On (default 500ms)
Definition: RDA5807.h:632
void * getStatus(uint8_t reg)
Gets the register content of a given status register (from 0x0A to 0x0F)
Definition: RDA5807.cpp:124
void powerDown()
Power the receiver off.
Definition: RDA5807.cpp:240
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.
Definition: RDA5807.cpp:273
void powerUp()
Powers the receiver on.
Definition: RDA5807.cpp:197
void setRegister(uint8_t reg, uint16_t value)
Sets a given value to a specific device register.
Definition: RDA5807.cpp:154
void softReset()
Resets the device.
Definition: RDA5807.cpp:187
void waitAndFinishTune()
Waits for Seek or Tune finish.
Definition: RDA5807.cpp:173
void setGpio(uint8_t gpioPin, uint8_t gpioSetup=0, int mcuPin=-1)
Sets the Device GPIO pins.
Definition: RDA5807.cpp:34
word16_to_bytes getDirectRegister(uint8_t reg)
Gets the register content via direct access.
Definition: RDA5807.cpp:102
void setNewDemodulateMethod(bool value)
Sets new demodulate method. It can improve the receiver sensitivity about 1dB.
Definition: RDA5807.cpp:230
void getStatusRegisters()
Gets all current device status and RDS information registers (From 0x0A to 0x0F)
Definition: RDA5807.cpp:79
void setInterruptMode(uint8_t value)
Sets Interrupt Mode.
Definition: RDA5807.cpp:65
uint16_t getDeviceId()
Gets the Device identification.
Definition: RDA5807.cpp:291
void setI2CBusAddrs(int directAccess, int fullAccess)
Sets alternatives I2C bus address.
Definition: RDA5807.h:641
void setBand3_50_65_Mode(uint8_t band3Mode)
Sets the band 3 mode: 50 to 65 MHZ or 65 to 76 MHz.
Definition: RDA5807.cpp:635
uint16_t getRealFrequency()
Gets the current frequency bases on the current channel.
Definition: RDA5807.cpp:490
uint16_t getRealChannel()
Gets the current channel stored in 0x0A status register.
Definition: RDA5807.cpp:468
void setSeekThreshold(uint8_t value)
Sets RSSI Seek Threshold.
Definition: RDA5807.cpp:585
bool isFmReady()
Returns true if the FM is ready.
Definition: RDA5807.h:771
void setDirectFrequency(uint16_t frequency)
Sets the frequency using the reg08 (direct frequency)
Definition: RDA5807.cpp:385
void setFrequencyUp()
Increments the current frequency.
Definition: RDA5807.cpp:424
void setFmDeemphasis(uint8_t de)
Sets De-emphasis.
Definition: RDA5807.cpp:746
uint16_t getFrequency()
Gets the current frequency.
Definition: RDA5807.cpp:454
uint16_t getMinimumFrequencyOfTheBand()
gets the minimum frequency of the current band
Definition: RDA5807.h:720
void setSoftBlendEnable(bool value)
Sets Soft Blend.
Definition: RDA5807.cpp:308
void setSpace(uint8_t space=0)
Sets the FM channel space.
Definition: RDA5807.cpp:691
void setFrequencyToEndBand()
Tunes the receiver at the last channel/frequency of the current band.
Definition: RDA5807.h:704
bool isFmTrue()
Returns true if the current channel is a station.
Definition: RDA5807.h:764
void seek(uint8_t seek_mode, uint8_t direction)
Seek function.
Definition: RDA5807.cpp:518
void setBand(uint8_t band=0)
Sets the FM band. See table below.
Definition: RDA5807.cpp:621
void setStep(uint8_t step=100)
Sets the FM Step;.
Definition: RDA5807.cpp:705
void setAFC(bool value)
Sets AFC true or false.
Definition: RDA5807.cpp:320
uint16_t getMaximunFrequencyOfTheBand()
gets the maximun frequency of the current band
Definition: RDA5807.h:712
void setChannel(uint16_t channel)
Sets the channel.
Definition: RDA5807.cpp:338
uint8_t getSpace()
Returns the current Band Space.
Definition: RDA5807.h:752
uint8_t getBand()
Returns the current band.
Definition: RDA5807.h:743
void setFrequencyToBeginBand()
Tunes the receiver at the first channel/frequency of the current band.
Definition: RDA5807.h:696
void setFrequency(uint16_t frequency)
Sets the frequency.
Definition: RDA5807.cpp:372
void setFrequencyDown()
Decrements the current frequency.
Definition: RDA5807.cpp:439
void seek(uint8_t seek_mode, uint8_t direction, void(*showFunc)())
Seek function.
Definition: RDA5807.cpp:559
void setFrequencyMode(uint8_t value)
Sets the frequency mode. If 1, then freq setting changed.
Definition: RDA5807.cpp:397
uint8_t getBand3Status()
Gets the status of the Band3.
Definition: RDA5807.cpp:649
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B.
Definition: RDA5807.cpp:837
bool hasRdsInfo()
Returns true when the RDS system has valid information.
Definition: RDA5807.h:957
void clearRdsFifo(bool value=1)
Clear RDS fifo.
Definition: RDA5807.cpp:1262
void clearRdsBuffer()
Clear RDS Information (Station Name, Station Information, Program Information and Time)
Definition: RDA5807.cpp:1274
uint8_t getErrorBlockA()
Gets the current Status of block A.
Definition: RDA5807.h:920
bool getRdsSync()
Gets the Rds Sync.
Definition: RDA5807.h:982
uint8_t getBlockId()
Gets the current Block ID.
Definition: RDA5807.h:897
char * getRdsStationInformation(void)
Gets the Station Information.
Definition: RDA5807.h:883
uint16_t getRdsGroupType()
Return the group type.
Definition: RDA5807.cpp:913
void getNext4Block(char *c)
Process data received from group 2A.
Definition: RDA5807.cpp:993
char * getRdsText2A(void)
Gets the Program Information.
Definition: RDA5807.cpp:1065
void setRDS(bool value)
Sets the RDS operation.
Definition: RDA5807.cpp:778
char * getRdsText0A(void)
Gets the station name and other messages.
Definition: RDA5807.cpp:1035
void getNext2Block(char *c)
Process data received from group 2B.
Definition: RDA5807.cpp:956
char * getRdsProgramInformation(void)
Gets the Program Information.
Definition: RDA5807.h:873
char * getRdsLocalTime()
Gets the RDS time converted to local time.
Definition: RDA5807.cpp:1185
char * getRdsStationName(void)
Gets the Station Name.
Definition: RDA5807.h:862
bool hasRdsInfoAB()
Returns true when the RDS system has valid information.
Definition: RDA5807.h:969
char * getRdsText2B(void)
Gets the Station Information.
Definition: RDA5807.cpp:1095
bool getRdsReady()
Returns true if RDS Ready.
Definition: RDA5807.cpp:822
bool isNewRdsFlagAB(void)
Returns true if the Text Flag A/B has changed.
Definition: RDA5807.cpp:854
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
Definition: RDA5807.cpp:927
bool getRdsAllData(char **stationName, char **stationInformation, char **programInformation, char **utcTime)
Gets Station Name, Station Information, Program Information and utcTime.
Definition: RDA5807.cpp:893
uint8_t getErrorBlockB()
Gets the current Status of block B.
Definition: RDA5807.h:944
void setRdsFifo(bool value)
Sets RDS fifo mode enable.
Definition: RDA5807.cpp:1249
uint8_t getRdsProgramType(void)
Returns the Program Type (extracted from the Block B)
Definition: RDA5807.cpp:943
void setRBDS(bool value)
Sets the RBDS operation.
Definition: RDA5807.cpp:792
char * getRdsTime()
Gets the RDS UTC time and date when the Group type is 4.
Definition: RDA5807.cpp:1122
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:1386
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:1435
void setI2SMaster(bool value)
Definition: RDA5807.cpp:1422
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:1447
void setI2SOn(bool value)
Enables I2S setup.
Definition: RDA5807.cpp:1410
bool isStereo()
Gets the current Stereo status.
Definition: RDA5807.cpp:1526
bool isSoftmuted()
Gets the softmute status.
Definition: RDA5807.h:783
bool isAudioOutputHighImpedance()
Gets true if the output audio impedance is high.
Definition: RDA5807.h:824
void setVolume(uint8_t value)
Sets the audio volume level.
Definition: RDA5807.cpp:1556
uint8_t getVolume()
Gets the current audio volume level.
Definition: RDA5807.cpp:1571
void setLedStereoIndicator(bool value=true)
Sets the system to use a LED to indicate Stereo or Mono.
Definition: RDA5807.h:809
void setBass(bool value)
Sets Bass Boost.
Definition: RDA5807.cpp:1513
void setVolumeUp()
Increments the audio volume.
Definition: RDA5807.cpp:1581
void setVolumeDown()
Decrements the audio volume.
Definition: RDA5807.cpp:1595
void setAudioOutputHighImpedance(bool value)
Sets audio output impedance high ow low.
Definition: RDA5807.cpp:1487
void setMono(bool value)
Sets audio Mono or stereo.
Definition: RDA5807.cpp:1500
void setSoftmute(bool value)
Sets Soft Mute Enable or disable.
Definition: RDA5807.cpp:1463
bool isMuted()
Gets Audio Mute Status.
Definition: RDA5807.h:817
void setMute(bool value)
Sets Audio mute or unmute.
Definition: RDA5807.cpp:1474
void setLnaIcSel(uint8_t value)
Sets LNA_ICSEL_BIT.
Definition: RDA5807.cpp:1615
int getRssi()
Gets the current Rssi.
Definition: RDA5807.cpp:1640
uint8_t getLnaIcSel()
Gets LNA_ICSEL_BIT current value.
Definition: RDA5807.h:678
void setLnaPortSel(uint8_t value)
Sets LNA input port selection bit.
Definition: RDA5807.cpp:1627
uint8_t getLnaPortSel()
Gets current vaue of the LNA input port selection bit.
Definition: RDA5807.h:685