 |
PU2CLR BK108X Arduino Library
1.0.1
This is an Arduino Library to control the BK108X device
|
Go to the documentation of this file.
21 #define MAX_DELAY_AFTER_OSCILLATOR 500
23 #define I2C_DEVICE_ADDR 0x80
25 #define MAX_SEEK_TIME 3000
27 #define OSCILLATOR_TYPE_CRYSTAL 1
28 #define OSCILLATOR_TYPE_REFCLK 0
30 #define RDS_STANDARD 0
32 #define BK_SEEK_DOWN 0
34 #define BK_SEEK_WRAP 0
35 #define BK_SEEK_STOP 1
38 #define FM_BAND_JAPAN_WIDE 1
39 #define FM_BAND_JAPAN 2
40 #define FM_BAND_USA_EU 3
50 #define DE_EMPHASIS_75 0
51 #define DE_EMPHASIS_50 1
277 uint8_t STHYS_SEL : 1;
278 uint8_t DACCK_SEL : 1;
284 uint8_t LINEIN_EN : 1;
285 uint8_t LINEIN_SEL : 1;
301 uint8_t AFCRSSIT : 7;
354 uint16_t READCHAN : 14;
355 uint16_t RESERVED : 2;
570 uint16_t RESERVED1 : 3;
571 uint16_t ANT_SEL : 5;
572 uint16_t RESERVED2 : 4;
597 uint16_t RESERVED : 15;
598 uint16_t FREQ_SEL : 1;
649 uint8_t programType : 5;
650 uint8_t trafficProgramCode : 1;
651 uint8_t versionCode : 1;
652 uint8_t groupType : 4;
657 uint8_t textABFlag : 1;
658 uint8_t programType : 5;
659 uint8_t trafficProgramCode : 1;
660 uint8_t versionCode : 1;
661 uint8_t groupType : 4;
666 uint8_t textABFlag : 1;
667 uint8_t programType : 5;
668 uint8_t trafficProgramCode : 1;
669 uint8_t versionCode : 1;
670 uint8_t groupType : 4;
690 uint8_t offset_sense : 1;
728 uint8_t i2cBuffer[32];
730 uint16_t shadowRegisters[32];
733 bk_reg00 *reg00 = (bk_reg00 *)&shadowRegisters[
REG00];
734 bk_reg01 *reg01 = (bk_reg01 *)&shadowRegisters[
REG01];
735 bk_reg02 *reg02 = (bk_reg02 *)&shadowRegisters[
REG02];
736 bk_reg03 *reg03 = (bk_reg03 *)&shadowRegisters[
REG03];
737 bk_reg04 *reg04 = (bk_reg04 *)&shadowRegisters[
REG04];
738 bk_reg05 *reg05 = (bk_reg05 *)&shadowRegisters[
REG05];
739 bk_reg06 *reg06 = (bk_reg06 *)&shadowRegisters[
REG06];
740 bk_reg07 *reg07 = (bk_reg07 *)&shadowRegisters[
REG07];
741 bk_reg08 *reg08 = (bk_reg08 *)&shadowRegisters[
REG08];
742 bk_reg09 *reg09 = (bk_reg09 *)&shadowRegisters[
REG09];
743 bk_reg0a *reg0a = (bk_reg0a *)&shadowRegisters[
REG0A];
744 bk_reg0b *reg0b = (bk_reg0b *)&shadowRegisters[
REG0B];
745 bk_reg0c *reg0c = (bk_reg0c *)&shadowRegisters[
REG0C];
746 bk_reg0d *reg0d = (bk_reg0d *)&shadowRegisters[
REG0D];
747 bk_reg0e *reg0e = (bk_reg0e *)&shadowRegisters[
REG0E];
748 bk_reg0f *reg0f = (bk_reg0f *)&shadowRegisters[
REG0F];
749 bk_reg10 *reg10 = (bk_reg10 *)&shadowRegisters[
REG10];
750 bk_reg11 *reg11 = (bk_reg11 *)&shadowRegisters[
REG11];
751 bk_reg12 *reg12 = (bk_reg12 *)&shadowRegisters[
REG12];
752 bk_reg13 *reg13 = (bk_reg13 *)&shadowRegisters[
REG13];
753 bk_reg14 *reg14 = (bk_reg14 *)&shadowRegisters[
REG14];
754 bk_reg15 *reg15 = (bk_reg15 *)&shadowRegisters[
REG15];
755 bk_reg16 *reg16 = (bk_reg16 *)&shadowRegisters[
REG16];
756 bk_reg17 *reg17 = (bk_reg17 *)&shadowRegisters[
REG17];
757 bk_reg18 *reg18 = (bk_reg18 *)&shadowRegisters[
REG18];
758 bk_reg19 *reg19 = (bk_reg19 *)&shadowRegisters[
REG19];
759 bk_reg1A *reg1A = (bk_reg1A *)&shadowRegisters[
REG1A];
760 bk_reg1B *reg1b = (bk_reg1B *)&shadowRegisters[
REG1B];
761 bk_reg1C *reg1c = (bk_reg1C *)&shadowRegisters[
REG1C];
762 bk_reg1D *reg1d = (bk_reg1D *)&shadowRegisters[
REG1D];
766 uint16_t fmStartBand[4] = {6400, 7400, 7600, 8700};
767 uint16_t fmEndBand[4] = {10800, 7600, 9100, 10800};
768 uint16_t fmSpace[4] = {1, 5, 10, 20};
770 uint16_t amStartBand[4] = {153, 520, 2300, 522};
771 uint16_t amEndBand[4] = {279, 1710, 21850, 1710};
772 uint16_t amSpace[4] = {1, 5, 9, 10};
774 int pin_sdio, pin_sclk;
805 void i2cInit(
int pin_sdio,
int pin_sclk);
864 if (register_number > 0x0F)
866 shadowRegisters[register_number] = value;
872 void setup(
int sda_pin,
int sclk_pin,
int rdsInterruptPin = -1,
int seekInterruptPin = -1, uint8_t oscillator_type =
OSCILLATOR_TYPE_CRYSTAL);
874 void setFM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step);
875 void setAM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step, uint16_t am_space = 0);
892 reg04->refined.PILOTS = value;
893 setRegister(
REG04,reg04->raw);
905 reg04->refined.DE = de;
906 setRegister(
REG04, reg04->raw);
917 reg04->refined.TCPILOT = value;
918 setRegister(
REG04, reg04->raw);
935 reg04->refined.GPIO2 = value;
936 setRegister(
REG04,reg04->raw);
954 reg04->refined.GPIO3 = value;
955 setRegister(
REG04, reg04->raw);
965 reg08->refined.AFCEN;
966 setRegister(
REG08, reg08->raw);
976 reg08->refined.TCSEL;
977 setRegister(
REG08, reg08->raw);
987 reg08->refined.SEL25K;
988 setRegister(
REG08, reg08->raw);
999 setRegister(
REG08, reg08->raw);
1010 setRegister(
REG08, reg08->raw);
1020 reg08->refined.RANGE;
1021 setRegister(
REG08, reg08->raw);
1031 reg08->refined.AFCRSSIT;
1032 setRegister(
REG08, reg08->raw);
1045 void seekHardware(uint8_t seek_mode, uint8_t direction);
1046 void seekSoftware(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL);
1049 void setBand(uint8_t band = 1);
char * getRdsText(void)
Gets the RDS Text when the message is of the Group Type 2 version A.
char rds_buffer0A[9]
RDS Basic tuning and switching information (Type 0 groups)
void setFM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step)
Sets the receiver to FM mode.
void i2cInit(int pin_sdio, int pin_sclk)
Sets the MCU pins connected to the I2C bus.
uint16_t readRegister(uint8_t reg)
Gets an array of values from a BK108X given register.
void setBand(uint8_t band=1)
Sets the current band for AM or FM
uint16_t bk_reg1E
The user does not have access to registsres 0x1E, 0x1F and 0x20.
bool isStereo()
Checks stereo / mono status.
uint16_t getChannel()
Gets the current channel.
void setAfcThreshold(uint8_t value)
Sets AFCRL Threshold.
char * getRdsTime()
Gets the RDS time and date when the Group type is 4.
char * getRdsText2A(void)
Gets the Text processed for the 2A group.
uint8_t i2cReceiveAck()
Gets Acknowledge (ACK)
void setI2CAddress(int bus_addr)
Sets the I2C bus address.
void i2cAck()
Sends Acknowledge (ACK)
void setAudioMute(bool value)
Sets the Mute true or false.
uint16_t getDeviceId()
Returns the Device Indentifiction.
int getSnr()
Gets the current SNR.
void i2cBeginTransaction()
Starts the I2C bus transaction
void powerDown()
Powers the receiver off.
void getNext4Block(char *c)
Process data received from group 2A.
void setAfc(bool value)
Enables or Disables AFC.
void setGpio2(uint8_t value)
Sets the Gpio2.
void seekHardware(uint8_t seek_mode, uint8_t direction)
Seeks a station via hardware functionality.
uint16_t getRealFrequency()
Gets the frequency based on READCHAN register (0x0B)
void setFrequency(uint16_t frequency)
Sets the FM frequency.
void setDelayAfterCrystalOn(uint8_t ms_value)
Set the Delay After Crystal On (default 500ms)
void setShadownRegister(uint8_t register_number, uint16_t value)
Sets a given value to the Shadown Register.
int getRssi()
Gets the current Rssi.
uint32_t currentFrequency
char rds_buffer2A[65]
RDS Radio Text buffer - Program Information.
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
void setSeekThreshold(uint8_t rssiValue, uint8_t snrValue)
Sets RSSI and SNR Seek Threshold.
char * getRdsText0A(void)
Gets the station name and other messages.
uint8_t i2cReadByte()
Gets a Byte from the slave device.
void setSpace(uint8_t space=0)
Sets the Space channel for AM or FM.
uint16_t getRealChannel()
Gets the current channel stored in register 0x0B.
bool getRdsSync()
Get the Rds Sync.
void setSoftmuteAttenuation(uint8_t value)
Sets Softmute Attenuation.
uint16_t getChipId()
Returns the Chip Indentifiction.
uint16_t getRegister(uint8_t reg)
Gets a givens current register content of the device.
void setGpio3(uint8_t value)
Sets the Gpio3.
void setChannel(uint16_t channel)
Sets the channel.
void setMuteThreshold(uint8_t rssi, uint8_t snr)
Set the Mute Threshold based on RSSI and SNR.
void setAfcMute(bool value)
Disable or Enable soft mute when AFCRL is high.
void setAfcAve(uint8_t value)
Sets AFC Average.
uint32_t minimumFrequency
#define OSCILLATOR_TYPE_CRYSTAL
void writeRegister(uint8_t reg, uint16_t vakue)
Sends an array of values to a BK108X given register.
void setAudioMute(bool left, bool right)
Sets the Mute true or false.
void setVolumeDown()
Decrements the audio volume.
void seekSoftware(uint8_t seek_mode, uint8_t direction, void(*showFunc)()=NULL)
Seeks a station via Software.
void waitAndFinishTune()
Wait STC (Seek/Tune Complete) status becomes 0.
void setAfcRange(uint8_t value)
Sets AFC range.
void getNext2Block(char *c)
Process data received from group 2B.
void setSoftmute(bool value)
Sets the Softmute true or false.
void setTimeCallStrengthPilot(uint8_t value)
Sets the time used to call the strength of pilot.
uint16_t raw
//!< Reference clock divider control , FREQ_SEL[17:0] = HEX | Ref Frequency/512+0....
void getRdsStatus()
Gets the RDS registers information.
uint16_t getFrequency()
Gets the current frequency.
void setFrequencyUp()
Increments the current frequency.
void setSoftmuteAttack(uint8_t value)
Sets Softmute Attack/Recover Rate.
void reset()
Resets the device.
uint8_t getRdsProgramType(void)
Returns the Program Type (extracted from the Block B)
void setAfcRssiSnrCalculateRate(uint8_t value)
Sets AFC/RSSI/SNR Calculate Rate.
void setVolume(uint8_t value)
Sets the audio volume level.
char rds_time[20]
RDS date time received information.
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B
uint8_t getCurrentMode()
Get the Current Mode (AM or FM)
void setFmDeemphasis(uint8_t de)
Sets De-emphasis.
uint32_t maximumFrequency
void powerUp()
Powers the receiver on.
uint16_t getShadownRegister(uint8_t register_number)
Get the Shadown Register object.
#define MAX_DELAY_AFTER_OSCILLATOR
uint8_t getVolume()
Gets the current audio volume level.
void setup(int sda_pin, int sclk_pin, int rdsInterruptPin=-1, int seekInterruptPin=-1, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL)
Starts the device.
void setStereoThresholdPilotStrength(uint8_t value)
Sets the Stereo Threshold of Pilotto Strength.
uint16_t maxDelayAftarCrystalOn
void setFrequencyDown()
Decrements the current frequency.
void setSeekMute(bool value)
Disable or Enable soft mute when seeking.
void i2cNack()
Sends Not Acknowledge (ACK)
void setRdsMode(uint8_t rds_mode=0)
Sets the Rds Mode Standard or Verbose.
bk_reg0a getStatus()
Gets the current status (register 0x0A) content.
uint16_t getRdsGroupType()
Return the group type.
char * getRdsText2B(void)
Gets the Text processed for the 2B group.
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 setMono(bool value)
Sets the Mono true or false (stereo)
void i2cEndTransaction()
Finish the I2C bus transaction.
void setI2C(uint8_t i2c_addr=I2C_DEVICE_ADDR)
Sets I2C bus address.
void setRds(bool value)
Sets the RDS operation.
void setVolumeUp()
Increments the audio volume.
void setAfcRssiThreshold(uint8_t value)
Sets RSSI Threshold for Instant AFC updating.
void setAgc(bool value)
Sets the AGC enable or disable.
void setRegister(uint8_t reg, uint16_t value)
Sets a given value to the device registers.
void setAfcVar(uint8_t value)
Sets Variation Threshold for average AFC calculation.
void i2cWriteByte(uint8_t data)
Sends a Byte to the slave device.
char rds_buffer2B[33]
RDS Radio Text buffer - Station Informaation.
bool getRdsReady()
Returns true if RDS Ready.