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
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
278 uint8_t STHYS_SEL : 1;
279 uint8_t DACCK_SEL : 1;
285 uint8_t LINEIN_EN : 1;
286 uint8_t LINEIN_SEL : 1;
292
293
294
295
296
297
302 uint8_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
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
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;
677
678
679
680
681
682
683
684
685
691 uint8_t offset_sense : 1;
702
703
704
718
719
720
721
722
723
775 char strFrequency[9];
777 int pin_sdio, pin_sclk;
810 void i2cInit(
int pin_sdio,
int pin_sclk);
829
830
831
832
833
837
838
839
840
841
849
850
851
852
853
854
855
856
860
861
862
863
864
865
866
869 if (register_number > 0x0F)
871 shadowRegisters[register_number] = value;
877 void setup(
int sda_pin,
int sclk_pin,
int rdsInterruptPin = -1,
int seekInterruptPin = -1, uint8_t oscillator_type =
OSCILLATOR_TYPE_CRYSTAL);
879 void setFM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step);
880 void setAM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step, uint16_t am_space = 0);
883
884
885
886
887
891
892
893
894
895
897 reg04->refined.PILOTS = value;
898 setRegister(
REG04,reg04->raw);
902
903
904
905
906
907
910 reg04->refined.DE = de;
911 setRegister(
REG04, reg04->raw);
915
916
917
918
919
922 reg04->refined.TCPILOT = value;
923 setRegister(
REG04, reg04->raw);
927
928
929
930
931
932
933
934
935
936
937
938
940 reg04->refined.GPIO2 = value;
941 setRegister(
REG04,reg04->raw);
945
946
947
948
949
950
951
952
953
954
955
956
959 reg04->refined.GPIO3 = value;
960 setRegister(
REG04, reg04->raw);
964
965
966
967
970 reg08->refined.AFCEN = value;
971 setRegister(
REG08, reg08->raw);
975
976
977
978
981 reg08->refined.TCSEL = value;
982 setRegister(
REG08, reg08->raw);
986
987
988
989
992 reg08->refined.SEL25K = value;
993 setRegister(
REG08, reg08->raw);
997
998
999
1000
1003 reg08->refined.AVE = value;
1004 setRegister(
REG08, reg08->raw);
1008
1009
1010
1011
1014 reg08->refined.VAR = value;
1015 setRegister(
REG08, reg08->raw);
1019
1020
1021
1022
1025 reg08->refined.RANGE = value;
1026 setRegister(
REG08, reg08->raw);
1030
1031
1032
1033
1036 reg08->refined.AFCRSSIT = value;
1037 setRegister(
REG08, reg08->raw);
1050 void seekHardware(uint8_t seek_mode, uint8_t direction);
1051 void seekSoftware(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL);
1053 inline void seek(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL)
1055 this->seekSoftware(seek_mode, direction, showFunc );
1059 void setBand(uint8_t band = 1);
1101 int checkI2C(uint8_t *addressArray);
1102 void convertToChar(uint16_t value,
char *strValue, uint8_t len, uint8_t dot, uint8_t separator,
bool remove_leading_zeros =
true);
1105
1106
1107
1108
1109
1110
1111
1112
1115 this->convertToChar(value, strValue, 5, 3, decimalSeparator,
true);
1119
1120
1121
1122
1123
1124
1125
1128 this->convertToChar(
this->currentFrequency,
this->strFrequency, 5, 3, decimalSeparator,
true);
1129 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 maxDelayAftarCrystalOn
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 * 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 * 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.
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.
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)
Convert a numeric frequency to a formated string (char *) frequency.
char * formatCurrentFrequency(char decimalSeparator=',')
Convert the current frequency to a formated string (char *) frequency.
int checkI2C(uint8_t *addressArray)
Check the I2C bus address.