PU2CLR RDA5807 Arduino Library
1.0.1
Arduino Library for RDA5807 Devices - By Ricardo Lima Caratti
|
Functions | |
void | RDA5807::setI2CBusAddrs (int directAccess, int fullAccess) |
Sets alternatives I2C bus address. More... | |
void | RDA5807::setGpio (uint8_t gpioPin, uint8_t gpioSetup=0, int mcuPin=-1) |
Set the Device GPIO pins. More... | |
void | RDA5807::getStatusRegisters () |
Gets all current device status and RDS information registers (From 0x0A to 0x0F) More... | |
void * | RDA5807::getStatus (uint8_t reg) |
Gets the register content of a given status register (from 0x0A to 0x0F) More... | |
void | RDA5807::setAllRegisters () |
Sets values to the device registers from 0x02 to 0x07. More... | |
void | RDA5807::setRegister (uint8_t reg, uint16_t value) |
Sets a given value to a specific device register. More... | |
void | RDA5807::waitAndFinishTune () |
Waits for Seek or Tune finish. More... | |
void | RDA5807::softReset () |
Resets the device. More... | |
void | RDA5807::powerUp () |
Powers the receiver on. More... | |
void | RDA5807::powerDown () |
Power the receiver off. More... | |
void | RDA5807::setup (uint8_t clock_type=CLOCK_32K, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL) |
Starts the device. More... | |
void | RDA5807::setChannel (uint16_t channel) |
Sets the channel. More... | |
void | RDA5807::setFrequency (uint16_t frequency) |
Sets the frequency. More... | |
void | RDA5807::setFrequencyUp () |
Increments the current frequency. More... | |
void | RDA5807::setFrequencyDown () |
Decrements the current frequency. More... | |
uint16_t | RDA5807::getFrequency () |
Gets the current frequency. More... | |
uint16_t | RDA5807::getRealChannel () |
Gets the current channel stored in 0x0A status register. More... | |
uint16_t | RDA5807::getRealFrequency () |
Gets the current frequency bases on the current channel. More... | |
void | RDA5807::seek (uint8_t seek_mode, uint8_t direction) |
Seek function. More... | |
void | RDA5807::setSeekThreshold (uint8_t value) |
Sets RSSI Seek Threshold. More... | |
void | RDA5807::setBand (uint8_t band=1) |
Sets the FM band. See table below. More... | |
void | RDA5807::setSpace (uint8_t space=0) |
Sets the FM channel space. More... | |
int | RDA5807::getRssi () |
Gets the current Rssi. More... | |
void | RDA5807::setSoftmute (bool value) |
Sets Soft Mute Enable or disable. More... | |
void | RDA5807::setMute (bool value) |
Sets Audio mute or unmute. More... | |
void | RDA5807::setMono (bool value) |
Sets audio Mono or stereo. More... | |
bool | RDA5807::isStereo () |
Gets the current Stereo status. More... | |
void | RDA5807::clearRdsFifo () |
Clears RDS/RBDS FIFO. More... | |
void | RDA5807::setVolume (uint8_t value) |
Sets the audio volume level. More... | |
uint8_t | RDA5807::getVolume () |
Gets the current audio volume level. More... | |
void | RDA5807::setVolumeUp () |
Increments the audio volume. More... | |
void | RDA5807::setVolumeDown () |
Decrements the audio volume. More... | |
uint8_t | RDA5807::getDeviceId () |
Gets the Device identification. More... | |
void | RDA5807::setFmDeemphasis (uint8_t de) |
Sets De-emphasis. More... | |
|
inline |
Sets alternatives I2C bus address.
You do not need use this function on RDA5807M
directAccess | |
fullAccess |
References RDA5807::deviceAddressDirectAccess, and RDA5807::deviceAddressFullAccess.
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 |
void RDA5807::getStatusRegisters | ( | ) |
Gets all current device status and RDS information registers (From 0x0A to 0x0F)
Referenced by RDA5807::getRdsFlagAB(), RDA5807::getRdsGroupType(), RDA5807::getRdsProgramType(), RDA5807::getRdsText(), RDA5807::getRdsText0A(), RDA5807::getRdsText2A(), RDA5807::getRdsText2B(), RDA5807::getRdsTime(), and RDA5807::getRdsVersionCode().
void * RDA5807::getStatus | ( | uint8_t | reg | ) |
Gets the register content of a given status register (from 0x0A to 0x0F)
Useful when you need just a specific status register content.
This methos update the first element of the shadowStatusRegisters linked to the register
void RDA5807::setAllRegisters | ( | ) |
Sets values to the device registers from 0x02 to 0x07.
An internal address counter automatically increments to allow continuous data byte writes, starting with the upper byte of register 02h, followed by the lower byte of register 02h, and onward until the lower byte of the last register is reached.
The registers from 0x2 to 0x07 are used to setup the device. This method writes the array shadowStatusRegisters. See Device registers map in RDA5807.h file.
To implement this, a register maping was created to deal with each register structure. For each type of register, there is a reference to the array element.
void RDA5807::setRegister | ( | uint8_t | reg, |
uint16_t | value | ||
) |
Sets a given value to a specific device register.
reg | register number (valid values is between 0x02 and 0x07) |
value | the unsigned 16 bits word value (see rda_rec0x data types) |
void RDA5807::waitAndFinishTune | ( | ) |
Waits for Seek or Tune finish.
Referenced by RDA5807::setChannel().
void RDA5807::softReset | ( | ) |
Resets the device.
The RDA5807M is RESET itself When VIO is Power up.
Also, it support soft reset by triggering the 0x02 register (rda_reg02) bit 1 from 0 to 1.
void RDA5807::powerUp | ( | ) |
Powers the receiver on.
Referenced by RDA5807::setup().
void RDA5807::powerDown | ( | ) |
Power the receiver off.
void RDA5807::setup | ( | uint8_t | clock_type = CLOCK_32K , |
uint8_t | oscillator_type = OSCILLATOR_TYPE_CRYSTAL |
||
) |
Starts the device.
clock_type | Clock used. |
oscillator_type | optional. Sets the Oscillator type used (Default Crystal or Ref. Clock). |
References RDA5807::powerUp().
void RDA5807::setChannel | ( | uint16_t | channel | ) |
Sets the channel.
This method tunes the rteceiver in a given channel.
The channel can be calculated by using the follow formula
channel = (desired frequency - start band frequency) / space channel in use / 10.0);
channel |
References RDA5807::waitAndFinishTune().
void RDA5807::setFrequency | ( | uint16_t | frequency | ) |
Sets the frequency.
frequency |
void RDA5807::setFrequencyUp | ( | ) |
Increments the current frequency.
The increment uses the band space as step. See array: uint16_t fmSpace[4] = {100/10, 200/10, 50/10, 25/10};
void RDA5807::setFrequencyDown | ( | ) |
Decrements the current frequency.
The drecrement uses the band space as step. See array: uint16_t fmSpace[4] = {20, 10, 5, 1};
uint16_t RDA5807::getFrequency | ( | ) |
Gets the current frequency.
uint16_t RDA5807::getRealChannel | ( | ) |
Gets the current channel stored in 0x0A status register.
uint16_t RDA5807::getRealFrequency | ( | ) |
Gets the current frequency bases on the current channel.
The current channel is stored in the 0x0A register. This value is updated after a tune or seek operation.
The current frequency can be calculated by the formula below
Band | Formula |
---|---|
0 | Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 87.0 MHz |
1 or 2 | Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 76.0 MHz |
3 | Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 65.0 MHz |
void RDA5807::seek | ( | uint8_t | seek_mode, |
uint8_t | direction | ||
) |
Seek function.
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 |
direction | if 0, seek down; if 1, seek up. |
void RDA5807::setSeekThreshold | ( | uint8_t | value | ) |
Sets RSSI Seek Threshold.
value |
void RDA5807::setBand | ( | uint8_t | band = 1 | ) |
Sets the FM band. See table below.
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) |
band | FM band index. See table above. |
void RDA5807::setSpace | ( | uint8_t | space = 0 | ) |
Sets the FM channel space.
Channel space table
Value | Description |
---|---|
00 | 100KHz |
01 | 200KHz |
10 | 50KHz |
11 | 25KHz |
space | FM channel space. See table above. |
int RDA5807::getRssi | ( | ) |
Gets the current Rssi.
RSSI; 000000 = min; 111111 = max; RSSI scale is logarithmic.
void RDA5807::setSoftmute | ( | bool | value | ) |
Sets Soft Mute Enable or disable.
value | true = enable; false=disable |
void RDA5807::setMute | ( | bool | value | ) |
Sets Audio mute or unmute.
value | TRUE = mute; FALSE = unmute |
void RDA5807::setMono | ( | bool | value | ) |
Sets audio Mono or stereo.
value | TRUE = Mono; FALSE force stereo |
bool RDA5807::isStereo | ( | ) |
Gets the current Stereo status.
void RDA5807::clearRdsFifo | ( | ) |
Clears RDS/RBDS FIFO.
void RDA5807::setVolume | ( | uint8_t | value | ) |
Sets the audio volume level.
value |
uint8_t RDA5807::getVolume | ( | ) |
Gets the current audio volume level.
void RDA5807::setVolumeUp | ( | ) |
Increments the audio volume.
void RDA5807::setVolumeDown | ( | ) |
Decrements the audio volume.
uint8_t RDA5807::getDeviceId | ( | ) |
void RDA5807::setFmDeemphasis | ( | uint8_t | de | ) |
Sets De-emphasis.
75 μs. Used in USA (default); 50 μs. Used in Europe, Australia, Japan.
de | 0 = 75 μs; 1 = 50 μs |