PU2CLR SI470X Arduino Library 1.0.1
Arduino Library for Si470X Devices - By Ricardo Lima Caratti
Loading...
Searching...
No Matches
Basic Functions

Functions

void SI470X::setI2CAddress (int bus_addr)
 Sets the I2C bus address.
 
void SI470X::setDelayAfterCrystalOn (uint8_t ms_value)
 Set the Delay After Crystal On (default 500ms)
 
uint16_t SI470X::getShadownRegister (uint8_t register_number)
 Get the Shadown Register object.
 
void SI470X::setShadownRegister (uint8_t register_number, uint16_t value)
 Sets a given value to the Shadown Register.
 
void SI470X::getAllRegisters ()
 Gets all current register content of the device.
 
void SI470X::setAllRegisters (uint8_t limit=0x07)
 Sets values to the device registers from 0x02 to 0x07.
 
void SI470X::getStatus ()
 Gets the value of the 0x0A register.
 
void SI470X::waitAndFinishTune ()
 Wait STC (Seek/Tune Complete) status becomes 0.
 
void SI470X::reset ()
 Resets the device.
 
void SI470X::powerUp ()
 Powers the receiver on.
 
void SI470X::powerDown ()
 Powers the receiver off.
 
void SI470X::setup (int resetPin, int sdaPin, int rdsInterruptPin=-1, int seekInterruptPin=-1, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL)
 Starts the device.
 
void SI470X::setup (int resetPin, int sdaPin, uint8_t oscillator_type)
 Starts the device.
 
void SI470X::setChannel (uint16_t channel)
 Sets the channel.
 
void SI470X::setFrequency (uint16_t frequency)
 Sets the FM frequency.
 
void SI470X::setFrequencyUp ()
 Increments the current frequency.
 
void SI470X::setFrequencyDown ()
 Decrements the current frequency.
 
uint16_t SI470X::getFrequency ()
 Gets the current frequency.
 
uint16_t SI470X::getRealChannel ()
 Gets the current channel stored in register 0x0B.
 
uint16_t SI470X::getRealFrequency ()
 Gets the frequency based on READCHAN register (0x0B)
 
void SI470X::seek (uint8_t seek_mode, uint8_t direction)
 Seek function.
 
void SI470X::seek (uint8_t seek_mode, uint8_t direction, void(*showFunc)())
 Seek function.
 
void SI470X::setSeekThreshold (uint8_t value)
 Sets RSSI Seek Threshold.
 
void SI470X::setBand (uint8_t band=1)
 Sets the FM Band

 
void SI470X::setSpace (uint8_t space=0)
 Sets the FM Space

 
int SI470X::getRssi ()
 Gets the Rssi.
 
void SI470X::setSoftmute (bool value)
 Sets the Softmute true or false.
 
void SI470X::setSoftmuteAttack (uint8_t value)
 Sets Softmute Attack/Recover Rate.
 
void SI470X::setSoftmuteAttenuation (uint8_t value)
 Sets Softmute Attenuation..
 
void SI470X::setAgc (bool value)
 Sets the AGC enable or disable.
 
void SI470X::setMute (bool value)
 Sets the Mute true or false.
 
void SI470X::setMono (bool value)
 Sets the Mono true or false (stereo)
 
bool SI470X::isStereo ()
 Checks stereo / mono status.
 
void SI470X::setVolume (uint8_t value)
 Sets the audio volume level.
 
uint8_t SI470X::getVolume ()
 Gets the current audio volume level.
 
void SI470X::setVolumeUp ()
 Increments the audio volume.
 
void SI470X::setVolumeDown ()
 Decrements the audio volume.
 
void SI470X::setExtendedVolumeRange (bool value)
 Sets Extended Volume Range.
 
uint8_t SI470X::getPartNumber ()
 Gets the Part Number.
 
uint16_t SI470X::getManufacturerId ()
 Gets the Manufacturer ID.
 
