rda5807m - Driver for single-chip broadcast FM radio tuner RDA5807M

group rda5807m

ESP-IDF driver for single-chip broadcast FM radio tuner RDA5807M.

Copyright (c) 2018 Ruslan V. Uss unclerus@gmail.com

BSD Licensed as described in the file LICENSE

Defines

RDA5807M_RSSI_MAX
RDA5807M_SEEK_TH_DEF
RDA5807M_SEEK_TH_MAX
RDA5807M_VOL_MAX

Enums

enum rda5807m_clock_freq_t

Clock mode.

Values:

enumerator RDA5807M_CLK_32768HZ

32768 Hz, default

enumerator RDA5807M_CLK_12MHZ

12 MHz

enumerator RDA5807M_CLK_13MHZ

13 MHz

enumerator RDA5807M_CLK_19_2MHZ

19.2 MHz

enumerator RDA5807M_CLK_24MHZ

24 MHz

enumerator RDA5807M_CLK_26MHZ

26 MHz

enumerator RDA5807M_CLK_38_4MHZ

38.4 MHz

enum rda5807m_channel_spacing_t

Channel spacing (frequency step)

Values:

enumerator RDA5807M_CHAN_SPACE_100

100 KHz, default

enumerator RDA5807M_CHAN_SPACE_200

200 KHz

enumerator RDA5807M_CHAN_SPACE_50

50 KHz

enumerator RDA5807M_CHAN_SPACE_25

25 KHz

enum rda5807m_band_t

FM Band.

Values:

enumerator RDA5807M_BAND_87_108

87..108 MHz (US/Europe), default

enumerator RDA5807M_BAND_76_91

76..91 MHz (Japan)

enumerator RDA5807M_BAND_76_108

76..108 MHz (Worldwide)

enumerator RDA5807M_BAND_65_76

65..76 MHz (Eastern Europe)

enumerator RDA5807M_BAND_50_76

50..76 MHz (Eastern Europe wide)

enum rda5807m_seek_status_t

Seek status.

Values:

enumerator RDA5807M_SEEK_NONE

No seeking stations currently.

enumerator RDA5807M_SEEK_STARTED

Seeking in progress.

enumerator RDA5807M_SEEK_COMPLETE

Seeking complete.

enumerator RDA5807M_SEEK_FAILED

Seeking failed - no stations with RSSI > threshold found.

Functions

esp_err_t rda5807m_init_desc(rda5807m_t *dev, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)

Initialize device descriptor.

Parameters
  • dev – Device descriptor

  • port – I2C port

  • sda_gpio – SDA GPIO

  • scl_gpio – SCL GPIO

Returns

ESP_OK on success

esp_err_t rda5807m_free_desc(rda5807m_t *dev)

Free device descriptor.

Parameters

dev – Device descriptor

Returns

ESP_OK on success

esp_err_t rda5807m_init(rda5807m_t *dev, rda5807m_clock_freq_t clock_freq)

Initialize device.

Parameters
  • dev – Device descriptor

  • clock_freq – RCLK frequency, usually RDA5807M_CLK_32768HZ

Returns

ESP_OK on success

esp_err_t rda5807m_get_state(rda5807m_t *dev, rda5807m_state_t *state)

Get current device status.

Parameters
  • dev – Device descriptor

  • state[out] Device status descriptor

Returns

ESP_OK on success

esp_err_t rda5807m_get_volume(rda5807m_t *dev, uint8_t *vol)

Get volume level (DAC gain)

Parameters
  • dev – Device descriptor

  • vol[out] Volume level, 0..RDA5807M_VOL_MAX

Returns

ESP_OK on success

esp_err_t rda5807m_set_volume(rda5807m_t *dev, uint8_t vol)

Set volume level (DAC gain)

Volume scale is logarithmic. When 0, device is muted and output impedance is very large.

Parameters
  • dev – Device descriptor

  • vol – Volume level, 0..RDA5807M_VOL_MAX

Returns

ESP_OK on success

esp_err_t rda5807m_get_mute(rda5807m_t *dev, bool *mute)

Get current mute state.

Parameters
  • dev – Device descriptor

  • mute[out] Mute state

Returns

ESP_OK on success

esp_err_t rda5807m_set_mute(rda5807m_t *dev, bool mute)

Mute/unmute device.

Parameters
  • dev – Device descriptor

  • mute – Mute if true

Returns

ESP_OK on success

esp_err_t rda5807m_get_softmute(rda5807m_t *dev, bool *softmute)

Get current soft mute state.

Parameters
  • dev – Device descriptor

  • softmute[out] Soft mute state

Returns

ESP_OK on success

