PU2CLR BK108X Arduino Library 1.0.2
This is an Arduino Library to control the BK108X device
|
BK108X Defined Data Types. More...
Classes | |
union | bk_reg00 |
Device ID. More... | |
union | bk_reg01 |
Chip ID. More... | |
union | bk_reg02 |
Power Configuratio. More... | |
union | bk_reg03 |
Channe. More... | |
union | bk_reg04 |
Register 04h. System Configuration1 (0x1180) More... | |
union | bk_reg05 |
Register 05h. System Configuration2 (0x3ddf) More... | |
union | bk_reg06 |
Register 06h. System Configuration3 (0x01ef) More... | |
union | bk_reg07 |
Register 07h. Test1 (0x0900) More... | |
union | bk_reg08 |
Test 2. More... | |
union | bk_reg09 |
Register 09h. Status1 (0x0000) More... | |
union | bk_reg0a |
Register 0Ah. Status2 (0x0000) More... | |
union | bk_reg0b |
Register 0Bh. Read Channel (0x0000) More... | |
union | bk_reg0c |
Register 0Ch. RDS1 (0x0000) More... | |
union | bk_reg0d |
Register 0Dh. RDS2 (0x0000) More... | |
union | bk_reg0e |
Register 0Eh. RDS2 (0x0000) More... | |
union | bk_reg0f |
Register 0Fh. RDS4 (0x0000) More... | |
union | bk_reg10 |
Register 10h. Boot Configuration1 (0x7b11) More... | |
union | bk_reg11 |
Register 11h. Boot Configuration2 (0x0080) More... | |
union | bk_reg12 |
Register 12h. Boot Configuration3 (0x4000) More... | |
union | bk_reg13 |
Register 13h. Boot Configuration4 (0x3e00) More... | |
union | bk_reg14 |
Register 14h. Boot Configuration5 (0x0000) More... | |
union | bk_reg15 |
15h. Boot Configuration6 (0x0000) More... | |
union | bk_reg16 |
Register 16h. Boot Configuration7 (0x0400) More... | |
union | bk_reg17 |
Register 17h. Boot Configuration8 (0x0001) More... | |
union | bk_reg18 |
Register 18h. Boot Configuration9 (0x143c) More... | |
union | bk_reg19 |
Register 19h. Boot Configuration10 (0x4351) More... | |
union | bk_reg1A |
Register 1Ah. Boot Configuration11 (0x0000) More... | |
union | bk_reg1B |
Register 1Bh. Analog Configuration1 (0x0000) More... | |
union | bk_reg1C |
Register 1Ch. Analog Configuration2 (0x0000) More... | |
union | bk_reg1D |
Register 1Dh. Analog Configuration2 (0x0000) More... | |
union | bk_rds_blockb |
RDS Block B data type. More... | |
union | bk_rds_date_time |
union | word16_to_bytes |
Converts 16 bits word to two bytes. More... | |
class | BK108X |
KT0915 Class. More... | |
struct | bk_reg00.refined |
struct | bk_reg01.refined |
struct | bk_reg02.refined |
struct | bk_reg03.refined |
struct | bk_reg04.refined |
struct | bk_reg05.refined |
struct | bk_reg06.refined |
struct | bk_reg07.refined |
struct | bk_reg08.refined |
struct | bk_reg09.refined |
struct | bk_reg0a.refined |
struct | bk_reg0b.refined |
struct | bk_reg0c.rds_status |
struct | bk_reg0c.refined |
struct | bk_reg0d.refined |
struct | bk_reg0e.refined |
struct | bk_reg0f.refined |
struct | bk_reg10.refined |
struct | bk_reg11.refined |
struct | bk_reg12.refined |
struct | bk_reg13.refined |
struct | bk_reg14.refined |
struct | bk_reg15.refined |
struct | bk_reg16.refined |
struct | bk_reg17.refined |
struct | bk_reg18.refined |
struct | bk_reg19.refined |
struct | bk_reg1A.refined |
struct | bk_reg1B.refined |
struct | bk_reg1C.refined |
struct | bk_reg1D.refined |
struct | bk_rds_blockb.group0 |
struct | bk_rds_blockb.group2 |
struct | bk_rds_blockb.refined |
struct | bk_rds_date_time.refined |
struct | word16_to_bytes.refined |
BK108X Defined Data Types.
Defined Data Types is a way to represent the BK108X registers information
Some information appears to be inaccurate due to translation problems from Chinese to English.
The information shown here was extracted from Datasheet:
BK108X 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 bk_reg00 |
Class Members | ||
---|---|---|
struct bk_reg00.refined | refined | |
uint16_t | deviceId |
union bk_reg01 |
Class Members | ||
---|---|---|
struct bk_reg01.refined | refined | |
uint16_t | chipId |
union bk_reg02 |
Power Configuratio.
Class Members | ||
---|---|---|
struct bk_reg02.refined | refined | |
uint16_t | raw |
union bk_reg03 |
Channe.
The tuned Frequency = Band + CHAN * SPACE
Class Members | ||
---|---|---|
struct bk_reg03.refined | refined | |
uint16_t | raw |
union bk_reg04 |
Register 04h. System Configuration1 (0x1180)
When register GPIO2[1:0]=2’b01 and seek or tune finish, a 5ms low pulse will appear at GPIO2 .Both RDSIEN and STCIEN can be high;
When register GPIO2[1:0]=2’b01 and new RDS come, a 5ms low pulse will appear at GPIO2.
Class Members | ||
---|---|---|
struct bk_reg04.refined | refined | |
uint16_t | raw |
union bk_reg05 |
Register 05h. System Configuration2 (0x3ddf)
LW and SW Band are only defined at BK1088
AM and Fm Band table ()
BAND value | AM band KHz | FM band MHz |
---|---|---|
0 | 00: LW 153~279 | FULL 64~108 |
1 | 10: MW 520~1710 | East Europe 64~76 |
2 | 10: SW 2.3~21.85 | Japan 76~91 |
3 | 11: MW 522~1710 | Europe 87~108 |
AM and FM Channel Space
BAND value | AM Space KHz | FM Space KHz |
---|---|---|
0 | 1 | 10 |
1 | 5 | 50 |
2 | 9 | 100 |
3 | 10 | 200 |
Class Members | ||
---|---|---|
struct bk_reg05.refined | refined | |
uint16_t | raw |
union bk_reg06 |
Register 06h. System Configuration3 (0x01ef)
SKCNT - Seek Impulse Detection Threshold Allowable number of impulse for a valid seek channel while setting all zeros means not use Impulse number to judge the channel’s validity.
SMUTEA table
Softmute Attenuation | Description |
---|---|
0 | 16 dB (default) |
1 | 14 dB |
2 | 12 dB |
3 | 10 dB |
SMUTER table
Softmute Attack/Recover Rate | Description |
---|---|
0 | fastest (default) |
1 | fast |
2 | slow |
3 | slowest |
Class Members | ||
---|---|---|
struct bk_reg06.refined | refined | |
uint16_t | raw |
union bk_reg07 |
Class Members | ||
---|---|---|
struct bk_reg07.refined | refined | |
uint16_t | raw |
union bk_reg08 |
Test 2.
RSSI Threshold for Instant AFC updating; AFC Average Range; Variation Threshold for average AFC calculation;
AFC Average; AFCRL Threshold; AFC/RSSI/SNR Calculate Rate; AFC Enable
Class Members | ||
---|---|---|
struct bk_reg08.refined | refined | |
uint16_t | raw |
union bk_reg09 |
Class Members | ||
---|---|---|
struct bk_reg09.refined | refined | |
uint16_t | raw |
union bk_reg0a |
Class Members | ||
---|---|---|
struct bk_reg0a.refined | refined | |
uint16_t | raw |
union bk_reg0b |
Class Members | ||
---|---|---|
struct bk_reg0b.refined | refined | |
uint16_t | raw |
union bk_reg0c |
Register 0Ch. RDS1 (0x0000)
RDS Block A - The First Register of RDS Received
Class Members | ||
---|---|---|
struct bk_reg0c.rds_status | rds_status | |
struct bk_reg0c.refined | refined | |
uint16_t | raw |
union bk_reg0d |
Register 0Dh. RDS2 (0x0000)
RDS Block B - The second register of RDS received
Class Members | ||
---|---|---|
struct bk_reg0d.refined | refined | |
uint16_t | raw |
union bk_reg0e |
Register 0Eh. RDS2 (0x0000)
RDS Block C - The third register of RDS received
Class Members | ||
---|---|---|
struct bk_reg0e.refined | refined | |
uint16_t | raw |
union bk_reg0f |
Register 0Fh. RDS4 (0x0000)
RDS Block D - The fourth register of RDS received when read
Class Members | ||
---|---|---|
struct bk_reg0f.refined | refined | |
uint16_t | raw |
union bk_reg10 |
Class Members | ||
---|---|---|
struct bk_reg10.refined | refined | |
uint16_t | raw |
union bk_reg11 |
Class Members | ||
---|---|---|
struct bk_reg11.refined | refined | |
uint16_t | raw |
union bk_reg12 |
Class Members | ||
---|---|---|
struct bk_reg12.refined | refined | |
uint16_t | raw |
union bk_reg13 |
Class Members | ||
---|---|---|
struct bk_reg13.refined | refined | |
uint16_t | raw |
union bk_reg14 |
Class Members | ||
---|---|---|
struct bk_reg14.refined | refined | |
uint16_t | raw |
union bk_reg15 |
Class Members | ||
---|---|---|
struct bk_reg15.refined | refined | |
uint16_t | raw |
union bk_reg16 |
Class Members | ||
---|---|---|
struct bk_reg16.refined | refined | |
uint16_t | raw |
union bk_reg17 |
Class Members | ||
---|---|---|
struct bk_reg17.refined | refined | |
uint16_t | raw |
union bk_reg18 |
Class Members | ||
---|---|---|
struct bk_reg18.refined | refined | |
uint16_t | raw |
union bk_reg19 |
Class Members | ||
---|---|---|
struct bk_reg19.refined | refined | |
uint16_t | raw |
union bk_reg1A |
Class Members | ||
---|---|---|
struct bk_reg1A.refined | refined | |
uint16_t | raw |
union bk_reg1B |
Class Members | ||
---|---|---|
struct bk_reg1B.refined | refined | |
uint16_t | raw |
union bk_reg1C |
Class Members | ||
---|---|---|
struct bk_reg1C.refined | refined | |
uint16_t | raw |
union bk_reg1D |
Class Members | ||
---|---|---|
struct bk_reg1D.refined | refined | |
uint16_t | raw | //!< Reference clock divider control , FREQ_SEL[17:0] = HEX | Ref Frequency/512+0.5 | Default 16 for 32.768kHz reference. |
union bk_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.
Class Members | ||
---|---|---|
struct bk_rds_blockb.group0 | group0 | |
struct bk_rds_blockb.group2 | group2 | |
struct bk_rds_blockb.refined | refined | |
uint16_t | blockB |
union bk_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 split minute and hour representation.
Class Members | ||
---|---|---|
struct bk_rds_date_time.refined | refined | |
uint8_t | raw[6] |
union word16_to_bytes |
Class Members | ||
---|---|---|
struct word16_to_bytes.refined | refined | |
uint16_t | raw |
class BK108X |
KT0915 Class.
<>
This class implements all functions that will help you to control the KT0915 devices.
Public Member Functions | |
void | setI2C (uint8_t i2c_addr=I2C_DEVICE_ADDR) |
Sets I2C bus address. | |
void | i2cInit (int pin_sdio, int pin_sclk) |
Sets the MCU pins connected to the I2C bus. | |
void | i2cBeginTransaction () |
Starts the I2C bus transaction. | |
void | i2cEndTransaction () |
Finish the I2C bus transaction. | |
void | i2cAck () |
Sends Acknowledge (ACK) | |
void | i2cNack () |
Sends Not Acknowledge (ACK) | |
uint8_t | i2cReceiveAck () |
Gets Acknowledge (ACK) | |
void | i2cWriteByte (uint8_t data) |
Sends a Byte to the slave device. | |
uint8_t | i2cReadByte () |
Gets a Byte from the slave device. | |
void | writeRegister (uint8_t reg, uint16_t vakue) |
Sends an array of values to a BK108X given register. | |
uint16_t | readRegister (uint8_t reg) |
Gets an array of values from a BK108X given register. | |
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. | |
void | setI2CAddress (int bus_addr) |
Sets the I2C bus address. | |
void | setDelayAfterCrystalOn (uint8_t ms_value) |
Set the Delay After Crystal On (default 500ms) | |
uint16_t | getRegister (uint8_t reg) |
Gets a givens current register content of the device. | |
void | setRegister (uint8_t reg, uint16_t value) |
Sets a given value to the device registers. | |
bk_reg0a | getStatus () |
Gets the current status (register 0x0A) content. | |
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. | |
uint16_t | getDeviceId () |
Returns the Device Indentifiction. | |
uint16_t | getChipId () |
Returns the Chip Indentifiction. | |
void | setup (int sda_pin, int sclk_pin, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL, uint32_t oscillator_frequency=32768) |
Starts the device. | |
void | setFM (uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step) |
Sets the receiver to FM mode. | |
void | setAM (uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step, uint16_t am_space=0) |
Sets the receiver to AM mode. | |
void | setFMGain (uint8_t value=0) |
set the FM gain. | |
uint8_t | getCurrentMode () |
Get the Current Mode (AM or FM) | |
void | setStereoThresholdPilotStrength (uint8_t value) |
Sets the Stereo Threshold of Pilotto Strength. | |
void | setFmDeemphasis (uint8_t de) |
Sets De-emphasis. | |
void | setTimeCallStrengthPilot (uint8_t value) |
Sets the time used to call the strength of pilot. | |
void | setGpio2 (uint8_t value) |
Sets the Gpio2. | |
void | setGpio3 (uint8_t value) |
Sets the Gpio3. | |
void | setAfc (bool value) |
Enables or Disables AFC. | |
void | AfcRail (bool value) |
Sets AFC Rail. | |
void | setAfcRssiSnrCalculateRate (uint8_t value) |
Sets AFC/RSSI/SNR Calculate Rate. | |
void | setAfcThreshold (uint8_t value) |
Sets AFCRL Threshold. | |
void | setAfcAve (uint8_t value) |
Sets AFC Average. | |
void | setAfcVar (uint8_t value) |
Sets Variation Threshold for average AFC calculation. | |
void | setAfcRange (uint8_t value) |
Sets AFC range. | |
void | setAfcRssiThreshold (uint8_t value) |
Sets RSSI Threshold for Instant AFC updating. | |
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 | getChannel () |
Gets the current channel. | |
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 | seekHardware (uint8_t seek_mode, uint8_t direction, void(*showFunc)()=NULL) |
Seeks a station via hardware functionality. | |
void | seekSoftware (uint8_t seek_mode, uint8_t direction, void(*showFunc)()=NULL) |
Seeks a station via Software. | |
void | seek (uint8_t seek_mode, uint8_t direction, void(*showFunc)()=NULL) |
void | setSeekThreshold (uint8_t rssiValue, uint8_t snrValue) |
Sets RSSI and SNR Seek Threshold. | |
void | setBand (uint8_t band=1) |
Sets the current band for AM or FM. | |
void | setSpace (uint8_t space=0) |
Sets the Space channel for AM or FM. | |
int | getRssi () |
Gets the current Rssi. | |
int | getSnr () |
Gets the current SNR. | |
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 | setMuteThreshold (uint8_t rssi, uint8_t snr) |
Set the Mute Threshold based on RSSI and SNR. | |
void | setSeekMute (bool value) |
Disable or Enable soft mute when seeking. | |
void | setAfcMute (bool value) |
Disable or Enable soft mute when AFCRL is high. | |
void | setMono (bool value) |
Sets the Mono true or false (stereo) | |
bool | isStereo () |
Checks stereo / mono status. | |
void | setAudioMute (bool left, bool right) |
Sets the Mute true or false. | |
void | setAudioMute (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 | setRdsMode (uint8_t rds_mode=0) |
Sets the Rds Mode Standard or Verbose. | |
void | setRds (bool value, bool interrupt_enable=false) |
Sets the RDS operation. | |
void | setRDS (bool value, bool interrupt_enable=false) |
bool | getRdsReady () |
Returns true if RDS Ready. | |
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 - Gets the Group Type (extracted from the Block B) | |
uint8_t | getRdsProgramType (void) |
Returns the Program Type (extracted from the Block B) | |
void | getNext2Block (char *c) |
Process data received from group 2B - Station Name. | |
void | getNext4Block (char *c) |
Processes 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. | |
bool | getRdsAllData (char **stationName, char **stationInformation, char **programInformation, char **utcTime) |
Gets Station Name, Station Information, Program Information and utcTime. | |
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. | |
char * | getRdsProgramInformation (void) |
Gets the Program Information (RT - Radio Text) | |
char * | getRdsStationInformation (void) |
Gets the Station Information. | |
char * | getRdsStationName (void) |
Gets the Station Name. | |
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. | |
uint16_t * | getRegisterValues () |
Returns the point of uint16_t array (size 32) | |
char * | formatFrequency (uint16_t value, char *strValue, char decimalSeparator=',', uint8_t decimalPosition=3) |
Convert a numeric frequency to a formated string (char *) frequency. | |
char * | formatCurrentFrequency (char decimalSeparator=',', uint8_t decimalPosition=3) |
Convert the current frequency to a formated string (char *) frequency. | |
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. | |
uint8_t | rds_mode |
int | deviceAddress = I2C_DEVICE_ADDR |
uint32_t | currentFrequency |
uint32_t | minimumFrequency |
uint32_t | maximumFrequency |
uint16_t | currentChannel = 0 |
uint16_t | currentStep = 1 |
uint8_t | currentFMBand = 0 |
uint8_t | currentAMBand = 1 |
uint8_t | currentFMSpace = 0 |
uint8_t | currentAMSpace = 0 |
uint8_t | currentMode = BK_MODE_FM |
uint8_t | currentVolume = 0 |
int | rdsInterruptPin = -1 |
int | seekInterruptPin = -1 |
int | oscillatorType = OSCILLATOR_TYPE_CRYSTAL |
uint32_t | oscillatorFrequency = 32768 |
uint16_t | maxDelayAfterCrystalOn = MAX_DELAY_AFTER_OSCILLATOR |
uint16_t BK108X::getDeviceId | ( | ) |
uint16_t BK108X::getChipId | ( | ) |
|
inline |
|
inline |
|
inline |
|
protected |
RDS Radio Text buffer - Program Information.
Definition at line 788 of file BK108X.h.
Referenced by clearRdsBuffer(), and getRdsText2A().
|
protected |
RDS Radio Text buffer - Station Informaation.
Definition at line 789 of file BK108X.h.
Referenced by clearRdsBuffer(), and getRdsText2B().
|
protected |
RDS Basic tuning and switching information (Type 0 groups)
Definition at line 790 of file BK108X.h.
Referenced by clearRdsBuffer(), and getRdsText0A().
|
protected |
RDS date time received information.
Definition at line 791 of file BK108X.h.
Referenced by clearRdsBuffer(), getRdsLocalTime(), and getRdsTime().
|
protected |
Definition at line 795 of file BK108X.h.
Referenced by readRegister(), setI2CAddress(), and writeRegister().
|
protected |
|
protected |
|
protected |
struct bk_reg00.refined |
struct bk_reg01.refined |
struct bk_reg02.refined |
struct bk_reg03.refined |
struct bk_reg04.refined |
struct bk_reg05.refined |
struct bk_reg06.refined |
struct bk_reg07.refined |
struct bk_reg08.refined |
struct bk_reg09.refined |
struct bk_reg0a.refined |
struct bk_reg0b.refined |
struct bk_reg0c.rds_status |
struct bk_reg0c.refined |
struct bk_reg0d.refined |
struct bk_reg0e.refined |
struct bk_reg0f.refined |
struct bk_reg10.refined |
struct bk_reg11.refined |
struct bk_reg12.refined |
struct bk_reg13.refined |
struct bk_reg14.refined |
struct bk_reg15.refined |
struct bk_reg16.refined |
struct bk_reg17.refined |
struct bk_reg18.refined |
struct bk_reg19.refined |
struct bk_reg1A.refined |
struct bk_reg1C.refined |
struct bk_rds_blockb.group0 |
struct bk_rds_blockb.group2 |
struct bk_rds_blockb.refined |
struct bk_rds_date_time.refined |