uint8_t SI470X::getFirmwareVersion ()
 Gets the Firmware Version.
 
uint8_t SI470X::getDeviceId ()
 Gets the Device identification.
 
uint8_t SI470X::getChipVersion ()
 Gets the Chip Version.
 
void SI470X::setFmDeemphasis (uint8_t de)
 Sets De-emphasis.
 

Detailed Description

Basic

Function Documentation

◆ setI2CAddress()

void SI470X::setI2CAddress ( int  bus_addr)
inline

Sets the I2C bus address.

This function must to be called before setup function if your device are not using 0x10 (default)

Parameters
bus_addrI2C buss address

References SI470X::deviceAddress.

◆ setDelayAfterCrystalOn()

void SI470X::setDelayAfterCrystalOn ( uint8_t  ms_value)
inline

Set the Delay After Crystal On (default 500ms)

Parameters
ms_valueValue in milliseconds

◆ getShadownRegister()

uint16_t SI470X::getShadownRegister ( uint8_t  register_number)
inline

Get the Shadown Register object.

if you want to get the current value of the device register, call getAllRegisters() before calling this function.

if you are dealing with the status register (0x0A), you can call getStatus() instead getAllRegisters().

See also
setAllRegisters, getAllRegisters, getShadownRegister, getStatus
Parameters
register_number
Returns
16 bits word with the Shadown registert

◆ setShadownRegister()

void SI470X::setShadownRegister ( uint8_t  register_number,
uint16_t  value 
)
inline

Sets a given value to the Shadown Register.

You have to call setAllRegisters() after setting the Shadow Registers to store the value into the device.

See also
setAllRegisters, getAllRegisters, getShadownRegister, getStatus
Parameters
register_numberregister index (from 0x00 to 0x0F)
value16 bits word with the content of the register

◆ getAllRegisters()

void SI470X::getAllRegisters ( )

Gets all current register content of the device.

For read operations, the device acknowledge is followed by an eight bit data word shifted out on falling SCLK edges. An internal address counter automatically increments to allow continuous data byte reads, starting with the upper byte of register 0Ah, followed by the lower byte of register 0Ah, and onward until the lower byte of the last register is reached. The internal address counter then automatically wraps around to the upper byte of register 00h and proceeds from there until continuous reads cease.

See also
BROADCAST FM RADIO TUNER FOR PORTABLE APPLICATIONS; page 19.
shadowRegisters;

Referenced by SI470X::getRealChannel(), SI470X::powerDown(), SI470X::powerUp(), SI470X::seek(), and SI470X::waitAndFinishTune().

◆ setAllRegisters()

void SI470X::setAllRegisters ( uint8_t  limit = 0x07)

Sets values to the device registers from 0x02 to 0x07.

For write operations, the device acknowledge is followed by an eight bit data word latched internally on rising edges of SCLK. The device acknowledges each byte of data written by driving SDIO low after the next falling SCLK edge, for 1 cycle.

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 internal address counter then automatically wraps around to the upper byte of register 00h and proceeds from there until continuous writes end.

The registers from 0x2 to 0x07 are used to setup the device. This method writes the array shadowRegisters, elements 8 to 14 (corresponding the registers 0x2 to 0x7 respectively) into the device. See Device registers map in SI470X.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.

See also
BROADCAST FM RADIO TUNER FOR PORTABLE APPLICATIONS; pages 18 and 19.
shadowRegisters;

◆ getStatus()

void SI470X::getStatus ( )

Gets the value of the 0x0A register.

This function also updates the value of shadowRegisters[0];

Returns
si470x_reg0a

Referenced by SI470X::getRdsReady(), SI470X::getRdsSync(), SI470X::getRssi(), and SI470X::isStereo().

◆ waitAndFinishTune()

void SI470X::waitAndFinishTune ( )
protected

Wait STC (Seek/Tune Complete) status becomes 0.

Should be used before processing Tune or Seek.

