-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPI3EQX12908A2.cpp
1938 lines (1808 loc) · 68.9 KB
/
PI3EQX12908A2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* @file PI3EQX12908A2.cpp
*
* @mainpage PI3EQX12908 PCIe 3.0 redriver library
*
* @section intro_sec Introduction
*
* The PI3EQX12908 PCIe 3.0 redriver library is a software library that allows developers to easily access the I2C interfaces of the PI3EQX12908 PCIe 3.0 redriver chip.
* It provides a simple API for performing common I2C operations and is compatible with Arduino platform.
* The library includes example code to help developers get started quickly.
*
* @section author Author
*
* Written by Salman Motlaq (@SMotlaq on GitHub)
*
* @section license License
*
* MIT License
*
*/
#include "PI3EQX12908A2.h"
#include "Arduino.h"
/**************************************************************************/
/*!
@brief Initialize the PI3EQX12908 object
This function sets the I2C address and the register names.
@param i2c_addr
The 7 bit I2C address of the redriver.
*/
/**************************************************************************/
PI3EQX12908::init(uint8_t i2c_addr){
_I2C_ADDR = i2c_addr;
_REGS[0] = "SIGNAL DETECT";
_REGS[1] = " RX DETECT";
_REGS[2] = " POWER DOWN";
_REGS[3] = " CHANNEL A0";
_REGS[4] = " CHANNEL A1";
_REGS[5] = " CHANNEL A2";
_REGS[6] = " CHANNEL A3";
_REGS[7] = " CHANNEL B0";
_REGS[8] = " CHANNEL B1";
_REGS[9] = " CHANNEL B2";
_REGS[10] = " CHANNEL B3";
_REGS[11] = " SIG DET CFG";
_REGS[12] = " RX DET CFG";
_REGS[13] = " SIG DET THR";
_REGS[14] = " 14th BYTE";
_REGS[15] = " 15th BYTE";
}
// 0 - Signal Detect
/**************************************************************************/
/*!
@brief Gets the signal detect register
This function reads the signal detect register values.
@return 8 bit value of signal detect register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSignalDetect(){
return _read_reg(SIGNAL_DETECT_REG);
}
/**************************************************************************/
/*!
@brief Gets the signal detect of A channel
This function reads the signal detect register
and returns the channel A status.
@return 4 bit value of channel A signal detect.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSignalDetect_A(){
return _read_reg(SIGNAL_DETECT_REG) >> 4;
}
/**************************************************************************/
/*!
@brief Gets the signal detect A by channel index
This function reads the signal detect register value
and returns the status of given channel index of A channel.
@param index
A reference to the channel index of A channel from 0 to 3.
@return return zero for not detected, otherwise for detected.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSignalDetect_A(uint8_t index){
return _read_reg(SIGNAL_DETECT_REG) & (1 << (index + 4));
}
/**************************************************************************/
/*!
@brief Gets the signal detect of B channel
This function reads the signal detect register
and returns the channel B status.
@return 4 bit value of channel B signal detect.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSignalDetect_B(){
return _read_reg(SIGNAL_DETECT_REG) & 0x0F;
}
/**************************************************************************/
/*!
@brief Gets the signal detect B by channel index
This function reads the signal detect register value
and returns the status of given channel index of B channel.
@param index
A reference to the channel index of B channel from 0 to 3.
@return return zero for not detected, otherwise for detected.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSignalDetect_B(uint8_t index){
return _read_reg(SIGNAL_DETECT_REG) & (1 << index);
}
// 1 - RX Detect
/**************************************************************************/
/*!
@brief Gets the RX detect register
This function reads the RX detect register values.
@return 8 bit value of RX detect register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getRxDetect(){
return _read_reg(RX_DETECT_REG);
}
/**************************************************************************/
/*!
@brief Gets the RX detect of A channel
This function reads the RX detect register
and returns the channel A status.
@return 4 bit value of channel A RX detect.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getRxDetect_A(){
return _read_reg(RX_DETECT_REG) >> 4;
}
/**************************************************************************/
/*!
@brief Gets the RX detect A by channel index
This function reads the RX detect register value
and returns the status of given channel index of A channel.
@param index
A reference to the channel index of A channel from 0 to 3.
@return return zero for not detected, otherwise for detected.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getRxDetect_A(uint8_t index){
return _read_reg(RX_DETECT_REG) & (1 << (index + 4));
}
/**************************************************************************/
/*!
@brief Gets the RX detect of B channel
This function reads the RX detect register
and returns the channel B status.
@return 4 bit value of channel B RX detect.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getRxDetect_B(){
return _read_reg(RX_DETECT_REG) & 0x0F;
}
/**************************************************************************/
/*!
@brief Gets the RX detect B by channel index
This function reads the RX detect register value
and returns the status of given channel index of B channel.
@param index
A reference to the channel index of B channel from 0 to 3.
@return return zero for not detected, otherwise for detected.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getRxDetect_B(uint8_t index){
return _read_reg(RX_DETECT_REG) & (1 << index);
}
// 2 - Power Down
/**************************************************************************/
/*!
@brief Gets the power down register
This function reads the power down register values.
@return 8 bit value of power down register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getPowerDown(){
return _read_reg(POWER_DOWN_REG);
}
/**************************************************************************/
/*!
@brief Gets the power down of A channel
This function reads the power down register
and returns the channel A status.
@return 4 bit value of channel A power down.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getPowerDown_A(){
return _read_reg(POWER_DOWN_REG) >> 4;
}
/**************************************************************************/
/*!
@brief Gets the power down A by channel index
This function reads the power down register value
and returns the status of given channel index of A channel.
@param index
A reference to the channel index of A channel from 0 to 3.
@return return zero for not detected, otherwise for detected.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getPowerDown_A(uint8_t index){
return _read_reg(POWER_DOWN_REG) & (1 << (index + 4));
}
/**************************************************************************/
/*!
@brief Gets the power down of B channel
This function reads the power down register
and returns the channel B status.
@return 4 bit value of channel B power down.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getPowerDown_B(){
return _read_reg(POWER_DOWN_REG) & 0x0F;
}
/**************************************************************************/
/*!
@brief Gets the power down B by channel index
This function reads the power down register value
and returns the status of given channel index of B channel.
@param index
A reference to the channel index of B channel from 0 to 3.
@return return zero for not detected, otherwise for detected.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getPowerDown_B(uint8_t index){
return _read_reg(POWER_DOWN_REG) & (1 << index);
}
/**************************************************************************/
/*!
@brief Sets the power down register.
This function change the power down status of all channels.
@param isDown
- #CFG_ON for power up
- #CFG_OFF for power down
*/
/**************************************************************************/
void PI3EQX12908::setPowerDown(uint8_t isDown){
_write_reg(POWER_DOWN_REG, isDown ? 0xFF : 0x00);
}
/**************************************************************************/
/*!
@brief Sets the power down of A channel.
This function change the power down status of channel A.
@param isDown
- #CFG_ON for power up
- #CFG_OFF for power down
*/
/**************************************************************************/
void PI3EQX12908::setPowerDown_A(uint8_t isDown){
uint8_t val = getPowerDown();
if(isDown)
val |= (uint8_t)0xF0;
else
val &= (uint8_t)0x0F;
_write_reg(POWER_DOWN_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the power down of a given index of A channel.
This function change the power down status of the
given channel A index.
@param index
A reference to the channel index of A channel from 0 to 3.
@param isDown
- #CFG_ON for power up
- #CFG_OFF for power down
*/
/**************************************************************************/
void PI3EQX12908::setPowerDown_A(uint8_t index, uint8_t isDown){
uint8_t val = getPowerDown();
if(isDown)
val |= (1 << (index + 4));
else
val &= ~(1 << (index + 4));
_write_reg(POWER_DOWN_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the power down of B channel.
This function change the power down status of channel B.
@param isDown
- #CFG_ON for power up
- #CFG_OFF for power down
*/
/**************************************************************************/
void PI3EQX12908::setPowerDown_B(uint8_t isDown){
uint8_t val = getPowerDown();
if(isDown)
val |= (uint8_t)0x0F;
else
val &= (uint8_t)0xF0;
_write_reg(POWER_DOWN_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the power down of a given index of B channel.
This function change the power down status of the
given channel B index.
@param index
A reference to the channel index of B channel from 0 to 3.
@param isDown
- #CFG_ON for power up
- #CFG_OFF for power down
*/
/**************************************************************************/
void PI3EQX12908::setPowerDown_B(uint8_t index, uint8_t isDown){
uint8_t val = getPowerDown();
if(isDown)
val |= (1 << index);
else
val &= ~(1 << index);
_write_reg(POWER_DOWN_REG, val);
}
// 3 - A0 Config
/**************************************************************************/
/*!
@brief Gets the configuration of the 0 index A channel.
This function reads the configuration of the 0 index A channel value.
@return 8 bit value of A0 config register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getConfig_A0(){
return _read_reg(CONFIG_A0_REG);
}
/**************************************************************************/
/*!
@brief Gets the equalizer configuration of the 0 index A channel.
This function reads the equalizer value of the 0 index A channel value.
@return 4 bit value of A0 equalizer.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getEQ_A0(){
return _read_reg(CONFIG_A0_REG) >> EQ_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the flat gain configuration of the 0 index A channel.
This function reads the flat gain value of the 0 index A channel value.
@return 2 bit value of A0 flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
uint8_t PI3EQX12908::getFlatGain_A0(){
return (_read_reg(CONFIG_A0_REG) & 0x0F) >> FG_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the swing configuration of the 0 index A channel.
This function reads the swing value of the 0 index A channel value.
@return 1 bit value of A0 swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSW_A0(){
return _read_reg(CONFIG_A0_REG) & 0x01;
}
/**************************************************************************/
/*!
@brief Sets the configuration of the 0 index A channel.
This function sets the configuration register of A0.
** NOT RECOMENDED TO USE! **
@param config
8 bit value of the config register
*/
/**************************************************************************/
void PI3EQX12908::setConfig_A0(uint8_t config){
_write_reg(CONFIG_A0_REG, config);
}
/**************************************************************************/
/*!
@brief Sets the equalizer value of the 0 index A channel.
This function sets the equalizer value of A0.
@param EQ
4 bit value of the equalizer index
*/
/**************************************************************************/
void PI3EQX12908::setEQ_A0(uint8_t EQ){
uint8_t val = getConfig_A0();
val &= 0x0F;
val |= (EQ & 0x0F) << EQ_SHIFT;
_write_reg(CONFIG_A0_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the flat gain value of the 0 index A channel.
This function sets the flat gain value of A0.
@param flat_gain
2 bit value of the flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
void PI3EQX12908::setFlatGain_A0(uint8_t flat_gain){
uint8_t val = getConfig_A0();
val &= 0xF3;
val |= (flat_gain & 0x03) << FG_SHIFT;
_write_reg(CONFIG_A0_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the swing value of the 0 index A channel.
This function sets the swing value of A0.
@param swing
1 bit value of the swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
void PI3EQX12908::setSW_A0(uint8_t swing){
uint8_t val = getConfig_A0();
val &= 0xFE;
val |= swing & 0x01;
_write_reg(CONFIG_A0_REG, val);
}
// 4 - A1 Config
/**************************************************************************/
/*!
@brief Gets the configuration of the 1 index A channel.
This function reads the configuration of the 1 index A channel value.
@return 8 bit value of A1 config register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getConfig_A1(){
return _read_reg(CONFIG_A1_REG);
}
/**************************************************************************/
/*!
@brief Gets the equalizer configuration of the 1 index A channel.
This function reads the equalizer value of the 1 index A channel value.
@return 4 bit value of A1 equalizer.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getEQ_A1(){
return _read_reg(CONFIG_A1_REG) >> EQ_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the flat gain configuration of the 1 index A channel.
This function reads the flat gain value of the 1 index A channel value.
@return 2 bit value of A1 flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
uint8_t PI3EQX12908::getFlatGain_A1(){
return (_read_reg(CONFIG_A1_REG) & 0x0F) >> FG_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the swing configuration of the 1 index A channel.
This function reads the swing value of the 1 index A channel value.
@return 1 bit value of A1 swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSW_A1(){
return _read_reg(CONFIG_A1_REG) & 0x01;
}
/**************************************************************************/
/*!
@brief Sets the configuration of the 1 index A channel.
This function sets the configuration register of A1.
** NOT RECOMENDED TO USE! **
@param config
8 bit value of the config register
*/
/**************************************************************************/
void PI3EQX12908::setConfig_A1(uint8_t config){
_write_reg(CONFIG_A1_REG, config);
}
/**************************************************************************/
/*!
@brief Sets the equalizer value of the 1 index A channel.
This function sets the equalizer value of A1.
@param EQ
4 bit value of the equalizer index
*/
/**************************************************************************/
void PI3EQX12908::setEQ_A1(uint8_t EQ){
uint8_t val = getConfig_A1();
val &= 0x0F;
val |= (EQ & 0x0F) << EQ_SHIFT;
_write_reg(CONFIG_A1_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the flat gain value of the 1 index A channel.
This function sets the flat gain value of A1.
@param flat_gain
2 bit value of the flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
void PI3EQX12908::setFlatGain_A1(uint8_t flat_gain){
uint8_t val = getConfig_A1();
val &= 0xF3;
val |= (flat_gain & 0x03) << FG_SHIFT;
_write_reg(CONFIG_A1_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the swing value of the 1 index A channel.
This function sets the swing value of A1.
@param swing
1 bit value of the swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
void PI3EQX12908::setSW_A1(uint8_t swing){
uint8_t val = getConfig_A1();
val &= 0xFE;
val |= swing & 0x01;
_write_reg(CONFIG_A1_REG, val);
}
// 5 - A2 Config
/**************************************************************************/
/*!
@brief Gets the configuration of the 2 index A channel.
This function reads the configuration of the 2 index A channel value.
@return 8 bit value of A2 config register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getConfig_A2(){
return _read_reg(CONFIG_A2_REG);
}
/**************************************************************************/
/*!
@brief Gets the equalizer configuration of the 2 index A channel.
This function reads the equalizer value of the 2 index A channel value.
@return 4 bit value of A2 equalizer.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getEQ_A2(){
return _read_reg(CONFIG_A2_REG) >> EQ_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the flat gain configuration of the 2 index A channel.
This function reads the flat gain value of the 2 index A channel value.
@return 2 bit value of A2 flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
uint8_t PI3EQX12908::getFlatGain_A2(){
return (_read_reg(CONFIG_A2_REG) & 0x0F) >> FG_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the swing configuration of the 2 index A channel.
This function reads the swing value of the 2 index A channel value.
@return 1 bit value of A2 swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSW_A2(){
return _read_reg(CONFIG_A2_REG) & 0x01;
}
/**************************************************************************/
/*!
@brief Sets the configuration of the 2 index A channel.
This function sets the configuration register of A2.
** NOT RECOMENDED TO USE! **
@param config
8 bit value of the config register
*/
/**************************************************************************/
void PI3EQX12908::setConfig_A2(uint8_t config){
_write_reg(CONFIG_A2_REG, config);
}
/**************************************************************************/
/*!
@brief Sets the equalizer value of the 2 index A channel.
This function sets the equalizer value of A2.
@param EQ
4 bit value of the equalizer index
*/
/**************************************************************************/
void PI3EQX12908::setEQ_A2(uint8_t EQ){
uint8_t val = getConfig_A2();
val &= 0x0F;
val |= (EQ & 0x0F) << EQ_SHIFT;
_write_reg(CONFIG_A2_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the flat gain value of the 2 index A channel.
This function sets the flat gain value of A2.
@param flat_gain
2 bit value of the flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
void PI3EQX12908::setFlatGain_A2(uint8_t flat_gain){
uint8_t val = getConfig_A2();
val &= 0xF3;
val |= (flat_gain & 0x03) << FG_SHIFT;
_write_reg(CONFIG_A2_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the swing value of the 2 index A channel.
This function sets the swing value of A2.
@param swing
1 bit value of the swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
void PI3EQX12908::setSW_A2(uint8_t swing){
uint8_t val = getConfig_A2();
val &= 0xFE;
val |= swing & 0x01;
_write_reg(CONFIG_A2_REG, val);
}
// 6 - A3 Config
/**************************************************************************/
/*!
@brief Gets the configuration of the 3 index A channel.
This function reads the configuration of the 3 index A channel value.
@return 8 bit value of A3 config register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getConfig_A3(){
return _read_reg(CONFIG_A3_REG);
}
/**************************************************************************/
/*!
@brief Gets the equalizer configuration of the 3 index A channel.
This function reads the equalizer value of the 3 index A channel value.
@return 4 bit value of A3 equalizer.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getEQ_A3(){
return _read_reg(CONFIG_A3_REG) >> EQ_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the flat gain configuration of the 3 index A channel.
This function reads the flat gain value of the 3 index A channel value.
@return 2 bit value of A3 flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
uint8_t PI3EQX12908::getFlatGain_A3(){
return (_read_reg(CONFIG_A3_REG) & 0x0F) >> FG_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the swing configuration of the 3 index A channel.
This function reads the swing value of the 3 index A channel value.
@return 1 bit value of A3 swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSW_A3(){
return _read_reg(CONFIG_A3_REG) & 0x01;
}
/**************************************************************************/
/*!
@brief Sets the configuration of the 3 index A channel.
This function sets the configuration register of A3.
** NOT RECOMENDED TO USE! **
@param config
8 bit value of the config register
*/
/**************************************************************************/
void PI3EQX12908::setConfig_A3(uint8_t config){
_write_reg(CONFIG_A3_REG, config);
}
/**************************************************************************/
/*!
@brief Sets the equalizer value of the 3 index A channel.
This function sets the equalizer value of A3.
@param EQ
4 bit value of the equalizer index
*/
/**************************************************************************/
void PI3EQX12908::setEQ_A3(uint8_t EQ){
uint8_t val = getConfig_A3();
val &= 0x0F;
val |= (EQ & 0x0F) << EQ_SHIFT;
_write_reg(CONFIG_A3_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the flat gain value of the 3 index A channel.
This function sets the flat gain value of A3.
@param flat_gain
2 bit value of the flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
void PI3EQX12908::setFlatGain_A3(uint8_t flat_gain){
uint8_t val = getConfig_A3();
val &= 0xF3;
val |= (flat_gain & 0x03) << FG_SHIFT;
_write_reg(CONFIG_A3_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the swing value of the 3 index A channel.
This function sets the swing value of A3.
@param swing
1 bit value of the swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
void PI3EQX12908::setSW_A3(uint8_t swing){
uint8_t val = getConfig_A3();
val &= 0xFE;
val |= swing & 0x01;
_write_reg(CONFIG_A3_REG, val);
}
// 7 - B0 Config
/**************************************************************************/
/*!
@brief Gets the configuration of the 0 index B channel.
This function reads the configuration of the 0 index B channel value.
@return 8 bit value of B0 config register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getConfig_B0(){
return _read_reg(CONFIG_B0_REG);
}
/**************************************************************************/
/*!
@brief Gets the equalizer configuration of the 0 index B channel.
This function reads the equalizer value of the 0 index B channel value.
@return 4 bit value of B0 equalizer.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getEQ_B0(){
return _read_reg(CONFIG_B0_REG) >> EQ_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the flat gain configuration of the 0 index B channel.
This function reads the flat gain value of the 0 index B channel value.
@return 2 bit value of B0 flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
uint8_t PI3EQX12908::getFlatGain_B0(){
return (_read_reg(CONFIG_B0_REG) & 0x0F) >> FG_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the swing configuration of the 0 index B channel.
This function reads the swing value of the 0 index B channel value.
@return 1 bit value of B0 swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSW_B0(){
return _read_reg(CONFIG_B0_REG) & 0x01;
}
/**************************************************************************/
/*!
@brief Sets the configuration of the 0 index B channel.
This function sets the configuration register of B0.
** NOT RECOMENDED TO USE! **
@param config
8 bit value of the config register
*/
/**************************************************************************/
void PI3EQX12908::setConfig_B0(uint8_t config){
_write_reg(CONFIG_B0_REG, config);
}
/**************************************************************************/
/*!
@brief Sets the equalizer value of the 0 index B channel.
This function sets the equalizer value of B0.
@param EQ
4 bit value of the equalizer index
*/
/**************************************************************************/
void PI3EQX12908::setEQ_B0(uint8_t EQ){
uint8_t val = getConfig_B0();
val &= 0x0F;
val |= (EQ & 0x0F) << EQ_SHIFT;
_write_reg(CONFIG_B0_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the flat gain value of the 0 index B channel.
This function sets the flat gain value of B0.
@param flat_gain
2 bit value of the flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
void PI3EQX12908::setFlatGain_B0(uint8_t flat_gain){
uint8_t val = getConfig_B0();
val &= 0xF3;
val |= (flat_gain & 0x03) << FG_SHIFT;
_write_reg(CONFIG_B0_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the swing value of the 0 index B channel.
This function sets the swing value of B0.
@param swing
1 bit value of the swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
void PI3EQX12908::setSW_B0(uint8_t swing){
uint8_t val = getConfig_B0();
val &= 0xFE;
val |= swing & 0x01;
_write_reg(CONFIG_B0_REG, val);
}
// 8 - B1 Config
/**************************************************************************/
/*!
@brief Gets the configuration of the 1 index B channel.
This function reads the configuration of the 1 index B channel value.
@return 8 bit value of B1 config register.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getConfig_B1(){
return _read_reg(CONFIG_B1_REG);
}
/**************************************************************************/
/*!
@brief Gets the equalizer configuration of the 1 index B channel.
This function reads the equalizer value of the 1 index B channel value.
@return 4 bit value of B1 equalizer.
*/
/**************************************************************************/
uint8_t PI3EQX12908::getEQ_B1(){
return _read_reg(CONFIG_B1_REG) >> EQ_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the flat gain configuration of the 1 index B channel.
This function reads the flat gain value of the 1 index B channel value.
@return 2 bit value of B1 flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db
*/
/**************************************************************************/
uint8_t PI3EQX12908::getFlatGain_B1(){
return (_read_reg(CONFIG_B1_REG) & 0x0F) >> FG_SHIFT;
}
/**************************************************************************/
/*!
@brief Gets the swing configuration of the 1 index B channel.
This function reads the swing value of the 1 index B channel value.
@return 1 bit value of B1 swing:
- #SWING_900mVpp -> 900 mVpp
- #SWING_1000mVpp -> 1000 mVpp
*/
/**************************************************************************/
uint8_t PI3EQX12908::getSW_B1(){
return _read_reg(CONFIG_B1_REG) & 0x01;
}
/**************************************************************************/
/*!
@brief Sets the configuration of the 1 index B channel.
This function sets the configuration register of B1.
** NOT RECOMENDED TO USE! **
@param config
8 bit value of the config register
*/
/**************************************************************************/
void PI3EQX12908::setConfig_B1(uint8_t config){
_write_reg(CONFIG_B1_REG, config);
}
/**************************************************************************/
/*!
@brief Sets the equalizer value of the 1 index B channel.
This function sets the equalizer value of B1.
@param EQ
4 bit value of the equalizer index
*/
/**************************************************************************/
void PI3EQX12908::setEQ_B1(uint8_t EQ){
uint8_t val = getConfig_B1();
val &= 0x0F;
val |= (EQ & 0x0F) << EQ_SHIFT;
_write_reg(CONFIG_B1_REG, val);
}
/**************************************************************************/
/*!
@brief Sets the flat gain value of the 1 index B channel.
This function sets the flat gain value of B1.
@param flat_gain
2 bit value of the flat gain:
- #FLAT_GAIN_M4db -> -4 db
- #FLAT_GAIN_M2db -> -2 db
- #FLAT_GAIN_00db -> 0 db
- #FLAT_GAIN_P2db -> +2 db