esp_err_t rda5807m_set_softmute(rda5807m_t *dev, bool softmute)

Enable/disable soft mute.

Parameters
  • dev – Device descriptor

  • softmute – If true, enable soft mute

Returns

ESP_OK on success

esp_err_t rda5807m_get_bass_boost(rda5807m_t *dev, bool *bass_boost)

Get current state of the bass boost feature.

Parameters
  • dev – Device descriptor

  • bass_boost[out] Bass boost state

Returns

ESP_OK on success

esp_err_t rda5807m_set_bass_boost(rda5807m_t *dev, bool bass_boost)

Enable/disable bass boost feature.

Parameters
  • dev – Device descriptor

  • bass_boost – If true, enable bass boost

Returns

ESP_OK on success

esp_err_t rda5807m_get_mono(rda5807m_t *dev, bool *mono)

Get forced mono state.

Parameters
  • dev – Device descriptor

  • mono[out] Forced mono state

Returns

ESP_OK on success

esp_err_t rda5807m_set_mono(rda5807m_t *dev, bool mono)

Enable/disable forced mono.

Parameters
  • dev – Device descriptor

  • mono – If true, audio will be in mono even if stereo is available

Returns

ESP_OK on success

esp_err_t rda5807m_get_band(rda5807m_t *dev, rda5807m_band_t *band)

Get current band.

Parameters
  • dev – Device descriptor

  • band[out] Current band

Returns

ESP_OK on success

esp_err_t rda5807m_set_band(rda5807m_t *dev, rda5807m_band_t band)

Switch device to band.

Parameters
  • dev – Device descriptor

  • band – New band

Returns

ESP_OK on success

esp_err_t rda5807m_get_channel_spacing(rda5807m_t *dev, rda5807m_channel_spacing_t *spacing)

Get current channel spacing (frequency step)

Parameters
  • dev – Device descriptor

  • spacing[out] Current channel spacing

Returns

ESP_OK on success

esp_err_t rda5807m_set_channel_spacing(rda5807m_t *dev, rda5807m_channel_spacing_t spacing)

Set channel spacing (frequency step)

Parameters
  • dev – Device descriptor

  • spacing – Channel spacing, usually RDA5807M_CHAN_SPACE_100

Returns

ESP_OK on success

esp_err_t rda5807m_get_frequency_khz(rda5807m_t *dev, uint32_t *frequency)

Get frequency the device is tuned to.

Parameters
  • dev – Device descriptor

  • frequency[out] Frequency, kHz

Returns

ESP_OK on success

esp_err_t rda5807m_set_frequency_khz(rda5807m_t *dev, uint32_t frequency)

Tune device to a frequency.

Parameters
  • dev – Device descriptor

  • frequency – Frequency, kHz

Returns

ESP_OK on success

esp_err_t rda5807m_get_afc(rda5807m_t *dev, bool *afc)

Get current state of the automatic frequency control.

Parameters
  • dev – Device descriptor

  • afc[out] AFC state

Returns

ESP_OK on success

esp_err_t rda5807m_set_afc(rda5807m_t *dev, bool afc)

Enable/disable automatic frequency control.

Parameters
  • dev – Device descriptor

  • afc – AFC state

Returns

ESP_OK on success

esp_err_t rda5807m_seek_start(rda5807m_t *dev, bool up, bool wrap, uint8_t threshold)

Start seeking stations.

Parameters
  • dev – Device descriptor

  • up – Seeking direction: true - up, false - down

  • wrap – If true, wrap at the upper or lower band limit and continue seeking, else stop seeking at bounds

  • threshold – Seeking SNR threshold, 0..RDA5807M_SEEK_TH_MAX. Usually it’s RDA5807M_SEEK_TH_DEF

Returns

ESP_OK on success

esp_err_t rda5807m_seek_stop(rda5807m_t *dev)

Stop seeking stations.

Parameters

dev – Device descriptor

Returns

ESP_OK on success

struct rda5807m_state_t
#include <rda5807m.h>

Overall device status.

Public Members

rda5807m_seek_status_t seek_status

Seek status.

bool station

True if tuned to a station.

bool stereo

True if stereo is available.

bool rds_ready

True if RDS data is ready.

uint8_t rssi

RSSI, 0..RDA5807M_RSSI_MAX (logarithmic scale)

uint32_t frequency

Current frequency, kHz.

uint16_t rds[4]

RDS data.

struct rda5807m_t
#include <rda5807m.h>

Device descriptor.

Public Members

i2c_dev_t i2c_dev

I2C device descriptor.

rda5807m_band_t band

Current band.

rda5807m_channel_spacing_t spacing

Current spacing.