PU2CLR RDA5807 Arduino Library 1.1.9
Arduino Library for RDA5807 Devices - By Ricardo Lima Caratti
|
rda Defined Data Types More...
Classes | |
union | rda_reg00 |
Register 0x00. More... | |
union | rda_reg01 |
Register 0x01 - Dummy. More... | |
union | rda_reg02 |
Register 0x02 - Basic setup: RESET configuration;. More... | |
union | rda_reg03 |
Register 0x03. More... | |
union | rda_reg04 |
Register 0x04. More... | |
union | rda_reg05 |
Register 0x05. More... | |
union | rda_reg06 |
Register 0x06. More... | |
union | rda_reg07 |
Register 0x07. More... | |
union | rda_reg08 |
Register 0x08 - Direct Frequency. More... | |
union | rda_reg0a |
Register 0x0A - Device current status. More... | |
union | rda_reg0b |
Register 0x0B. More... | |
union | rda_reg0c |
Register 0x0C. More... | |
union | rda_reg0d |
Register 0x0D. More... | |
union | rda_reg0e |
Register 0x0E. More... | |
union | rda_reg0f |
Register 0x0F. More... | |
union | rds_blockb |
RDS Block B data type. More... | |
union | rds_date_time |
union | word16_to_bytes |
Converts 16 bits word to two bytes. More... | |
class | RDA5807 |
KT0915 Class. More... | |
struct | rda_reg00.refined |
struct | rda_reg01.refined |
struct | rda_reg02.refined |
struct | rda_reg03.refined |
struct | rda_reg04.refined |
struct | rda_reg05.refined |
struct | rda_reg06.refined |
struct | rda_reg07.refined |
struct | rda_reg08.refined |
struct | rda_reg0a.refined |
struct | rda_reg0b.refined |
struct | rda_reg0c.refined |
struct | rda_reg0d.refined |
struct | rda_reg0e.refined |
struct | rda_reg0f.refined |
struct | rds_blockb.group0 |
struct | rds_blockb.group2 |
struct | rds_blockb.refined |
struct | rds_date_time.refined |
struct | word16_to_bytes.refined |
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.
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg00.refined | refined |
union rda_reg01 |
Register 0x01 - Dummy.
It is not documented by the RDA.
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg01.refined | refined |
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 |
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg02.refined | 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.
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg03.refined | 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.
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg04.refined | refined |
union rda_reg05 |
Register 0x05.
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg05.refined | 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 |
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg06.refined | refined |
union rda_reg07 |
Register 0x07.
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg07.refined | 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
Class Members | ||
---|---|---|
uint16_t | directFrequency | |
struct rda_reg08.refined | refined |
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 |
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg0a.refined | 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 |
Class Members | ||
---|---|---|
uint16_t | raw | |
struct rda_reg0b.refined | refined |
union rda_reg0c |
Register 0x0C.
BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Class Members | ||
---|---|---|
uint16_t | RDSA | BLOCK A ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1) |
struct rda_reg0c.refined | refined |
union rda_reg0d |
Register 0x0D.
BLOCK B ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Class Members | ||
---|---|---|
uint16_t | RDSB | |
struct rda_reg0d.refined | refined |
union rda_reg0e |
Register 0x0E.
BLOCK C ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Class Members | ||
---|---|---|
uint16_t | RDSC | |
struct rda_reg0e.refined | refined |
union rda_reg0f |
Register 0x0F.
BLOCK D ( in RDS mode) or BLOCK E (in RBDS mode when ABCD_E flag is 1)
Class Members | ||
---|---|---|
uint16_t | RDSD | |
struct rda_reg0f.refined | refined |
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.
Class Members | ||
---|---|---|
uint16_t | blockB | |
struct rds_blockb.group0 | group0 | |
struct rds_blockb.group2 | group2 | |
struct rds_blockb.refined | refined |
union 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 Crossing boundary, it was necessary to split minute and hour representation.
Class Members | ||
---|---|---|
uint8_t | raw[6] | |
struct rds_date_time.refined | refined |
union word16_to_bytes |
Converts 16 bits word to two bytes.
Class Members | ||
---|---|---|
uint16_t | raw | |
struct word16_to_bytes.refined | refined |
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) | |
void | setI2CBusAddrs (int directAccess, int fullAccess) |
Sets alternatives I2C bus address. | |
void | getStatusRegisters () |
Gets all current device status and RDS information registers (From 0x0A to 0x0F) | |
word16_to_bytes | getDirectRegister (uint8_t reg) |
Gets the register content via direct access. | |
void * | getStatus (uint8_t reg) |
Gets the register content of a given status register (from 0x0A to 0x0F) | |
void | setRegister (uint8_t reg, uint16_t value) |
Sets a given value to a specific device register. | |
void | setGpio (uint8_t gpioPin, uint8_t gpioSetup=0, int mcuPin=-1) |
Sets the Device GPIO pins. | |
void | setInterruptMode (uint8_t value) |
Sets Interrupt Mode. | |
void | waitAndFinishTune () |
Waits for Seek or Tune finish. | |
void | softReset () |
Resets the device. | |
void | powerUp () |
Powers the receiver on. | |
void | powerDown () |
Power the receiver off. | |
void | setup (uint8_t clock_frequency=CLOCK_32K, uint8_t oscillator_type=OSCILLATOR_TYPE_PASSIVE, uint8_t rlck_no_calibrate=RLCK_NO_CALIBRATE_MODE_OFF) |
Starts the device. | |
void | setNewDemodulateMethod (bool value) |
Sets new demodulate method. It can improve the receiver sensitivity about 1dB. | |
void | setAFC (bool value) |
Sets AFC true or false. | |
void | setLnaIcSel (uint8_t value) |
Sets LNA_ICSEL_BIT. | |
void | setLnaPortSel (uint8_t value) |
Sets LNA input port selection bit. | |
uint8_t | getLnaIcSel () |
Gets LNA_ICSEL_BIT current value. | |
uint8_t | getLnaPortSel () |
Gets current vaue of the LNA input port selection bit. | |
void | setFrequency (uint16_t frequency) |
Sets the frequency. | |
void | setFrequencyToBeginBand () |
Tunes the receiver at the first channel/frequency of the current band. | |
void | setFrequencyToEndBand () |
Tunes the receiver at the last channel/frequency of the current band. | |
uint16_t | getMaximunFrequencyOfTheBand () |
gets the maximun frequency of the current band | |
uint16_t | getMinimumFrequencyOfTheBand () |
gets the minimum frequency of the current band | |
uint16_t | getFrequency () |
Gets the current frequency. | |
void | setFrequencyUp () |
Increments the current frequency. | |
void | setFrequencyDown () |
Decrements the current frequency. | |
void | setDirectFrequency (uint16_t frequency) |
Sets the frequency using the reg08 (direct frequency) | |
void | setFrequencyMode (uint8_t value) |
Sets the frequency mode. If 1, then freq setting changed. | |
uint16_t | getRealFrequency () |
Gets the current frequency bases on the current channel. | |
uint16_t | getRealChannel () |
Gets the current channel stored in 0x0A status register. | |
void | setChannel (uint16_t channel) |
Sets the channel. | |
void | seek (uint8_t seek_mode, uint8_t direction) |
Seek function. | |
void | seek (uint8_t seek_mode, uint8_t direction, void(*showFunc)()) |
Seek function. | |
void | setSeekThreshold (uint8_t value) |
Sets RSSI Seek Threshold. | |
void | setBand (uint8_t band=0) |
Sets the FM band. See table below. | |
uint8_t | getBand () |
Returns the current band. | |
void | setSpace (uint8_t space=0) |
Sets the FM channel space. | |
void | setStep (uint8_t step=100) |
Sets the FM Step;. | |
uint8_t | getSpace () |
Returns the current Band Space. | |
void | setBand3_50_65_Mode (uint8_t band3Mode) |
Sets the band 3 mode: 50 to 65 MHZ or 65 to 76 MHz. | |
uint8_t | getBand3Status () |
Gets the status of the Band3. | |
int | getRssi () |
Gets the current Rssi. | |
bool | isFmTrue () |
Returns true if the current channel is a station. | |
bool | isFmReady () |
Returns true if the FM is ready. | |
uint16_t | getDeviceId () |
Gets the Device identification. | |
void | setSoftmute (bool value) |
Sets Soft Mute Enable or disable. | |
bool | isSoftmuted () |
Gets the softmute status. | |
void | setMono (bool value) |
Sets audio Mono or stereo. | |
bool | isStereo () |
Gets the current Stereo status. | |
void | setBass (bool value) |
Sets Bass Boost. | |
bool | getBass () |
Gets Bass Boost. | |
void | setLedStereoIndicator (bool value=true) |
Sets the system to use a LED to indicate Stereo or Mono. | |
void | setMute (bool value) |
Sets Audio mute or unmute. | |
bool | isMuted () |
Gets Audio Mute Status. | |
bool | getMute () |
Gets Audio Mute Status. Same isMuted. | |
bool | isAudioOutputHighImpedance () |
Gets true if the output audio impedance is high. | |
void | setAudioOutputHighImpedance (bool value) |
Sets audio output impedance high ow low. | |
void | setSoftBlendEnable (bool value) |
Sets Soft Blend. | |
void | setVolume (uint8_t value) |
Sets the audio volume level. | |
uint8_t | getVolume () |
Gets the current audio volume level. | |
void | setVolumeUp () |
Increments the audio volume. | |
void | setVolumeDown () |
Decrements the audio volume. | |
void | setFmDeemphasis (uint8_t de) |
Sets De-emphasis. | |
void | setRDS (bool value) |
Sets the RDS operation. | |
void | setRBDS (bool value) |
Sets the RBDS operation. | |
void | setRdsFifo (bool value) |
Sets RDS fifo mode enable. | |
void | clearRdsFifo (bool value=1) |
Clear RDS fifo. | |
void | clearRdsBuffer () |
Clear RDS Information (Station Name, Station Information, Program Information and Time) | |
bool | getRdsReady () |
Returns true if RDS Ready. | |
bool | getRdsAllData (char **stationName, char **stationInformation, char **programInformation, char **utcTime) |
Gets Station Name, Station Information, Program Information and utcTime. | |
uint8_t | getRdsFlagAB (void) |
Returns the current Text Flag A/B. | |
bool | isNewRdsFlagAB (void) |
Returns true if the Text Flag A/B has changed. | |
uint8_t | getRdsVersionCode (void) |
Gets the version code (extracted from the Block B) | |
uint16_t | getRdsGroupType () |
Return the group type. | |
uint8_t | getRdsProgramType (void) |
Returns the Program Type (extracted from the Block B) | |
uint8_t | getRdsTrafficProgramCode (void) |
Returns the Traffic Alerts given by the station. | |
void | getNext2Block (char *c) |
Process data received from group 2B. | |
void | getNext4Block (char *c) |
Process data received from group 2A. | |
char * | getRdsText0A (void) |
Gets the station name and other messages. | |
char * | getRdsStationName (void) |
Gets the Station Name. | |
char * | getRdsText2A (void) |
Gets the Program Information. | |
char * | getRdsProgramInformation (void) |
Gets the Program Information (RT - Radio Text) | |
char * | getRdsText2B (void) |
Gets the Station Information. | |
char * | getRdsStationInformation (void) |
Gets the Station Information. | |
char * | getRdsTime () |
Gets the RDS UTC time and date when the Group type is 4. | |
char * | getRdsLocalTime () |
Gets the RDS time converted to local time. | |
uint8_t | getBlockId () |
Gets the current Block ID. | |
uint8_t | getErrorBlockA () |
Gets the current Status of block A. | |
uint8_t | getErrorBlockB () |
Gets the current Status of block B. | |
bool | hasRdsInfo () |
Returns true when the RDS system has valid information. | |
bool | hasRdsInfoAB () |
Returns true when the RDS system has valid information. | |
bool | getRdsSync () |
Gets the Rds Sync. | |
void | setI2SOn (bool value) |
Enables I2S setup. | |
void | setI2SAllParameters (uint8_t R_DELY, uint8_t L_DELY, uint8_t SCLK_O_EDGE, uint8_t SW_O_EDGE, uint8_t I2S_SW_CNT, uint8_t WS_I_EDGE, uint8_t DATA_SIGNED, uint8_t SCLK_I_EDGE, uint8_t WS_LR, uint8_t SLAVE_MASTER, uint8_t OPEN_MODE) |
Configures all parameters for I2S. | |
void | setI2SMaster (bool value) |
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, I2S_WS_STEP_32,. | |
void | setI2SDataSigned (bool value) |
If 0, I2S output unsigned 16-bit audio data. If 1, I2S output signed 16-bit audio data. | |
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. | |
char * | formatFrequency (uint16_t value, char *strValue, char decimalSeparator) |
Convert a numeric frequency to a formated string (char *) frequency. | |
char * | formatCurrentFrequency (char decimalSeparator=',') |
Convert the current frequency to a formated string (char *) frequency. | |
int | checkI2C (uint8_t *addressArray) |
Check the I2C bus address. | |
Protected Attributes | |
uint16_t | shadowStatusRegisters [6] |
shadow status registers | |
uint16_t | shadowRegisters [9] |
shadow configuration registers | |
rda_reg00 * | reg00 = (rda_reg00 *)&shadowRegisters[0] |
rda_reg01 * | reg01 = (rda_reg01 *)&shadowRegisters[1] |
rda_reg02 * | reg02 = (rda_reg02 *)&shadowRegisters[2] |
rda_reg03 * | reg03 = (rda_reg03 *)&shadowRegisters[3] |
rda_reg04 * | reg04 = (rda_reg04 *)&shadowRegisters[4] |
rda_reg05 * | reg05 = (rda_reg05 *)&shadowRegisters[5] |
rda_reg06 * | reg06 = (rda_reg06 *)&shadowRegisters[6] |
rda_reg07 * | reg07 = (rda_reg07 *)&shadowRegisters[7] |
rda_reg08 * | reg08 = (rda_reg08 *)&shadowRegisters[8] |
rda_reg0a * | reg0a = (rda_reg0a *)&shadowStatusRegisters[0] |
rda_reg0b * | reg0b = (rda_reg0b *)&shadowStatusRegisters[1] |
rda_reg0c * | reg0c = (rda_reg0c *)&shadowStatusRegisters[2] |
rda_reg0d * | reg0d = (rda_reg0d *)&shadowStatusRegisters[3] |
rda_reg0e * | reg0e = (rda_reg0e *)&shadowStatusRegisters[4] |
rda_reg0f * | reg0f = (rda_reg0f *)&shadowStatusRegisters[5] |
uint16_t | startBand [4] = {8700, 7600, 7600, 6500} |
uint16_t | endBand [4] = {10800, 9100, 10800, 7600} |
End FM band limit. | |
uint16_t | fmSpace [4] = {10, 20, 5, 1} |
char | rds_buffer2A [65] |
RT - RDS Radio Text buffer - Program Information. | |
char | rds_buffer2B [33] |
RDS Radio Text buffer - Station Information. | |
char | rds_buffer0A [9] |
PS - RDS Basic tuning and switching information (Type 0 groups) - Station Name. | |
char | rds_time [25] |
CT - RDS date time received information - UTC Time. | |
uint8_t | oldTextABFlag |
Saves the latest value of the textABFlag. Useful to check chanhes. | |
char | strFrequency [8] |
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. | |
int | gpio2Control = -1 |
Can be used to add control to the system via GPIO2 pin. | |
int | gpio3Control = -1 |
Can be used to add control to the system via GPIO3 pin. | |
uint8_t | clockFrequency = CLOCK_32K |
uint8_t | oscillatorType = OSCILLATOR_TYPE_PASSIVE |
uint8_t | rlckNoCalibrate = RLCK_NO_CALIBRATE_MODE_OFF |
Default is 0. | |
uint16_t | maxDelayAftarCrystalOn = MAX_DELAY_AFTER_OSCILLATOR |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by setI2CBusAddrs().
|
protected |
Referenced by setI2CBusAddrs().
|
protected |
End FM band limit.
|
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 |
Saves the latest value of the textABFlag. Useful to check chanhes.
|
protected |
|
protected |
PS - RDS Basic tuning and switching information (Type 0 groups) - Station Name.
Referenced by clearRdsBuffer(), getRdsText0A(), and isNewRdsFlagAB().
|
protected |
RT - RDS Radio Text buffer - Program Information.
Referenced by clearRdsBuffer(), and getRdsText2A().
|
protected |
RDS Radio Text buffer - Station Information.
Referenced by clearRdsBuffer(), and getRdsText2B().
|
protected |
CT - RDS date time received information - UTC Time.
Referenced by clearRdsBuffer(), getRdsLocalTime(), and getRdsTime().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Default is 0.
|
protected |
shadow configuration registers
|
protected |
shadow status registers
|
protected |
|
protected |
Referenced by formatCurrentFrequency().
struct rda_reg02.refined |
struct rda_reg03.refined |
struct rda_reg04.refined |
struct rda_reg05.refined |
struct rda_reg06.refined |
struct rda_reg07.refined |
struct rda_reg0a.refined |
struct rda_reg0b.refined |
struct rds_blockb.group0 |
struct rds_blockb.group2 |
struct rds_blockb.refined |
struct rds_date_time.refined |