The STC bit being cleared indicates that the TUNE or SEEK bits may be set again to start another tune or seek operation. Do not set the TUNE or SEEK bits until the Si470x clears the STC bit.

References SI470X::getAllRegisters().

Referenced by SI470X::seek(), and SI470X::setChannel().

◆ reset()

void SI470X::reset ( )
protected

Resets the device.

Referenced by SI470X::setup().

◆ powerUp()

void SI470X::powerUp ( )
protected

Powers the receiver on.

Starts the receiver with some default configurations

References SI470X::getAllRegisters().

Referenced by SI470X::setup().

◆ powerDown()

void SI470X::powerDown ( )
protected

Powers the receiver off.

References SI470X::getAllRegisters().

◆ setup() [1/2]

void SI470X::setup ( int  resetPin,
int  sdaPin,
int  rdsInterruptPin = -1,
int  seekInterruptPin = -1,
uint8_t  oscillator_type = OSCILLATOR_TYPE_CRYSTAL 
)

Starts the device.

sets the reset pin, interrupt pins and oscillator type you are using in your project.

You have to inform at least two parameters: RESET pin and I2C SDA pin of your MCU

Parameters
resetPin// Arduino pin used to reset control.
sdaPin// I2C data bus pin (SDA).
rdsInterruptPin// optional. Sets the Interrupt Arduino pin used to RDS function control.
seekInterruptPin// optional. Sets the Arduino pin used to Seek function control.
oscillator_type// optional. Sets the Oscillator type used Crystal (default) or Ref. Clock.

References SI470X::powerUp(), SI470X::rdsInterruptPin, SI470X::reset(), SI470X::resetPin, and SI470X::seekInterruptPin.

◆ setup() [2/2]

void SI470X::setup ( int  resetPin,
int  sdaPin,
uint8_t  oscillator_type 
)

Starts the device.

Use this if you are not using interrupt pins in your project

Parameters
resetPin// Arduino pin used to reset control.
rdsInterruptPin// optional. Sets the Arduino pin used to RDS function control.
seekInterruptPin// optional. Sets the Arduino pin used to Seek function control.

◆ setChannel()

void SI470X::setChannel ( uint16_t  channel)

Sets the channel.

Parameters
channel

References SI470X::waitAndFinishTune().

◆ setFrequency()

void SI470X::setFrequency ( uint16_t  frequency)

Sets the FM frequency.

If you want to select 106.5 MHz, send the integer number 10650 (frequency 106.5MHz multiplied by 100).

Parameters
frequency7600 to 1080 (means 76Mhz to 108Mhz)

◆ setFrequencyUp()

void SI470X::setFrequencyUp ( )

Increments the current frequency.

The increment uses the band space as step. See array: uint16_t fmSpace[4] = {20, 10, 5, 1};

◆ setFrequencyDown()

void SI470X::setFrequencyDown ( )

Decrements the current frequency.

The drecrement uses the band space as step. See array: uint16_t fmSpace[4] = {20, 10, 5, 1};

◆ getFrequency()

uint16_t SI470X::getFrequency ( )

Gets the current frequency.

Returns
uint16_t

◆ getRealChannel()

uint16_t SI470X::getRealChannel ( )

Gets the current channel stored in register 0x0B.

This method is useful to query the current channel during the seek operations.

Returns
uint16_t

References SI470X::getAllRegisters().

◆ getRealFrequency()

uint16_t SI470X::getRealFrequency ( )

Gets the frequency based on READCHAN register (0x0B)

Unlike getFrequency method, this method queries the device.

Returns
uint16_t

◆ seek() [1/2]

void SI470X::seek ( uint8_t  seek_mode,
uint8_t  direction 
)

Seek function.

Seeks a station up or down.

Seek begins at the current channel, and goes in the direction specified with the SEEKUP bit. Seek operation stops when a channel is qualified as valid according to the seek parameters, the entire band has been searched (SKMODE = 0), or the upper or lower band limit has been reached (SKMODE = 1).

