PU2CLR SI470X Arduino Library 1.0.1
Arduino Library for Si470X Devices - By Ricardo Lima Caratti
|
SI470X Defined Data Types. More...
Typedefs | |
typedef uint16_t | si470x_reg0c |
RDS Block A. | |
typedef uint16_t | si470x_reg0d |
RDS Block B. | |
typedef uint16_t | si470x_reg0e |
RDS Block C. | |
typedef uint16_t | si470x_reg0f |
RDS Block D. | |
SI470X Defined Data Types.
Defined Data Types is a way to represent the SI470X registers information
Some information appears to be inaccurate due to translation problems from Chinese to English.
The information shown here was extracted from Datasheet:
SI470X stereo FM digital tuning radio documentation.
Other information seems incomplete even in the original Chinese Datasheet.
For example: Reg 10 (0x0A). There is no information about it. The Reg11 and 12 seem wrong
union si470x_reg00 |
Device ID.
Data Fields | ||
---|---|---|
struct si470x_reg00.refined | refined | |
uint16_t | raw |
union si470x_reg01 |
Chip ID.
Data Fields | ||
---|---|---|
struct si470x_reg01.refined | refined | |
uint16_t | raw |
union si470x_reg02 |
Power Configuratio.
Data Fields | ||
---|---|---|
struct si470x_reg02.refined | refined | |
uint16_t | raw |
union si470x_reg03 |
Channe.
Channel value for tune operation. If BAND 05h[7:6] = 00, then Freq (MHz) = Spacing (MHz) x Channel + 87.5 MHz.
If BAND 05h[7:6] = 01, BAND 05h[7:6] = 10, then Freq (MHz) = Spacing (MHz) x Channel + 76 MHz.
CHAN[9:0] is not updated during a seek operation. READCHAN[9:0] provides the current tuned channel and is updated during a seek operation and after a seek or tune operation completes. Channel spacing is set with the bits SPACE 05h[5:4].
The tune operation begins when the TUNE bit is set high. The STC bit is set high when the tune operation completes. The STC bit must be set low by setting the TUNE bit low before the next tune or seek may begin.
Data Fields | ||
---|---|---|
struct si470x_reg03.refined | refined | |
uint16_t | raw |
union si470x_reg04 |
System Configuration 1.
Setting STCIEN = 1 will generate a 5 ms low pulse on GPIO2 when the STC 0Ah[14] bit is set.
Setting RDSIEN = 1 will generate a 5 ms low pulse on GPIO2 when the RDSR 0Ah[15] bit is set.
Setting STCIEN = 1 and GPIO2[1:0] = 01 will generate a 5 ms low pulse on GPIO2 when the STC 0Ah[14] bit is set.
BLNDADJ value | Description |
---|---|
0 | 31–49 RSSI dBμV (default) |
1 | 37–55 RSSI dBμV (+6 dB) |
2 | 19–37 RSSI dBμV (–12 dB) |
3 | 25–43 RSSI dBμV (–6 dB) |
Data Fields | ||
---|---|---|
struct si470x_reg04.refined | refined | |
uint16_t | raw |
union si470x_reg05 |
System Configuration 2.
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."
BAND value | Description |
---|---|
0 | 00 = 87.5–108 MHz (USA, Europe) (Default) |
1 | 01 = 76–108 MHz (Japan wide band) |
2 | 10 = 76–90 MHz (Japan) |
3 | 11 = Reserved |
Data Fields | ||
---|---|---|
struct si470x_reg05.refined | refined | |
uint16_t | raw |
union si470x_reg06 |
System Configuration 3.
The VOLEXT 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.
Refer to 4.5. "Stereo Audio Processing" on page 16.
| Softmute Attenuation | Description | | 0 | 16 dB (default) | | 1 | 14 dB | | 2 | 12 dB | | 3 | 10 dB |
| Softmute Attack/Recover Rate | Description | | 0 | fastest (default) | | 1 | fast | | 2 | slow | | 3 | slowest |
Data Fields | ||
---|---|---|
struct si470x_reg06.refined | refined | |
uint16_t | raw |
union si470x_reg07 |
Test 1.
Setting AHIZEN maintains a dc bias of 0.5 x VIO on the LOUT and ROUT pins to pre- vent the ESD diodes from clamping to the VIO or GND rail in response to the output swing of another device.
Register 07h containing the AHIZEN bit must not be written during the powerup sequence and high-Z only takes effect when in powerdown and VIO is supplied. Bits 13:0 of register 07h must be preserved as 0x0100 while in pow- erdown and as 0x3C04 while in powerup.
The internal crystal oscillator requires an external 32.768 kHz crystal as shown in "Typical Application Schematic" on page 14.
The oscillator must be enabled before powerup (ENABLE = 1) as shown in Figure 9, “Initialization Sequence,” on page 21. It should only be disabled after powerdown (ENABLE = 0).
Bits 13:0 of register 07h must be preserved as 0x0100 while in powerdown and as 0x3C04 while in powerup. Refer to Si4702/03 Internal Crystal Oscillator Errata.
Data Fields | ||
---|---|---|
struct si470x_reg07.refined | refined | |
uint16_t | raw |
union si470x_reg08 |
Test 2.
If written, these bits should be read first and then written with their pre-existing val- ues. Do not write during powerup.
Data Fields | ||
---|---|---|
struct si470x_reg08.refined | refined | |
uint16_t | raw |
union si470x_reg09 |
Boot Configuration.
If written, these bits should be read first and then written with their pre-existing val- ues. Do not write during powerup.
Data Fields | ||
---|---|---|
struct si470x_reg09.refined | refined | |
uint16_t | raw |
union si470x_reg0a |
Status RSSI.
RSSI is measured units of dBμV in 1 dB increments with a maximum of approximately 75 dBμV. Si4702/03-C19 does not report RSSI levels greater than 75 dBuV.
AFCRL is updated after a tune or seek operation completes and indicates a valid or invalid channel. During normal operation, AFCRL is updated to reflect changing RF envi- ronments.
The SF/BL flag is set high when SKMODE 02h[10] = 0 and the seek operation fails to find a channel qualified as valid according to the seek parameters.
The SF/BL flag is set high when SKMODE 02h[10] = 1 and the upper or lower band limit has been reached. The SEEK 02h[8] bit must be set low to clear SF/BL.
The seek/tune complete flag is set when the seek or tune operation completes. Setting the SEEK 02h[8] or TUNE 03h[15] bit low will clear STC.
RDS Block A Errors | Description |
---|---|
0 | 0 errors requiring correction |
1 | 1–2 errors requiring correction |
2 | 3–5 errors requiring correction |
3 | 6+ errors or error in checkword, correction not possible |
Data Fields | ||
---|---|---|
struct si470x_reg0a.refined | refined | |
uint16_t | raw |
union si470x_reg0b |
Read Channel.
If BAND 05h[7:6] = 00, then Freq (MHz) = Spacing (MHz) x Channel + 87.5 MHz. If BAND 05h[7:6] = 01, BAND 05h[7:6] = 10, then Freq (MHz) = Spacing (MHz) x Channel + 76 MHz.
READCHAN[9:0] provides the current tuned channel and is updated during a seek operation and after a seek or tune operation completes. Spacing and channel are set with the bits SPACE 05h[5:4] and CHAN 03h[9:0].
RDS block Errors | Description |
---|---|
0 | 0 errors requiring correction |
1 | 1–2 errors requiring correction |
2 | 3–5 errors requiring correction |
3 | 6+ errors or error in checkword, correction not possible |
Data Fields | ||
---|---|---|
struct si470x_reg0b.refined | refined | |
uint16_t | raw |
union si470x_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.
Data Fields | ||
---|---|---|
struct si470x_rds_blockb.group0 | group0 | |
struct si470x_rds_blockb.group2 | group2 | |
struct si470x_rds_blockb.refined | refined | |
si470x_reg0d | blockB |
union si470x_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 Crosses boundary, it was necessary to use uint32_t data type.
Data Fields | ||
---|---|---|
struct si470x_rds_date_time.refined | refined | |
uint8_t | raw[6] |
union word16_to_bytes |
Converts 16 bits word to two bytes.
Data Fields | ||
---|---|---|
struct word16_to_bytes.refined | refined | |
uint16_t | raw |
class SI470X |
KT0915 Class.
<>
This class implements all functions that will help you to control the KT0915 devices.
Public Member Functions | |
void | setI2CAddress (int bus_addr) |
Sets the I2C bus address. | |
void | setDelayAfterCrystalOn (uint8_t ms_value) |
Set the Delay After Crystal On (default 500ms) | |
void | getAllRegisters () |
Gets all current register content of the device. | |
void | setAllRegisters (uint8_t limit=0x07) |
Sets values to the device registers from 0x02 to 0x07. | |
void | getStatus () |
Gets the value of the 0x0A register. | |
uint16_t | getShadownRegister (uint8_t register_number) |
Get the Shadown Register object. | |
void | setShadownRegister (uint8_t register_number, uint16_t value) |
Sets a given value to the Shadown Register. | |
void | setup (int resetPin, int sdaPin, int rdsInterruptPin=-1, int seekInterruptPin=-1, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL) |
Starts the device. | |
void | setup (int resetPin, int sdaPin, uint8_t oscillator_type) |
Starts the device. | |
void | setFrequency (uint16_t frequency) |
Sets the FM frequency. | |
void | setFrequencyUp () |
Increments the current frequency. | |
void | setFrequencyDown () |
Decrements the current frequency. | |
uint16_t | getFrequency () |
Gets the current frequency. | |
uint16_t | getRealFrequency () |
Gets the frequency based on READCHAN register (0x0B) | |
uint16_t | getRealChannel () |
Gets the current channel stored in register 0x0B. | |
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=1) |
Sets the FM Band | |
void | setSpace (uint8_t space=0) |
Sets the FM Space | |
int | getRssi () |
Gets the Rssi. | |
void | setSoftmute (bool value) |
Sets the Softmute true or false. | |
void | setSoftmuteAttack (uint8_t value) |
Sets Softmute Attack/Recover Rate. | |
void | setSoftmuteAttenuation (uint8_t value) |
Sets Softmute Attenuation.. | |
void | setAgc (bool value) |
Sets the AGC enable or disable. | |
void | setMono (bool value) |
Sets the Mono true or false (stereo) | |
bool | isStereo () |
Checks stereo / mono status. | |
uint8_t | getPartNumber () |
Gets the Part Number. | |
uint16_t | getManufacturerId () |
Gets the Manufacturer ID. | |
uint8_t | getFirmwareVersion () |
Gets the Firmware Version. | |
uint8_t | getDeviceId () |
Gets the Device identification. | |
uint8_t | getChipVersion () |
Gets the Chip Version. | |
void | setMute (bool value) |
Sets the Mute true or false. | |
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 | setExtendedVolumeRange (bool value) |
Sets Extended Volume Range. | |
void | setFmDeemphasis (uint8_t de) |
Sets De-emphasis. | |
void | getRdsStatus () |
Gets the RDS registers information. | |
void | setRdsMode (uint8_t rds_mode=0) |
Sets the Rds Mode Standard or Verbose. | |
void | setRds (bool value) |
Sets the RDS operation. | |
void | setRDS (bool value) |
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 | |
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) | |
void | getNext2Block (char *c) |
Process data received from group 2B. | |
void | getNext4Block (char *c) |
Process data received from group 2A. | |
char * | getRdsText (void) |
Gets the RDS Text when the message is of the Group Type 2 version A. | |
char * | getRdsText0A (void) |
Gets the station name and other messages. | |
char * | getRdsText2A (void) |
Gets the Text processed for the 2A group. | |
char * | getRdsText2B (void) |
Gets the Text processed for the 2B group. | |
char * | getRdsTime () |
Gets the RDS time and date when the Group type is 4. | |
char * | getRdsLocalTime () |
Gets the RDS time converted to local time. | |
bool | getRdsSync () |
Get the Rds Sync. | |
void | clearRdsBuffer () |
Clear RDS Information (Station Name, Station Information, Program Information and Time) | |
int | checkI2C (uint8_t *addressArray) |
Check the I2C bus address. | |
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. | |
Protected Member Functions | |
void | reset () |
Resets the device. | |
void | powerUp () |
Powers the receiver on. | |
void | powerDown () |
Powers the receiver off. | |
void | waitAndFinishTune () |
Wait STC (Seek/Tune Complete) status becomes 0. | |
Protected Attributes | |
char | rds_buffer2A [65] |
RDS Radio Text buffer - Program Information. | |
char | rds_buffer2B [33] |
RDS Radio Text buffer - Station Informaation. | |
char | rds_buffer0A [9] |
RDS Basic tuning and switching information (Type 0 groups) | |
char | rds_time [20] |
RDS date time received information. | |
int | deviceAddress = I2C_DEVICE_ADDR |
int | resetPin |
uint16_t | currentFrequency |
uint8_t | currentFMBand = 0 |
uint8_t | currentFMSpace = 0 |
uint8_t | currentVolume = 0 |
int | rdsInterruptPin = -1 |
int | seekInterruptPin = -1 |
int | oscillatorType = OSCILLATOR_TYPE_CRYSTAL |
uint16_t | maxDelayAftarCrystalOn = MAX_DELAY_AFTER_OSCILLATOR |
|
inline |
References setRds().
|
protected |
RDS Radio Text buffer - Program Information.
Referenced by clearRdsBuffer(), getRdsText(), and getRdsText2A().
|
protected |
RDS Radio Text buffer - Station Informaation.
Referenced by clearRdsBuffer(), and getRdsText2B().
|
protected |
RDS Basic tuning and switching information (Type 0 groups)
Referenced by clearRdsBuffer(), and getRdsText0A().
|
protected |
RDS date time received information.
Referenced by clearRdsBuffer(), getRdsLocalTime(), and getRdsTime().
|
protected |
Referenced by setI2CAddress().
|
protected |
Referenced by setup().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by setup().
|
protected |
Referenced by setup().
|
protected |
|
protected |
struct si470x_reg00.refined |
struct si470x_reg01.refined |
struct si470x_reg02.refined |
struct si470x_reg03.refined |
struct si470x_reg04.refined |
struct si470x_reg05.refined |
struct si470x_reg06.refined |
struct si470x_reg07.refined |
struct si470x_reg0a.refined |
struct si470x_reg0b.refined |
struct si470x_rds_blockb.group0 |
struct si470x_rds_blockb.group2 |
struct si470x_rds_blockb.refined |
struct si470x_rds_date_time.refined |
typedef uint16_t si470x_reg0c |
RDS Block A.
RDS Block A Data.
typedef uint16_t si470x_reg0d |
RDS Block B.
RDS Block B Data.
typedef uint16_t si470x_reg0e |
RDS Block C.
RDS Block C Data.
typedef uint16_t si470x_reg0f |
RDS Block D.
RDS Block D Data.