PU2CLR SI470X Arduino Library 1.0.1
Arduino Library for Si470X Devices - By Ricardo Lima Caratti
|
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. | |
|
inline |
Sets the I2C bus address.
This function must to be called before setup function if your device are not using 0x10 (default)
bus_addr | I2C buss address |
References SI470X::deviceAddress.
|
inline |
Set the Delay After Crystal On (default 500ms)
ms_value | Value in milliseconds |
|
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().
register_number |
|
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.
register_number | register index (from 0x00 to 0x0F) |
value | 16 bits word with the content of the register |
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.
Referenced by SI470X::getRealChannel(), SI470X::powerDown(), SI470X::powerUp(), SI470X::seek(), and SI470X::waitAndFinishTune().
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.
void SI470X::getStatus | ( | ) |
Gets the value of the 0x0A register.
This function also updates the value of shadowRegisters[0];
Referenced by SI470X::getRdsReady(), SI470X::getRdsSync(), SI470X::getRssi(), and SI470X::isStereo().
|
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().
|
protected |
Resets the device.
Referenced by SI470X::setup().
|
protected |
Powers the receiver on.
Starts the receiver with some default configurations
References SI470X::getAllRegisters().
Referenced by SI470X::setup().
|
protected |
Powers the receiver off.
References SI470X::getAllRegisters().
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
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.
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
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. |
void SI470X::setChannel | ( | uint16_t | channel | ) |
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).
frequency | 7600 to 1080 (means 76Mhz to 108Mhz) |
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};
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};
uint16_t SI470X::getFrequency | ( | ) |
Gets the current frequency.
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.
References SI470X::getAllRegisters().
uint16_t SI470X::getRealFrequency | ( | ) |
Gets the frequency based on READCHAN register (0x0B)
Unlike getFrequency method, this method queries the device.
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.
seek_mode | Seek Mode; 0 = Wrap at the upper or lower band limit and continue seeking (default); 1 = Stop seeking at the upper or lower band limit. |
direction | Seek Direction; 0 = Seek down (default); 1 = Seek up. |
References SI470X::getAllRegisters(), and SI470X::waitAndFinishTune().
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:
seek_mode | Seek Mode; 0 = Wrap at the upper or lower band limit and continue seeking (default); 1 = Stop seeking at the upper or lower band limit. |
direction | Seek Direction; 0 = Seek down (default); 1 = Seek up. |
showFunc | function 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().
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."
value | between 0 and 127 |
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 |
band | See the table above. If you do not set a parameter, will be considered 1 (76-108MHz) |
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) |
int SI470X::getRssi | ( | ) |
void SI470X::setSoftmute | ( | bool | value | ) |
Sets the Softmute true or false.
value | TRUE or FALSE |
void SI470X::setSoftmuteAttack | ( | uint8_t | value | ) |
Sets Softmute Attack/Recover Rate.
Value | Description |
---|---|
0 | fastest (default) |
1 | fast |
2 | slow |
3 | slowest |
value | See table above |
void SI470X::setSoftmuteAttenuation | ( | uint8_t | value | ) |
Sets Softmute Attenuation..
Value | Description |
---|---|
0 | 16 dB (default) |
1 | 14 dB |
2 | 12 dB |
3 | 10 dB |
value | See table above |
void SI470X::setAgc | ( | bool | value | ) |
Sets the AGC enable or disable.
value | true = enable; fale = disable |
void SI470X::setMute | ( | bool | value | ) |
Sets the Mute true or false.
value | TRUE or FALSE |
void SI470X::setMono | ( | bool | value | ) |
Sets the Mono true or false (stereo)
value | TRUE or FALSE |
bool SI470X::isStereo | ( | ) |
void SI470X::setVolume | ( | uint8_t | value | ) |
Sets the audio volume level.
value | 0 to 15 (if 0, mutes the audio) |
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.
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.
value | false = disabled (default); true = enabled. |
uint8_t SI470X::getPartNumber | ( | ) |
Gets the Part Number.
If it returns 0x01, so the device is: Si4702/03
uint16_t SI470X::getManufacturerId | ( | ) |
Gets the Manufacturer ID.
uint8_t SI470X::getFirmwareVersion | ( | ) |
Gets the Firmware Version.
The return velue before powerup will be 0. After powerup should be 010011 (19)
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.
75 μs. Used in USA (default); 50 μs. Used in Europe, Australia, Japan.
de | 0 = 75 μs; 1 = 50 μs |