The STC bit is set high when the seek operation completes and/or the SF/BL bit is set high if the seek operation was unable to find a channel qualified as valid according to the seek parameters. The STC and SF/BL bits must be set low by setting the SEEK bit low before the next seek or tune may begin.

Seek performance for 50 kHz channel spacing varies according to RCLK tolerance. Silicon Laboratories recommends ±50 ppm RCLK crystal tolerance for 50 kHz seek performance.

A seek operation may be aborted by setting SEEK = 0.

Parameters
seek_modeSeek Mode; 0 = Wrap at the upper or lower band limit and continue seeking (default); 1 = Stop seeking at the upper or lower band limit.
directionSeek Direction; 0 = Seek down (default); 1 = Seek up.

References SI470X::getAllRegisters(), and SI470X::waitAndFinishTune().

◆ seek() [2/2]

void SI470X::seek ( uint8_t  seek_mode,
uint8_t  direction,
void(*)()  showFunc 
)

Seek function.

Seeks a station up or down.

Seek up or down a station and call a function defined by the user to show the frequency during the seek process.

Seek begins at the current channel, and goes in the direction specified with the SEEKUP bit. Seek operation stops when a channel is qualified as valid according to the seek parameters, the entire band has been searched (SKMODE = 0), or the upper or lower band limit has been reached (SKMODE = 1).

The STC bit is set high when the seek operation completes and/or the SF/BL bit is set high if the seek operation was unable to find a channel qualified as valid according to the seek parameters. The STC and SF/BL bits must be set low by setting the SEEK bit low before the next seek or tune may begin.

Seek performance for 50 kHz channel spacing varies according to RCLK tolerance. Silicon Laboratories recommends ±50 ppm RCLK crystal tolerance for 50 kHz seek performance.

A seek operation may be aborted by setting SEEK = 0.

It is important to say you have to implement a show frequency function. This function have to get the frequency via getFrequency function.

Example:

SI470X rx;
void showFrequency() {
uint16_t freq = rx.getFrequency();
Serial.print(freq);
Serial.println("MHz ");
}
void loop() {
.
.
rx.seek(SI470X_SEEK_WRAP, SI470X_SEEK_UP, showFrequency); // Seek Up
.
.
}
#define SI470X_SEEK_WRAP
Definition: SI470X.h:28
#define SI470X_SEEK_UP
Seek Up Direction.
Definition: SI470X.h:27
KT0915 Class.
Definition: SI470X.h:444
void seek(uint8_t seek_mode, uint8_t direction)
Seek function.
Definition: SI470X.cpp:349
uint16_t getFrequency()
Gets the current frequency.
Definition: SI470X.cpp:308
Parameters
seek_modeSeek Mode; 0 = Wrap at the upper or lower band limit and continue seeking (default); 1 = Stop seeking at the upper or lower band limit.
directionSeek Direction; 0 = Seek down (default); 1 = Seek up.
showFuncfunction that you have to implement to show the frequency during the seeking process. Set NULL if you do not want to show the progress.

References SI470X::getAllRegisters(), and SI470X::waitAndFinishTune().

◆ setSeekThreshold()

void SI470X::setSeekThreshold ( uint8_t  value)

Sets RSSI Seek Threshold.

SEEKTH presents the logarithmic RSSI threshold for the seek operation.

The Si4702/03-C19 will not validate channels with RSSI below the SEEKTH value.

SEEKTH is one of multiple parameters that can be used to validate channels.

For more information, see "AN284: Si4700/01 Firmware 15 Seek Adjustability and Set- tings."

Parameters
valuebetween 0 and 127

◆ setBand()

void SI470X::setBand ( uint8_t  band = 1)

Sets the FM Band

