 |
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
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
291 uint8_t RESERVED : 2;
307 uint8_t AFCRSSIT : 7;
359 uint16_t READCHAN : 14;
360 uint16_t RESERVED : 2;
575 uint16_t ANT_SEL : 9;
576 uint16_t RESERVED : 7;
589 uint16_t RESERVED : 15;
590 uint16_t FREQ_SEL : 1;
603 uint16_t RESERVED : 15;
604 uint16_t FREQ_SEL : 1;
650 uint8_t programType : 5;
651 uint8_t trafficProgramCode : 1;
652 uint8_t versionCode : 1;
653 uint8_t groupType : 4;
658 uint8_t textABFlag : 1;
659 uint8_t programType : 5;
660 uint8_t trafficProgramCode : 1;
661 uint8_t versionCode : 1;
662 uint8_t groupType : 4;
667 uint8_t textABFlag : 1;
668 uint8_t programType : 5;
669 uint8_t trafficProgramCode : 1;
670 uint8_t versionCode : 1;
671 uint8_t groupType : 4;
691 uint8_t offset_sense : 1;
729 uint8_t i2cBuffer[32];
731 uint16_t shadowRegisters[32];
734 bk_reg00 *reg00 = (bk_reg00 *)&shadowRegisters[
REG00];
735 bk_reg01 *reg01 = (bk_reg01 *)&shadowRegisters[
REG01];
736 bk_reg02 *reg02 = (bk_reg02 *)&shadowRegisters[
REG02];
737 bk_reg03 *reg03 = (bk_reg03 *)&shadowRegisters[
REG03];
738 bk_reg04 *reg04 = (bk_reg04 *)&shadowRegisters[
REG04];
739 bk_reg05 *reg05 = (bk_reg05 *)&shadowRegisters[
REG05];
740 bk_reg06 *reg06 = (bk_reg06 *)&shadowRegisters[
REG06];
741 bk_reg07 *reg07 = (bk_reg07 *)&shadowRegisters[
REG07];
742 bk_reg08 *reg08 = (bk_reg08 *)&shadowRegisters[
REG08];
743 bk_reg09 *reg09 = (bk_reg09 *)&shadowRegisters[
REG09];
744 bk_reg0a *reg0a = (bk_reg0a *)&shadowRegisters[
REG0A];
745 bk_reg0b *reg0b = (bk_reg0b *)&shadowRegisters[
REG0B];
746 bk_reg0c *reg0c = (bk_reg0c *)&shadowRegisters[
REG0C];
747 bk_reg0d *reg0d = (bk_reg0d *)&shadowRegisters[
REG0D];
748 bk_reg0e *reg0e = (bk_reg0e *)&shadowRegisters[
REG0E];
749 bk_reg0f *reg0f = (bk_reg0f *)&shadowRegisters[
REG0F];
750 bk_reg10 *reg10 = (bk_reg10 *)&shadowRegisters[
REG10];
751 bk_reg11 *reg11 = (bk_reg11 *)&shadowRegisters[
REG11];
752 bk_reg12 *reg12 = (bk_reg12 *)&shadowRegisters[
REG12];
753 bk_reg13 *reg13 = (bk_reg13 *)&shadowRegisters[
REG13];
754 bk_reg14 *reg14 = (bk_reg14 *)&shadowRegisters[
REG14];
755 bk_reg15 *reg15 = (bk_reg15 *)&shadowRegisters[
REG15];
756 bk_reg16 *reg16 = (bk_reg16 *)&shadowRegisters[
REG16];
757 bk_reg17 *reg17 = (bk_reg17 *)&shadowRegisters[
REG17];
758 bk_reg18 *reg18 = (bk_reg18 *)&shadowRegisters[
REG18];
759 bk_reg19 *reg19 = (bk_reg19 *)&shadowRegisters[
REG19];
760 bk_reg1A *reg1A = (bk_reg1A *)&shadowRegisters[
REG1A];
761 bk_reg1B *reg1b = (bk_reg1B *)&shadowRegisters[
REG1B];
762 bk_reg1C *reg1c = (bk_reg1C *)&shadowRegisters[
REG1C];
763 bk_reg1D *reg1d = (bk_reg1D *)&shadowRegisters[
REG1D];
767 uint16_t fmStartBand[4] = {6400, 7400, 7600, 8700};
768 uint16_t fmEndBand[4] = {10800, 7600, 9100, 10800};
769 uint16_t fmSpace[4] = {1, 5, 10, 20};
771 uint16_t amStartBand[4] = {153, 520, 2300, 522};
772 uint16_t amEndBand[4] = {279, 1710, 21850, 1710};
773 uint16_t amSpace[4] = {1, 5, 9, 10};
775 int pin_sdio, pin_sclk;
806 void i2cInit(
int pin_sdio,
int pin_sclk);
865 if (register_number > 0x0F)
867 shadowRegisters[register_number] = value;
873 void setup(
int sda_pin,
int sclk_pin,
int rdsInterruptPin = -1,
int seekInterruptPin = -1, uint8_t oscillator_type =
OSCILLATOR_TYPE_CRYSTAL);
875 void setFM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step);
876 void setAM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step, uint16_t am_space = 0);
894 void seek(uint8_t seek_mode, uint8_t direction);
895 void seek(uint8_t seek_mode, uint8_t direction,
void (*showFunc)());
898 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 FM Band
bool isStereo()
Checks stereo / mono status.
uint16_t getChannel()
Gets the current channel.
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 seek(uint8_t seek_mode, uint8_t direction)
Seek function.
void i2cAck()
Sends Acknowledge (ACK)
void setExtendedVolumeRange(bool value)
Sets Extended Volume Range.
uint16_t getDeviceId()
Returns the Device Indentifiction.
void i2cBeginTransaction()
Starts the I2C bus transaction
void powerDown()
Powers the receiver off.
void getNext4Block(char *c)
Process data received from group 2A.
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 Rssi.
uint32_t currentFrequency
char rds_buffer2A[65]
RDS Radio Text buffer - Program Information.
void seek(uint8_t seek_mode, uint8_t direction, void(*showFunc)())
Seek function.
void setMute(bool value)
Sets the Mute true or false.
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
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 FM Space
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 setChannel(uint16_t channel)
Sets the channel.
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 setVolumeDown()
Decrements the audio volume.
void waitAndFinishTune()
Wait STC (Seek/Tune Complete) status becomes 0.
void getNext2Block(char *c)
Process data received from group 2B.
void setSoftmute(bool value)
Sets the Softmute true or false.
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 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.
uint16_t maxDelayAftarCrystalOn
void setFrequencyDown()
Decrements the current frequency.
void i2cNack()
Sends Not Acknowledge (ACK)
void setRdsMode(uint8_t rds_mode=0)
Sets the Rds Mode Standard or Verbose.
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 setSeekThreshold(uint8_t value)
Sets RSSI Seek Threshold.
void setRds(bool value)
Sets the RDS operation.
void setVolumeUp()
Increments the audio volume.
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 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.