PU2CLR AKC695X Arduino Library  1.0.1
This is an Arduino Library to control the AKC695X / M695X DSP radio devices
AKC695X.h
1 
16 #include <Arduino.h>
17 #include <Wire.h>
18 
19 #define DEFAUL_I2C_ADDRESS 0x10
20 #define CURRENT_MODE_FM 1
21 #define CURRENT_MODE_AM 0
22 
60 #define AKC595X_I2C_ADRESS 0x10
61 
62 // Read and Write (RW) AKC695X registers
63 #define REG00 0x00
64 #define REG01 0x01
65 #define REG02 0x02
66 #define REG03 0x03
67 #define REG04 0x04
68 #define REG05 0x05
69 #define REG06 0x06
70 #define REG07 0x07
71 #define REG08 0x08
72 #define REG09 0x09
73 #define REG11 0x0B
74 #define REG12 0x0C
75 #define REG13 0x0D
76 // Read only AKC695X registers
77 #define REG20 0x14
78 #define REG21 0x15
79 #define REG22 0x16
80 #define REG23 0x17
81 #define REG24 0x18
82 #define REG25 0x19
83 #define REG26 0x1A
84 #define REG27 0x1B
85 
103 typedef union {
104  struct
105  {
106  uint8_t rsv : 2;
107  uint8_t mute : 1;
108  uint8_t seekup : 1;
109  uint8_t seek : 1;
110  uint8_t tune : 1;
111  uint8_t fm_en : 1;
112  uint8_t power_on : 1;
113  } refined;
114  uint8_t raw;
115 } akc595x_reg0;
116 
124 typedef union {
125  struct
126  {
127  uint8_t fmband : 3;
128  uint8_t amband : 4;
129  } refined;
130  uint8_t raw;
131 } akc595x_reg1;
132 
144 typedef union {
145  struct
146  {
147  uint8_t channel : 5;
148  uint8_t mode3k : 1;
149  uint8_t ref_37k_mode : 1;
150  uint8_t rsv : 1;
151  } refined;
152  uint8_t raw;
153 } akc595x_reg2;
154 
159 typedef uint8_t akc595x_reg3;
160 
165 typedef uint8_t akc595x_reg4;
166 
172 typedef uint8_t akc595x_reg5;
173 
178 typedef union {
179  struct
180  {
181  uint8_t phase_inv : 1;
182  uint8_t line : 1;
183  uint8_t volume : 6;
184  } refined;
185  uint8_t raw;
186 } akc595x_reg6;
187 
193 typedef union {
194  struct
195  {
196  uint8_t bw : 2;
197  uint8_t stereo_mono : 2;
198  uint8_t bben : 1;
199  uint8_t de : 1;
200  uint8_t rsv : 2;
201  } refined;
202  uint8_t raw;
203 } akc595x_reg7;
204 
212 typedef union {
213  struct
214  {
215  uint8_t stereo_th : 2;
216  uint8_t fd_th : 2;
217  uint8_t am_cnr_th : 2;
218  uint8_t fm_cnr_th : 2;
219  } refined;
220  uint8_t raw;
221 } akc595x_reg8;
222 
230 typedef union {
231  struct
232  {
233  uint8_t iv_en : 1;
234  uint8_t rsv1 : 1;
235  uint8_t osc_en : 1;
236  uint8_t pd_adc_vol : 1;
237  uint8_t rsv2 : 4;
238  } refined;
239  uint8_t raw;
240 } akc595x_reg9;
241 
256 typedef union {
257  struct
258  {
259  uint8_t rsv1 : 2;
260  uint8_t space : 2;
261  uint8_t rsv2 : 4;
262  } refined;
263  uint8_t raw;
264 } akc595x_reg11;
265 
273 typedef union {
274  struct
275  {
276  uint8_t rsv2 : 5;
277  uint8_t pd_rx : 1;
278  uint8_t res : 1;
279  uint8_t pd_adc : 1;
280  } refined;
281  uint8_t raw;
282 } akc595x_reg12;
283 
291 typedef union {
292  struct
293  {
294  uint8_t rsv3 : 2;
295  uint8_t vol_pre : 2;
296  uint8_t rsv2 : 2;
297  uint8_t st_led : 1;
298  uint8_t rsv1 : 1;
299  } refined;
300  uint8_t raw;
301 } akc595x_reg13;
302 
310 typedef union {
311  struct
312  {
313  uint8_t readchan : 5;
314  uint8_t tuned : 1;
315  uint8_t stc : 1;
316  uint8_t st : 1;
317  } refined;
318  uint8_t raw;
319 } akc595x_reg20;
320 
327 typedef uint8_t akc595x_reg21;
328 
336 typedef union {
337  struct
338  {
339  uint8_t cnram : 7;
340  uint8_t mode3k_f : 1;
341  } refined;
342  uint8_t raw;
343 } akc595x_reg22;
344 
352 typedef union {
353  struct
354  {
355  uint8_t cnrfm : 7;
356  uint8_t st_dem : 1;
357  } refined;
358  uint8_t raw;
359 } akc595x_reg23;
360 
368 typedef union {
369  struct
370  {
371  uint8_t lvmode : 1;
372  uint8_t rsv : 1;
373  uint8_t pgalevel_if : 3;
374  uint8_t pgalevel_rf : 3;
375  } refined;
376  uint8_t raw;
377 } akc595x_reg24;
378 
386 typedef union {
387  struct
388  {
389  uint8_t vbat : 6;
390  uint8_t rsv : 2;
391  } refined;
392  uint8_t raw;
393 } akc595x_reg25;
394 
402 typedef uint8_t akc595x_reg26;
403 
413 typedef union {
414  struct
415  {
416  uint8_t rssi : 7;
417  uint8_t rsv : 1;
418  } refined;
419  uint8_t raw;
420 } akc595x_reg27;
421 
430 class AKC695X
431 {
432 
433 protected:
434  int deviceAddress = AKC595X_I2C_ADRESS;
435  int resetPin = -1;
436 
437  uint8_t volume;
438 
439  uint16_t currentStep;
440  uint16_t currentFrequency;
441  uint8_t currentMode = 0;
442 
443  // AM current band information
444  uint8_t currentBand = 0;
445  uint16_t currentBandMinimumFrequency;
446  uint16_t currentBandMaximumFrequency;
447 
448  // FM current band information
449  uint8_t fmCurrentBand = 0;
450 
451 public:
452  // Low level functions
453  void reset();
454  void setI2CBusAddress(int deviceAddress);
455  void setup(int reset_pin);
456  void powerOn(uint8_t fm_en, uint8_t tune, uint8_t mute, uint8_t seek, uint8_t seekup);
457  void setRegister(uint8_t reg, uint8_t parameter);
458  uint8_t getRegister(uint8_t reg);
459 
460  bool isTuned();
461  bool isTuningComplete();
462  uint8_t isCurrentModeFM();
463  uint16_t getCurrentChannel();
464 
465 
466  void setFM(uint8_t akc695x_fm_band, uint16_t minimum_freq, uint16_t maximum_freq, uint16_t default_frequency, uint8_t default_step);
467  void setAM(uint8_t akc695x_am_band, uint16_t minimum_freq, uint16_t maximum_freq, uint16_t default_frequency, uint8_t default_step);
468  void setStep(uint8_t step);
469 
470  void setFmSeekStep(uint8_t value);
471  void seekFmStation(uint8_t up_down);
472 
473  void setFrequency(uint16_t frequency);
474  uint16_t getFrequency();
475  void frequencyUp();
476  void frequencyDown();
477 
478  void setAudio(uint8_t phase_inv, uint8_t line, uint8_t volume);
479  void setAudio();
480 
481  void setVolume(uint8_t volume);
482  void setVolumeControl(uint8_t type);
483  void setVolumeUp();
484  void setVolumeDown();
485  inline int getVolume() { return this->volume; };
486 
487  int getRSSI();
488  float getSupplyVoltage();
489 
490  inline uint8_t getCurrentMode() { return this->currentMode; };
491 
492  void commitTune();
493 };
akc595x_reg2::channel
uint8_t channel
(0:4) - 5 most significant bits that represents the channel (see reg3)
Definition: AKC695X.h:147
AKC695X::setStep
void setStep(uint8_t step)
Sets the step that will be used to increment and decrement the current frequency.
Definition: AKC695X.cpp:361
AKC695X::setVolume
void setVolume(uint8_t volume)
Sets the output audio volume.
Definition: AKC695X.cpp:547
akc595x_reg12::rsv2
uint8_t rsv2
Reserved. Measured using, do not change this value.
Definition: AKC695X.h:276
akc595x_reg20
Reg20 (type 0x14 / R)
Definition: AKC695X.h:310
akc595x_reg13::vol_pre
uint8_t vol_pre
Adjusting the output volume of the entire values: 00: 0dB 01: 3.5dB.
Definition: AKC695X.h:295
AKC695X::isTuningComplete
bool isTuningComplete()
Gets the Status of seeking or tuning process.
Definition: AKC695X.cpp:158
akc595x_reg6
Reg6 (type 0x06 / RW): configures register 0 (default: 0xA1) Address.
Definition: AKC695X.h:178
akc595x_reg0::tune
uint8_t tune
0-> 1 Trigger tune process The STC bit is set high when the tune operation completes.
Definition: AKC695X.h:110
AKC695X::seekFmStation
void seekFmStation(uint8_t up_down)
Seeks a FM station.
Definition: AKC695X.cpp:396
AKC695X::setI2CBusAddress
void setI2CBusAddress(int deviceAddress)
Sets the I2C bus device address.
Definition: AKC695X.cpp:44
akc595x_reg0::seek
uint8_t seek
0-> 1 Trigger tune process The STC bit is set high when the tune operation completes.
Definition: AKC695X.h:109
AKC695X::isTuned
bool isTuned()
Gets the result of tune processing.
Definition: AKC695X.cpp:144
akc595x_reg8::am_cnr_th
uint8_t am_cnr_th
When AM mode, chip sets and lighting sentence carrier to noise ratio threshold.
Definition: AKC695X.h:217
AKC695X
Definition: AKC695X.h:430
AKC695X::setFrequency
void setFrequency(uint16_t frequency)
Sets the the device to a given frequency.
Definition: AKC695X.cpp:438
akc595x_reg25::rsv
uint8_t rsv
Reserved.
Definition: AKC695X.h:390
akc595x_reg11
Reg11 (type 0x0B / RW): configure register 9 (default: 0xE0) Address.
Definition: AKC695X.h:256
akc595x_reg9
Reg9 (type 0x09 / RW): configure register 9 (default: 0x07) Address.
Definition: AKC695X.h:230
akc595x_reg13::rsv2
uint8_t rsv2
Measured using, do not change this value.
Definition: AKC695X.h:296
akc595x_reg22::mode3k_f
uint8_t mode3k_f
1 = AM 3K channel spacing; 0 = AM 5K channel spacing
Definition: AKC695X.h:340
akc595x_reg2
Reg2 (type 0x02 / RW): configure register 2 (default: 0x4A) Address.
Definition: AKC695X.h:144
AKC695X::getRSSI
int getRSSI()
Gets the current RSSI.
Definition: AKC695X.cpp:606
akc595x_reg9::pd_adc_vol
uint8_t pd_adc_vol
0 = volume potentiometer mode
Definition: AKC695X.h:236
akc595x_reg7::bben
uint8_t bben
Base boost enable 0; Close bass 1.
Definition: AKC695X.h:198
akc595x_reg13::rsv1
uint8_t rsv1
Measured using, do not change this value.
Definition: AKC695X.h:298
akc595x_reg6::line
uint8_t line
0 = Radio mode; 1 = Line Mode
Definition: AKC695X.h:182
akc595x_reg9::rsv1
uint8_t rsv1
Reserved. Measured using, do not change this value.
Definition: AKC695X.h:234
akc595x_reg25
Reg25 (type 0x19 / R)
Definition: AKC695X.h:386
akc595x_reg8::fm_cnr_th
uint8_t fm_cnr_th
When the FM mode, chip sets and lighting sentence carrier to noise. Ratio limit 00-2dB 01-3dB 10-4dB ...
Definition: AKC695X.h:218
akc595x_reg13::st_led
uint8_t st_led
0 = tund pin is tuned lamp; When 1-FM and non wtmode, tund indicator pin is stereo demodulation,...
Definition: AKC695X.h:297
AKC695X::setAM
void setAM(uint8_t akc695x_am_band, uint16_t minimum_freq, uint16_t maximum_freq, uint16_t default_frequency, uint8_t default_step)
Sets the AKC695X to AM mode and selects the band.
Definition: AKC695X.cpp:321
akc595x_reg13
Reg13 (type 0x0D / RW): configure register 11 (default: 0x??) Address.
Definition: AKC695X.h:291
AKC695X::getSupplyVoltage
float getSupplyVoltage()
Gets the supply voltage.
Definition: AKC695X.cpp:629
akc595x_reg11::rsv2
uint8_t rsv2
Reserved. Measured using, do not change this value.
Definition: AKC695X.h:261
akc595x_reg12::res
uint8_t res
?????
Definition: AKC695X.h:278
akc595x_reg0::power_on
uint8_t power_on
1 = Chip on; 0 = Chip off
Definition: AKC695X.h:112
akc595x_reg4
uint8_t akc595x_reg4
Reg4 (type 0x04 / RW): configures register 4 (default: 0x19) Address.
Definition: AKC695X.h:165
akc595x_reg5
uint8_t akc595x_reg5
Reg5 (type 0x05 / RW): configures register 5 (default: 0x32) Address.
Definition: AKC695X.h:172
AKC695X::setFM
void setFM(uint8_t akc695x_fm_band, uint16_t minimum_freq, uint16_t maximum_freq, uint16_t default_frequency, uint8_t default_step)
Sets the AKC695X to FM mode.
Definition: AKC695X.cpp:257
akc595x_reg11::space
uint8_t space
00 = 25KHz; 01 = 50KHz; 10 = 100KHz; 11 = 200KHz
Definition: AKC695X.h:260
akc595x_reg1
Reg1 (type 0x01 / RW): configures register 1 (default: 0x10) Address.
Definition: AKC695X.h:124
akc595x_reg6::volume
uint8_t volume
Volume: 0 ~ 63 (<24 = mute; 24 ~ 63)
Definition: AKC695X.h:183
AKC695X::frequencyDown
void frequencyDown()
Subtracts the current step from the current frequency and assign the new frequency.
Definition: AKC695X.cpp:498
AKC695X::setVolumeControl
void setVolumeControl(uint8_t type)
Sets the kind of audio volume control will be used.
Definition: AKC695X.cpp:591
AKC695X::isCurrentModeFM
uint8_t isCurrentModeFM()
Gets the current operation mode;.
Definition: AKC695X.cpp:173
akc595x_reg22
Reg22 (type 0x16 / R)
Definition: AKC695X.h:336
AKC695X::setVolumeDown
void setVolumeDown()
Decrements the audio volume.
Definition: AKC695X.cpp:575
akc595x_reg8
Reg8 (type 0x08 / RW): configures register 8 (default: 0x58) Address.
Definition: AKC695X.h:212
akc595x_reg9::osc_en
uint8_t osc_en
Oscillator source selection. 0 = 0-External XO; 1 = 1-Crystal.
Definition: AKC695X.h:235
akc595x_reg3
uint8_t akc595x_reg3
Reg3 (type 0x03 / RW): configures register 3 (default: 0xC8) Address.
Definition: AKC695X.h:159
akc595x_reg27::rsv
uint8_t rsv
Reserved.
Definition: AKC695X.h:417
akc595x_reg0::fm_en
uint8_t fm_en
1 = FM mode; 0 = AM mode
Definition: AKC695X.h:111
akc595x_reg9::rsv2
uint8_t rsv2
Reserved. Measured using, do not change this value.
Definition: AKC695X.h:237
akc595x_reg0::seekup
uint8_t seekup
Seek direction control bit. 0 = Seek down; 1 = Seek up.
Definition: AKC695X.h:108
AKC695X::getFrequency
uint16_t getFrequency()
Returns the current frequency value.
Definition: AKC695X.cpp:477
akc595x_reg12::pd_rx
uint8_t pd_rx
0 = analog and RF analog and RF ??????
Definition: AKC695X.h:277
akc595x_reg12::pd_adc
uint8_t pd_adc
Signal channel ADC signal path; 0 = Close; 1 = Open.
Definition: AKC695X.h:279
akc595x_reg24
Reg24 (type 0x18 / R)
Definition: AKC695X.h:368
akc595x_reg7::rsv
uint8_t rsv
Measured using, set to "0" during normal use.
Definition: AKC695X.h:200
akc595x_reg27::rssi
uint8_t rssi
Antenna aperture can be calculated using signal levels rssi.
Definition: AKC695X.h:416
akc595x_reg11::rsv1
uint8_t rsv1
Reserved. Measured using, do not change this value.
Definition: AKC695X.h:259
akc595x_reg23::cnrfm
uint8_t cnrfm
Carrier to noise ratio of the FM signal format, in dB.
Definition: AKC695X.h:355
akc595x_reg24::pgalevel_rf
uint8_t pgalevel_rf
?? RF power control loop gain level, the greater the level, a high gain of approximately ?...
Definition: AKC695X.h:374
akc595x_reg7::de
uint8_t de
De-emphasis mode. 1 = 75 μ s (USA); 0 = 50 μ s (China)
Definition: AKC695X.h:199
akc595x_reg7::bw
uint8_t bw
00 = 150K; 01 = 200K; 10 = 50K; 11 = 100K
Definition: AKC695X.h:196
AKC695X::setup
void setup(int reset_pin)
Receiver startup.
Definition: AKC695X.cpp:55
akc595x_reg20::stc
uint8_t stc
0 = Not complete; 1 = Complete during Seek and Tune in the register 0.
Definition: AKC695X.h:315
akc595x_reg21
uint8_t akc595x_reg21
Reg21 (type 0x15 / R)
Definition: AKC695X.h:327
akc595x_reg7
Reg7 (type 0x07 / RW): configures register 0 (default: 0xA1) Address.
Definition: AKC695X.h:193
akc595x_reg20::readchan
uint8_t readchan
Current Channel number (high 5bit). See Reg21.
Definition: AKC695X.h:313
akc595x_reg0::mute
uint8_t mute
1 - Mute L / R channel 0 - Normal operation
Definition: AKC695X.h:107
akc595x_reg24::rsv
uint8_t rsv
Reserved.
Definition: AKC695X.h:372
AKC695X::frequencyUp
void frequencyUp()
Adds the current step to the current frequency and sets the new frequency.
Definition: AKC695X.cpp:487
akc595x_reg20::tuned
uint8_t tuned
When transferred to station 1, station search software can use this determination bit table.
Definition: AKC695X.h:314
AKC695X::reset
void reset()
Resets the system.
Definition: AKC695X.cpp:27
akc595x_reg20::st
uint8_t st
??? 0 to the current situation other FM stereo radio ????
Definition: AKC695X.h:316
akc595x_reg0
Reg0 (type 0x00 / RW): configures register 0 (default: 0x4c) Address.
Definition: AKC695X.h:103
AKC695X::powerOn
void powerOn(uint8_t fm_en, uint8_t tune, uint8_t mute, uint8_t seek, uint8_t seekup)
Power the device on.
Definition: AKC695X.cpp:75
akc595x_reg9::iv_en
uint8_t iv_en
When low voltage power supply, whether to enter the low-voltage operation mode can.
Definition: AKC695X.h:233
akc595x_reg23::st_dem
uint8_t st_dem
Only the demodulated FM stereo (Stereo ratio is greater than 30%) show only one.
Definition: AKC695X.h:356
akc595x_reg2::rsv
uint8_t rsv
(7) - Reserved - Debug use, do not change this value using
Definition: AKC695X.h:150
AKC695X::setFmSeekStep
void setFmSeekStep(uint8_t value)
Sets FM step for seeking.
Definition: AKC695X.cpp:383
akc595x_reg25::vbat
uint8_t vbat
6 bits indicating the supply voltage ( unsigned number )
Definition: AKC695X.h:389
AKC695X::getRegister
uint8_t getRegister(uint8_t reg)
Gets a given register content.
Definition: AKC695X.cpp:114
akc595x_reg7::stereo_mono
uint8_t stereo_mono
"00" the auto stereo, there Stereo_th control threshold ; "10" long as the pilot is forced stereo "x1...
Definition: AKC695X.h:197
AKC695X::getCurrentChannel
uint16_t getCurrentChannel()
Gets the current channel.
Definition: AKC695X.cpp:187
akc595x_reg6::phase_inv
uint8_t phase_inv
0 = audio output inphase, 1 = opposite phase, for single speaker
Definition: AKC695X.h:181
akc595x_reg24::lvmode
uint8_t lvmode
Low voltage maximum volume limit mode indication bit.
Definition: AKC695X.h:371
akc595x_reg13::rsv3
uint8_t rsv3
Measured using, do not change this value.
Definition: AKC695X.h:294
akc595x_reg23
Reg23 (type 0x17 / R)
Definition: AKC695X.h:352
akc595x_reg2::ref_37k_mode
uint8_t ref_37k_mode
(6) - 1 = 32K ref. crystal clock; 0 = 12MHz ref crystal clock
Definition: AKC695X.h:149
AKC695X::commitTune
void commitTune()
Sets the STC bit to high when the tune operation completes.
Definition: AKC695X.cpp:215
akc595x_reg0::rsv
uint8_t rsv
Reserved - Debug use, do not change this value using.
Definition: AKC695X.h:106
akc595x_reg26
uint8_t akc595x_reg26
Reg26 (type 0x1A / R)
Definition: AKC695X.h:402
akc595x_reg24::pgalevel_if
uint8_t pgalevel_if
?? RF power control loop gain level, the greater the level, a high gain of approximately ?...
Definition: AKC695X.h:373
akc595x_reg12
Reg12 (type 0x0C / RW): configure register 11 (default: 0x??) Address.
Definition: AKC695X.h:273
akc595x_reg8::stereo_th
uint8_t stereo_th
FM stereo demodulation start CNR threshold - 00=4, 01=8, 10=12,11=16.
Definition: AKC695X.h:215
AKC695X::setRegister
void setRegister(uint8_t reg, uint8_t parameter)
Sets a given register with a given value.
Definition: AKC695X.cpp:98
akc595x_reg2::mode3k
uint8_t mode3k
(5) - 1 = 3K; 0 = 5K
Definition: AKC695X.h:148
akc595x_reg22::cnram
uint8_t cnram
Carrier to noise ratio of the AM signal format, in dB.
Definition: AKC695X.h:339
AKC695X::setVolumeUp
void setVolumeUp()
Increments the audio volume.
Definition: AKC695X.cpp:564
akc595x_reg27
Reg27 (type 0x1B / R)
Definition: AKC695X.h:413
AKC695X::setAudio
void setAudio()
Configures the audio output with default values.
Definition: AKC695X.cpp:533