PU2CLR RDA5807 Arduino Library
1.0.1
Arduino Library for RDA5807 Devices - By Ricardo Lima Caratti
|
rda Defined Data Types More...
Data Structures | |
union | rda_reg00 |
Register 0x00. More... | |
struct | rda_reg00.refined |
union | rda_reg01 |
Register 0x01 - Dummy. More... | |
struct | rda_reg01.refined |
union | rda_reg02 |
Register 0x02 - Basic setup: RESET configuration;. More... | |
struct | rda_reg02.refined |
union | rda_reg03 |
Register 0x03. More... | |
struct | rda_reg03.refined |
union | rda_reg04 |
Register 0x04. More... | |
struct | rda_reg04.refined |
union | rda_reg05 |
Register 0x05. More... | |
struct | rda_reg05.refined |
union | rda_reg06 |
Register 0x06. More... | |
struct | rda_reg06.refined |
union | rda_reg07 |
Register 0x07. More... | |
struct | rda_reg07.refined |
union | rda_reg08 |
Register 0x08 - Direct Frequency. More... | |
struct | rda_reg08.refined |
union | rda_reg0a |
Register 0x0A - Device current status. More... | |
struct | rda_reg0a.refined |
union | rda_reg0b |
Register 0x0B. More... | |
struct | rda_reg0b.refined |
union | rda_reg0c |
Register 0x0C. More... | |
struct | rda_reg0c.refined |
union | rda_reg0d |
Register 0x0D. More... | |
struct | rda_reg0d.refined |
union | rda_reg0e |
Register 0x0E. More... | |
struct | rda_reg0e.refined |
union | rda_reg0f |
Register 0x0F. More... | |
struct | rda_reg0f.refined |
union | rds_blockb |
RDS Block B data type. More... | |
struct | rds_blockb.group0 |
struct | rds_blockb.group2 |
struct | rds_blockb.refined |
union | rda_rds_date_time |
struct | rda_rds_date_time.refined |
union | word16_to_bytes |
Converts 16 bits word to two bytes. More... | |
struct | word16_to_bytes.refined |
class | RDA5807 |
KT0915 Class. More... | |
rda Defined Data Types
Defined Data Types is a way to represent the rda registers information
The information shown here was extracted from Datasheet:
rda stereo FM digital tuning radio documentation.
union rda_reg00 |
Register 0x00.
Data Fields | ||
---|---|---|
struct rda_reg00 | refined | |
uint16_t | raw |
union rda_reg01 |
Register 0x01 - Dummy.
It is not documented by the RDA.
Data Fields | ||
---|---|---|
struct rda_reg01 | refined | |
uint16_t | raw |
union rda_reg02 |
Register 0x02 - Basic setup: RESET configuration;.
Clock type configuration; seek operation; Sterio/Mono; Bass; and Audio configuration
The RDA5807M is RESET itself when power up. You also can use soft reset by triggering SOFT_RESET bit to 1.
Seek begins in the direction specified by SEEKUP and ends when a channel is found, or the entire band has been searched.
The SEEK bit is set low and the STC bit is set high when the seek operation completes.
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.
Only suppory ±20°C temperature swing from tune point).
Clock CLK_MODE table
Value | Clock |
---|---|
000 | 32.768kHz |
001 | 12Mhz |
101 | 24Mhz |
010 | 13Mhz |
110 | 26Mhz |
011 | 19.2Mhz |
111 | 38.4Mhz |
Data Fields | ||
---|---|---|
struct rda_reg02 | refined | |
uint16_t | raw |
struct rda_reg02.refined |
union rda_reg03 |
Register 0x03.
Receiver configuratio
The tune operation begins when the TUNE bit is set high. The STC bit is set high when the tune operation completes.
The tune bit is reset to low automatically when the tune operation completes
Channel space table
Value | Description |
---|---|
00 | 100KHz |
01 | 200KHz |
10 | 50KHz |
11 | 25KHz |
FM band table
Value | Description |
---|---|
00 | 87–108 MHz (US/Europe) |
01 | 76–91 MHz (Japan) |
10 | 76–108 MHz (world wide) |
11 | 65 –76 MHz (East Europe) or 50-65MHz (see bit 9 of gegister 0x06) |
Channel select table
BAND | Description |
---|---|
0 | Frequency = Channel Spacing (kHz) x CHAN+ 87.0 MHz |
1 or 2 | Frequency = Channel Spacing (kHz) x CHAN + 76.0 MHz |
3 | Frequency = Channel Spacing (kHz) x CHAN + 65.0 MHz |
IMPORTANT: CHAN is updated after a seek operation.
Data Fields | ||
---|---|---|
struct rda_reg03 | refined | |
uint16_t | raw |
struct rda_reg03.refined |
union rda_reg04 |
Register 0x04.
Receiver properties
Volume scale is logarithmic When 0000, output mute and output impedance is very large
Setting STCIEN = 1 will generate a low pulse on GPIO2 when the interrupt occurs.
Data Fields | ||
---|---|---|
struct rda_reg04 | refined | |
uint16_t | raw |
struct rda_reg04.refined |
union rda_reg05 |
Register 0x05.
Data Fields | ||
---|---|---|
struct rda_reg05 | refined | |
uint16_t | raw |
struct rda_reg05.refined |
union rda_reg06 |
Register 0x06.
I2S_SW_CNT values table
Value | Description |
---|---|
0b1000 | WS_STEP_48 |
0b0111 | WS_STEP=44.1kbps |
0b0110 | WS_STEP=32kbps |
0b0101 | WS_STEP=24kbps |
0b0100 | WS_STEP=22.05kbps |
0b0011 | WS_STEP=16kbps |
0b0010 | WS_STEP=12kbps |
0b0001 | WS_STEP=11.025kbps |
0b0000 | WS_STEP=8kbps |
Data Fields | ||
---|---|---|
struct rda_reg06 | refined | |
uint16_t | raw |
struct rda_reg06.refined |
union rda_reg07 |
Register 0x07.
Data Fields | ||
---|---|---|
struct rda_reg07 | refined | |
uint16_t | raw |
struct rda_reg07.refined |
union rda_reg08 |
Register 0x08 - Direct Frequency.
Valid when freq_mode = 1
Freq = 7600(or 8700) kHz + freq_direct (08H) kHz.
Value to be stores is frequency - 7600 or 8700
Data Fields | ||
---|---|---|
struct rda_reg08 | refined | |
uint16_t | raw |
union rda_reg0a |
Register 0x0A - Device current status.
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].
The seek/tune complete (STC) flag is set when the seek or tune operation completes.
Channel table
BAND | Description |
---|---|
0 | Frequency = Channel Spacing (kHz) x CHAN+ 87.0 MHz |
1 or 2 | Frequency = Channel Spacing (kHz) x CHAN + 76.0 MHz |
3 | Frequency = Channel Spacing (kHz) x CHAN + 65.0 MHz |
Data Fields | ||
---|---|---|
struct rda_reg0a | refined | |
uint16_t | raw |
struct rda_reg0a.refined |
union rda_reg0b |
Register 0x0B.
Current RDS and device status
Errors Level table (Block Errors Level of RDS_DATA_0 and RDS_DATA_1. 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).
Value | Description |
---|---|
00 | 0 errors requiring correction |
01 | 1~2 errors requiring correction |
10 | 3~5 errors requiring correction |
10 | 6+ errors or error in checkword, correction not possible |
Data Fields | ||
---|---|---|
struct rda_reg0b | refined | |
uint16_t | raw |
struct rda_reg0b.refined |
union rda_reg0c |
Register 0x0C.
BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Data Fields | ||
---|---|---|
struct rda_reg0c | refined | |
uint16_t | RDSA | BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1) |
union rda_reg0d |
Register 0x0D.
BLOCK B ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Data Fields | ||
---|---|---|
struct rda_reg0d | refined | |
uint16_t | RDSB |
union rda_reg0e |
Register 0x0E.
BLOCK C ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Data Fields | ||
---|---|---|
struct rda_reg0e | refined | |
uint16_t | RDSC |
union rda_reg0f |
Register 0x0F.
BLOCK D ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Data Fields | ||
---|---|---|
struct rda_reg0f | refined | |
uint16_t | RDSD |
union rds_blockb |
RDS Block B data type.
For GCC on System-V ABI on 386-compatible (32-bit processors), the following stands:
1) Bit-fields are allocated from right to left (least to most significant). 2) A bit-field must entirely reside in a storage unit appropriate for its declared type. Thus a bit-field never crosses its unit boundary. 3) Bit-fields may share a storage unit with other struct/union members, including members that are not bit-fields. Of course, struct members occupy different parts of the storage unit. 4) Unnamed bit-fields' types do not affect the alignment of a structure or union, although individual bit-fields' member offsets obey the alignment constraints.
Data Fields | ||
---|---|---|
struct rds_blockb | group0 | |
struct rds_blockb | group2 | |
struct rds_blockb | refined | |
rda_reg0d | blockB |
struct rds_blockb.group0 |
struct rds_blockb.group2 |
struct rds_blockb.refined |
union rda_rds_date_time |
Group RDS type 4A ( RDS Date and Time) When group type 4A is used by the station, it shall be transmitted every minute according to EN 50067. This Structure uses blocks 2,3 and 5 (B,C,D)
ATTENTION: To make it compatible with 8, 16 and 32 bits platforms and avoid Crosses boundary, it was necessary to split minute and hour representation.
Data Fields | ||
---|---|---|
struct rda_rds_date_time | refined | |
uint8_t | raw[6] |
struct rda_rds_date_time.refined |
union word16_to_bytes |
Converts 16 bits word to two bytes.
Data Fields | ||
---|---|---|
struct word16_to_bytes | refined | |
uint16_t | raw |
class RDA5807 |
KT0915 Class.
This class implements all functions that will help you to control the KT0915 devices.
Public Member Functions | |
void | setDelayAfterCrystalOn (uint8_t ms_value) |
Set the Delay After Crystal On (default 500ms) More... | |
void | setI2CBusAddrs (int directAccess, int fullAccess) |
Sets alternatives I2C bus address. More... | |
void | getStatusRegisters () |
Gets all current device status and RDS information registers (From 0x0A to 0x0F) More... | |
void * | getStatus (uint8_t reg) |
Gets the register content of a given status register (from 0x0A to 0x0F) More... | |
void | setAllRegisters () |
Sets values to the device registers from 0x02 to 0x07. More... | |
void | setRegister (uint8_t reg, uint16_t value) |
Sets a given value to a specific device register. More... | |
void | setGpio (uint8_t gpioPin, uint8_t gpioSetup=0, int mcuPin=-1) |
Set the Device GPIO pins. More... | |
void | waitAndFinishTune () |
Waits for Seek or Tune finish. More... | |
void | softReset () |
Resets the device. More... | |
void | powerUp () |
Powers the receiver on. More... | |
void | powerDown () |
void | setup (uint8_t clock_type=CLOCK_32K, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL) |
Starts the device. More... | |
void | setFrequency (uint16_t frequency) |
Sets the frequency. More... | |
uint16_t | getFrequency () |
Gets the current frequency. More... | |
uint16_t | getRealFrequency () |
uint16_t | getRealChannel () |
void | setChannel (uint16_t channel) |
Sets the channel. More... | |
void | seek (uint8_t seek_mode, uint8_t direction) |
Seek function. More... | |
void | setSeekThreshold (uint8_t value) |
Sets RSSI Seek Threshold. More... | |
void | setBand (uint8_t band=1) |
Sets the FM band. See table below. More... | |
void | setSpace (uint8_t space=0) |
Sets the FM channel space. More... | |
int | getRssi () |
Gets the current Rssi. More... | |
void | setSoftmute (bool value) |
Sets Soft Mute Enable or disable. More... | |
void | setMono (bool value) |
Sets audio Mono or stereo. More... | |
void | setRDS (bool value) |
Sets the RDS operation. More... | |
void | setRBDS (bool value) |
Sets the RBDS operation. More... | |
void | clearRdsFifo () |
Clears RDS/RBDS FIFO. More... | |
uint8_t | getDeviceId () |
Gets the Device identification. More... | |
void | setMute (bool value) |
Sets Audio mute or unmute. More... | |
void | setVolume (uint8_t value) |
Sets the audio volume level. More... | |
uint8_t | getVolume () |
Gets the current audio volume level. More... | |
void | setVolumeUp () |
Increments the audio volume. More... | |
void | setVolumeDown () |
Decrements the audio volume. More... | |
void | setFmDeemphasis (uint8_t de) |
Sets De-emphasis. More... | |
Protected Attributes | |
int | deviceAddressDirectAccess = I2C_ADDR_DIRECT_ACCESS |
int | deviceAddressFullAccess = I2C_ADDR_FULL_ACCESS |
int | resetPin |
uint16_t | currentFrequency |
uint8_t | currentFMBand = 0 |
uint8_t | currentFMSpace = 0 |
uint8_t | currentVolume = 0 |
int | gpio1Control = -1 |
Can be used to add control to the system via GPIO1 pin. More... | |
int | gpio2Control = -1 |
Can be used to add control to the system via GPIO2 pin. More... | |
int | gpio3Control = -1 |
Can be used to add control to the system via GPIO3 pin. More... | |
uint8_t | clockType = CLOCK_32K |
uint8_t | oscillatorType = OSCILLATOR_TYPE_CRYSTAL |
uint16_t | maxDelayAftarCrystalOn = MAX_DELAY_AFTER_OSCILLATOR |
|
inline |
Set the Delay After Crystal On (default 500ms)
ms_value | Value in milliseconds |
void RDA5807::setGpio | ( | uint8_t | gpioPin, |
uint8_t | gpioSetup = 0 , |
||
int | mcuPin = -1 |
||
) |
Set the Device GPIO pins.
This method is useful to add control to the system via GPIO RDA devive pins.
For example: You can use these pins to control RDS and SEEK via interrupt.
GPIOs are General Purpose I/O pin.
GPIO setup
When gpioPin is 1; gpioSetup can be: 00 = High impedance; 01 = Reserved; 10 = Low; 11 = High
When gpioPin is 2; gpioSetup can be: 00 = High impedance; 01 = Interrupt (INT) 10 = Low; 11 = High
When gpioPin is 2; gpioSetup can be: 00 = High impedance; 01 = Mono/Stereo indicator (ST) = Low; 11 = High
gpioPin | gpio number (1, 2 or 3) |
gpioSetup | See description above |
mcuPip | MCU (Arduino) pin connected to the gpio |
|
protected |
Referenced by setI2CBusAddrs().
|
protected |
Referenced by setI2CBusAddrs().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Can be used to add control to the system via GPIO1 pin.
|
protected |
Can be used to add control to the system via GPIO2 pin.
|
protected |
Can be used to add control to the system via GPIO3 pin.
|
protected |
|
protected |
|
protected |