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 5000
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
374 uint16_t FM_READY : 1;
375 uint16_t FM_TRUE : 1;
387
388
389
390
402
403
404
405
417
418
419
420
432
433
434
446
447
448
460
461
462
474
475
476
488
489
490
495 uint16_t RSSIMTH : 7;
497 uint16_t AFCMUTE : 1;
504
505
506
518
519
520
532
533
534
546
547
548
560
561
562
574
575
576
581 uint16_t RESERVED1 : 3;
582 uint16_t ANT_SEL : 5;
583 uint16_t RESERVED2 : 4;
589
590
591
601
602
603
608 uint16_t RESERVED : 14;
609 uint16_t FREQ_SEL : 2;
615
616
617
627
628
629
630
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
656 uint16_t address : 2;
660 uint16_t programType : 5;
661 uint16_t trafficProgramCode : 1;
662 uint16_t versionCode : 1;
663 uint16_t groupType : 4;
667 uint16_t address : 4;
668 uint16_t textABFlag : 1;
669 uint16_t programType : 5;
670 uint16_t trafficProgramCode : 1;
671 uint16_t versionCode : 1;
672 uint16_t groupType : 4;
676 uint16_t content : 4;
677 uint16_t textABFlag : 1;
678 uint16_t programType : 5;
679 uint16_t trafficProgramCode : 1;
680 uint16_t versionCode : 1;
681 uint16_t groupType : 4;
687
688
689
690
691
692
693
694
695
701 uint32_t offset_sense : 1;
710
711
712
726
727
728
729
730
731
783 char strFrequency[9];
785 int pin_sdio, pin_sclk;
820 void i2cInit(
int pin_sdio,
int pin_sclk);
839
840
841
842
843
847
848
849
850
851
859
860
861
862
863
864
865
866
870
871
872
873
874
875
876
879 if (register_number > 0x0F)
881 shadowRegisters[register_number] = value;
890 void setFM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step);
891 void setAM(uint16_t minimum_frequency, uint16_t maximum_frequency, uint16_t default_frequency, uint16_t step, uint16_t am_space = 0);
894
895
896
897
898
899
901 reg07->refined.FMGAIN = value;
902 setRegister(
REG07,reg07->raw);
906
907
908
909
910
914
915
916
917
918
920 reg04->refined.PILOTS = value;
921 setRegister(
REG04,reg04->raw);
925
926
927
928
929
930
933 reg04->refined.DE = de;
934 setRegister(
REG04, reg04->raw);
938
939
940
941
942
945 reg04->refined.TCPILOT = value;
946 setRegister(
REG04, reg04->raw);
950
951
952
953
954
955
956
957
958
959
960
961
963 reg04->refined.GPIO2 = value;
964 setRegister(
REG04,reg04->raw);
968
969
970
971
972
973
974
975
976
977
978
979
982 reg04->refined.GPIO3 = value;
983 setRegister(
REG04, reg04->raw);
987
988
989
990
993 reg08->refined.AFCEN = value;
994 setRegister(
REG08, reg08->raw);
998
999
1000
1001
1004 reg08->refined.TCSEL = value;
1005 setRegister(
REG08, reg08->raw);
1009
1010
1011
1012
1015 reg08->refined.SEL25K = value;
1016 setRegister(
REG08, reg08->raw);
1020
1021
1022
1023
1026 reg08->refined.AVE = value;
1027 setRegister(
REG08, reg08->raw);
1031
1032
1033
1034
1037 reg08->refined.VAR = value;
1038 setRegister(
REG08, reg08->raw);
1042
1043
1044
1045
1048 reg08->refined.RANGE = value;
1049 setRegister(
REG08, reg08->raw);
1053
1054
1055
1056
1059 reg08->refined.AFCRSSIT = value;
1060 setRegister(
REG08, reg08->raw);
1073 void seekHardware(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL);
1074 void seekSoftware(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL);
1076 inline void seek(uint8_t seek_mode, uint8_t direction,
void (*showFunc)() =
NULL)
1078 this->seekHardware(seek_mode, direction, showFunc );
1082 void setBand(uint8_t band = 1);
1107 void setRds(
bool value,
bool interrupt_enable =
false);
1108 inline void setRDS(
bool value,
bool interrupt_enable =
false ) {
setRds(value
, interrupt_enable
); };
1121 bool getRdsAllData(
char **stationName,
char **stationInformation,
char **programInformation,
char **utcTime);
1127
1128
1129
1130
1131
1132
1133
1137
1138
1139
1140
1141
1142
1146
1147
1148
1149
1150
1151
1152
1158 int checkI2C(uint8_t *addressArray);
1159 void convertToChar(uint16_t value,
char *strValue, uint8_t len, uint8_t dot, uint8_t separator,
bool remove_leading_zeros =
true);
1163
1164
1165
1166
1167
1168
1169
1170
1171 inline char *
formatFrequency(uint16_t value,
char *strValue,
char decimalSeparator =
',', uint8_t decimalPosition = 3)
1173 this->convertToChar(value, strValue, 5, decimalPosition, decimalSeparator,
true);
1177
1178
1179
1180
1181
1182
1183
1186 this->convertToChar(
this->currentFrequency,
this->strFrequency, 5, decimalPosition, decimalSeparator,
true);
1187 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.
uint16_t maxDelayAfterCrystalOn
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.
uint32_t currentFrequency
uint32_t minimumFrequency
uint32_t oscillatorFrequency
void setRDS(bool value, bool interrupt_enable=false)
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 seekHardware(uint8_t seek_mode, uint8_t direction, void(*showFunc)()=NULL)
Seeks a station via hardware functionality.
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.
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 setup(int sda_pin, int sclk_pin, uint8_t oscillator_type=OSCILLATOR_TYPE_CRYSTAL, uint32_t oscillator_frequency=32768)
Starts the device.
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 setFMGain(uint8_t value=0)
set the FM gain.
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.
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)
Processes 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.
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.
uint16_t getRdsGroupType()
Return the group type - Gets the Group Type (extracted from the Block B)
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 getRdsStatus()
Gets the RDS registers information.
void setRds(bool value, bool interrupt_enable=false)
Sets the RDS operation.
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.
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.
int checkI2C(uint8_t *addressArray)
Check the I2C bus address.