BAND value Description
0 00 = 87.5–108 MHz (USA, Europe) (Default)
1 (default) 01 = 76–108 MHz (Japan wide band)
2 10 = 76–90 MHz (Japan)
3 11 = Reserved
Parameters
bandSee the table above. If you do not set a parameter, will be considered 1 (76-108MHz)

◆ setSpace()

void SI470X::setSpace ( uint8_t  space = 0)

Sets the FM Space

The SI470x device supports 3 different settings as shown below

BAND value Description
0 00 - 200 kHz (US / Australia, Default)
1 (default) 01 - 100 kHz (Europe / Japan)
2 02 - 50 kHz
3 03 - Reserved (Do not use)

◆ getRssi()

int SI470X::getRssi ( )

Gets the Rssi.

Returns
int

References SI470X::getStatus().

◆ setSoftmute()

void SI470X::setSoftmute ( bool  value)

Sets the Softmute true or false.

Parameters
valueTRUE or FALSE

◆ setSoftmuteAttack()

void SI470X::setSoftmuteAttack ( uint8_t  value)

Sets Softmute Attack/Recover Rate.

Value Description
0 fastest (default)
1 fast
2 slow
3 slowest
Parameters
valueSee table above

◆ setSoftmuteAttenuation()

void SI470X::setSoftmuteAttenuation ( uint8_t  value)

Sets Softmute Attenuation..

Value Description
0 16 dB (default)
1 14 dB
2 12 dB
3 10 dB
Parameters
valueSee table above

◆ setAgc()

void SI470X::setAgc ( bool  value)

Sets the AGC enable or disable.

Parameters
valuetrue = enable; fale = disable

◆ setMute()

void SI470X::setMute ( bool  value)

Sets the Mute true or false.

Parameters
valueTRUE or FALSE

◆ setMono()

void SI470X::setMono ( bool  value)

Sets the Mono true or false (stereo)

Parameters
valueTRUE or FALSE

◆ isStereo()

bool SI470X::isStereo ( )

Checks stereo / mono status.

Parameters
valueTRUE if stereo

References SI470X::getStatus().

◆ setVolume()

void SI470X::setVolume ( uint8_t  value)

Sets the audio volume level.

Parameters
value0 to 15 (if 0, mutes the audio)

◆ getVolume()

uint8_t SI470X::getVolume ( )

Gets the current audio volume level.

Returns
uint8_t 0 to 15

◆ setVolumeUp()

void SI470X::setVolumeUp ( )

Increments the audio volume.

◆ setVolumeDown()

void SI470X::setVolumeDown ( )

Decrements the audio volume.

◆ setExtendedVolumeRange()

void SI470X::setExtendedVolumeRange ( bool  value)

Sets Extended Volume Range.

This bit attenuates the output by 30 dB. With the bit set to 0, the 15 volume settings adjust the volume between 0 and –28 dBFS. With the bit set to 1, the 15 volume set- tings adjust the volume between –30 and –58 dBFS.

Parameters
valuefalse = disabled (default); true = enabled.

◆ getPartNumber()

uint8_t SI470X::getPartNumber ( )

Gets the Part Number.

If it returns 0x01, so the device is: Si4702/03

Returns
the part number

◆ getManufacturerId()

uint16_t SI470X::getManufacturerId ( )

Gets the Manufacturer ID.

Returns
number

◆ getFirmwareVersion()

uint8_t SI470X::getFirmwareVersion ( )

Gets the Firmware Version.

The return velue before powerup will be 0. After powerup should be 010011 (19)

Returns
number

◆ getDeviceId()

uint8_t SI470X::getDeviceId ( )

Gets the Device identification.

Returns
number

◆ getChipVersion()

uint8_t SI470X::getChipVersion ( )

Gets the Chip Version.

Returns
number

◆ setFmDeemphasis()

void SI470X::setFmDeemphasis ( uint8_t  de)

Sets De-emphasis.

75 μs. Used in USA (default); 50 μs. Used in Europe, Australia, Japan.

Parameters
de0 = 75 μs; 1 = 50 μs