3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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
88
89
90
91
92
93
94
95
96
99
100
101
102
114
115
116
117
129
130
131
132
154
155
156
157
158
170
171
172
173
174
175
184 uint16_t TCPILOT : 2;
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
269
270
271
277 uint16_t RESERVED :3;
278 uint16_t STHYS_SEL : 1;
279 uint16_t DACCK_SEL : 1;
285 uint16_t LINEIN_EN : 1;
286 uint16_t LINEIN_SEL : 1;
292
293
294
295
296
297
302 uint16_t AFCRSSIT : 7;
314
315
316
328
329
330
348
349
350
355 uint16_t READCHAN : 14;
356 uint16_t RESERVED : 2;
362
363
364
365
377
378
379
380
392
393
394
395
407
408
409
410
422
423
424
436
437
438
450
451
452
464
465
466
478
479
480
485 uint16_t RSSIMTH : 7;
487 uint16_t AFCMUTE : 1;
494
495
496
508
509
510
522
523
524
536
537
538
550
551
552
564
565
566
571 uint16_t RESERVED1 : 3;
572 uint16_t ANT_SEL : 5;
573 uint16_t RESERVED2 : 4;
579
580
581
591
592
593
598 uint16_t RESERVED : 15;
599 uint16_t FREQ_SEL : 1;
605
606
607
617
618
619
620
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
646 uint16_t address : 2;
650 uint16_t programType : 5;
651 uint16_t trafficProgramCode : 1;
652 uint16_t versionCode : 1;
653 uint16_t groupType : 4;
657 uint16_t address : 4;
658 uint16_t textABFlag : 1;
659 uint16_t programType : 5;
660 uint16_t trafficProgramCode : 1;
661 uint16_t versionCode : 1;
662 uint16_t groupType : 4;
666 uint16_t content : 4;
667 uint16_t textABFlag : 1;
668 uint16_t programType : 5;
669 uint16_t trafficProgramCode : 1;
670 uint16_t versionCode : 1;
671 uint16_t groupType : 4;
677
678
679
680
681
682
683
684
685
691 uint32_t offset_sense : 1;
700
701
702
716
717
718
719
720
721
773 char strFrequency[9];
775 int pin_sdio, pin_sclk;
808 void i2cInit(
int pin_sdio,
int pin_sclk);
827
828
829
830
831
835
836
837
838
839
847
848
849
850
851
852
853
854
858
859
860
861
862
863
864
867 if (register_number > 0x0F)
869 shadowRegisters[register_number] = value;
875 void setup(
int sda_pin,
int sclk_pin,
int rdsInterruptPin = -1,
int seekInterruptPin = -1, uint8_t oscillator_type =
OSCILLATOR_TYPE_CRYSTAL);
877 void setFM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step);
878 void setAM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step, uint16_t am_space = 0);
881
882
883
884
885
889
890
891
892
893
895 reg04->refined.PILOTS = value;
896 setRegister(
REG04,reg04->raw);
900
901
902
903
904
905
908 reg04->refined.DE = de;
909 setRegister(
REG04, reg04->raw);
913
914
915
916
917
920 reg04->refined.TCPILOT = value;
921 setRegister(
REG04, reg04->raw);
925
926
927
928
929
930
931
932
933
934
935
936
938 reg04->refined.GPIO2 = value;
939 setRegister(
REG04,reg04->raw);
943
944
945
946
947
948
949
950
951
952
953
954
957 reg04->refined.GPIO3 = value;
958 setRegister(
REG04, reg04->raw);
962
963
964
965
968 reg08->refined.AFCEN = value;
969 setRegister(
REG08, reg08->raw);
973
974
975
976
979 reg08->refined.TCSEL = value;
980 setRegister(
REG08, reg08->raw);
984
985
986
987
990 reg08->refined.SEL25K = value;
991 setRegister(
REG08, reg08->raw);
995
996
997
998
1001 reg08->refined.AVE = value;
1002 setRegister(
REG08, reg08->raw);
1006
1007
1008
1009
1012 reg08->refined.VAR = value;
1013 setRegister(
REG08, reg08->raw);
1017
1018
1019
1020
1023 reg08->refined.RANGE = value;
1024 setRegister(
REG08, reg08->raw);
1028
1029
1030
1031
1034 reg08->refined.AFCRSSIT = value;
1035 setRegister(
REG08, reg08->raw);
1048 void seekHardware(uint8_t seek_mode, uint8_t direction);
1049 void seekSoftware(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL);
1051 inline void seek(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL)
1053 this->seekSoftware(seek_mode, direction, showFunc );
1057 void setBand(uint8_t band = 1);
1101
1102
1103
1104
1105
1106
1107
1111
1112
1113
1114
1115
1116
1120
1121
1122
1123
1124
1125
1126
1132 int checkI2C(uint8_t *addressArray);
1133 void convertToChar(uint16_t value,
char *strValue, uint8_t len, uint8_t dot, uint8_t separator,
bool remove_leading_zeros =
true);
1136
1137
1138
1139
1140
1141
1142
1143
1144 inline char *
formatFrequency(uint16_t value,
char *strValue,
char decimalSeparator =
',', uint8_t decimalPosition = 3)
1146 this->convertToChar(value, strValue, 5, decimalPosition, decimalSeparator,
true);
1150
1151
1152
1153
1154
1155
1156
1159 this->convertToChar(
this->currentFrequency,
this->strFrequency, 5, decimalPosition, decimalSeparator,
true);
1160 return this->strFrequency;
uint16_t bk_reg1E
The user does not have access to registsres 0x1E, 0x1F and 0x20.
#define OSCILLATOR_TYPE_CRYSTAL
#define MAX_DELAY_AFTER_OSCILLATOR
void setAfcAve(uint8_t value)
Sets AFC Average.
uint16_t getChipId()
Returns the Chip Indentifiction.
uint32_t maximumFrequency
uint16_t raw
//!< Reference clock divider control , FREQ_SEL[17:0] = HEX | Ref Frequency/512+0....
char rds_buffer2A[65]
RDS Radio Text buffer - Program Information.
void setAfcRange(uint8_t value)
Sets AFC range.
char rds_buffer2B[33]
RDS Radio Text buffer - Station Informaation.
void setAfcRssiThreshold(uint8_t value)
Sets RSSI Threshold for Instant AFC updating.
void setAfc(bool value)
Enables or Disables AFC.
uint16_t getDeviceId()
Returns the Device Indentifiction.
void setGpio2(uint8_t value)
Sets the Gpio2.
void setGpio3(uint8_t value)
Sets the Gpio3.
void setAfcVar(uint8_t value)
Sets Variation Threshold for average AFC calculation.
void setAfcThreshold(uint8_t value)
Sets AFCRL Threshold.
char rds_buffer0A[9]
RDS Basic tuning and switching information (Type 0 groups)
void setAfcRssiSnrCalculateRate(uint8_t value)
Sets AFC/RSSI/SNR Calculate Rate.
char rds_time[20]
RDS date time received information.
uint16_t maxDelayAfterCrystalOn
uint32_t currentFrequency
uint32_t minimumFrequency
void seek(uint8_t seek_mode, uint8_t direction, void(*showFunc)()=NULL)
uint8_t i2cReceiveAck()
Gets Acknowledge (ACK)
uint8_t i2cReadByte()
Gets a Byte from the slave device.
uint16_t readRegister(uint8_t reg)
Gets an array of values from a BK108X given register.
void i2cBeginTransaction()
Starts the I2C bus transaction
void i2cEndTransaction()
Finish the I2C bus transaction.
void i2cWriteByte(uint8_t data)
Sends a Byte to the slave device.
void writeRegister(uint8_t reg, uint16_t vakue)
Sends an array of values to a BK108X given register.
void i2cNack()
Sends Not Acknowledge (ACK)
void setI2C(uint8_t i2c_addr=I2C_DEVICE_ADDR)
Sets I2C bus address.
void i2cAck()
Sends Acknowledge (ACK)
void i2cInit(int pin_sdio, int pin_sclk)
Sets the MCU pins connected to the I2C bus.
void reset()
Resets the device.
uint16_t getChannel()
Gets the current channel.
void setShadownRegister(uint8_t register_number, uint16_t value)
Sets a given value to the Shadown Register.
void setSpace(uint8_t space=0)
Sets the Space channel for AM or FM.
void seekSoftware(uint8_t seek_mode, uint8_t direction, void(*showFunc)()=NULL)
Seeks a station via Software.
uint16_t getRealChannel()
Gets the current channel stored in register 0x0B.
void waitAndFinishTune()
Wait STC (Seek/Tune Complete) status becomes 0.
void setSoftMuteAttack(uint8_t value)
Sets Softmute Attack/Recover Rate.
void setSeekThreshold(uint8_t rssiValue, uint8_t snrValue)
Sets RSSI and SNR Seek Threshold.
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.
int getSnr()
Gets the current SNR.
void setDelayAfterCrystalOn(uint8_t ms_value)
Set the Delay After Crystal On (default 500ms)
void setAudioMute(bool left, bool right)
Sets the Mute true or false.
void setI2CAddress(int bus_addr)
Sets the I2C bus address.
void setFrequency(uint16_t frequency)
Sets the FM frequency.
void setBand(uint8_t band=1)
Sets the current band for AM or FM
void setFrequencyDown()
Decrements the current frequency.
void setAudioMute(bool value)
Sets the Mute true or false.
void setSoftMute(bool value)
Sets the Softmute true or false.
void setAfcMute(bool value)
Disable or Enable soft mute when AFCRL is high.
bk_reg0a getStatus()
Gets the current status (register 0x0A) content.
uint8_t getCurrentMode()
Get the Current Mode (AM or FM)
void setStereoThresholdPilotStrength(uint8_t value)
Sets the Stereo Threshold of Pilotto Strength.
bool isStereo()
Checks stereo / mono status.
void setVolumeUp()
Increments the audio volume.
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 getFrequency()
Gets the current frequency.
void setSoftMuteAttenuation(uint8_t value)
Sets Softmute Attenuation.
void powerDown()
Powers the receiver off.
void setChannel(uint16_t channel)
Sets the channel.
void setFM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step)
Sets the receiver to FM mode.
void setVolume(uint8_t value)
Sets the audio volume level.
uint8_t getVolume()
Gets the current audio volume level.
uint16_t getShadownRegister(uint8_t register_number)
Get the Shadown Register object.
void setMono(bool value)
Sets the Mono true or false (stereo)
void setFmDeemphasis(uint8_t de)
Sets De-emphasis.
void setFrequencyUp()
Increments the current frequency.
uint16_t getRealFrequency()
Gets the frequency based on READCHAN register (0x0B)
void setVolumeDown()
Decrements the audio volume.
void powerUp()
Powers the receiver on.
void setTimeCallStrengthPilot(uint8_t value)
Sets the time used to call the strength of pilot.
int getRssi()
Gets the current Rssi.
void setRegister(uint8_t reg, uint16_t value)
Sets a given value to the device registers.
void setMuteThreshold(uint8_t rssi, uint8_t snr)
Set the Mute Threshold based on RSSI and SNR.
void seekHardware(uint8_t seek_mode, uint8_t direction)
Seeks a station via hardware functionality.
void setSeekMute(bool value)
Disable or Enable soft mute when seeking.
uint16_t getRegister(uint8_t reg)
Gets a givens current register content of the device.
char * getRdsText0A(void)
Gets the station name and other messages.
bool getRdsReady()
Returns true if RDS Ready.
char * getRdsStationInformation(void)
Gets the Station Information.
char * getRdsText(void)
Gets the RDS Text when the message is of the Group Type 2 version A.
char * getRdsText2B(void)
Gets the Text processed for the 2B group.
void getNext4Block(char *c)
Process data received from group 2A.
uint8_t getRdsVersionCode(void)
Gets the version code (extracted from the Block B)
char * getRdsStationName(void)
Gets the Station Name.
char * getRdsTime()
Gets the RDS time and date when the Group type is 4.
uint16_t getRdsGroupType()
Return the group type.
uint8_t getRdsFlagAB(void)
Returns the current Text Flag A/B
uint8_t getRdsProgramType(void)
Returns the Program Type (extracted from the Block B)
void getNext2Block(char *c)
Process data received from group 2B.
char * getRdsText2A(void)
Gets the Text processed for the 2A group.
char * getRdsProgramInformation(void)
Gets the Program Information (RT - Radio Text)
void clearRdsBuffer()
Clear RDS Information (Station Name, Station Information, Program Information and Time)
bool getRdsSync()
Get the Rds Sync.
void setRdsMode(uint8_t rds_mode=0)
Sets the Rds Mode Standard or Verbose.
void setRds(bool value)
Sets the RDS operation.
void getRdsStatus()
Gets the RDS registers information.
char * getRdsLocalTime()
Gets the RDS time converted to local time.
char * formatCurrentFrequency(char decimalSeparator=',', uint8_t decimalPosition=3)
Convert the current frequency to a formated string (char *) frequency.
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.
char * formatFrequency(uint16_t value, char *strValue, char decimalSeparator=',', uint8_t decimalPosition=3)
Convert a numeric frequency to a formated string (char *) frequency.
int checkI2C(uint8_t *addressArray)
Check the I2C bus address.