Set bit in register of sgtl5000 - how?

Status
Not open for further replies.

DIYLAB

Well-known member
Hi guys,

how can I set a bit in a register in the audio library without editing the control_sgtl5000.cpp?

Have a nice weekend
Bruno
 
You could just use the Wire library to talk directly to the SGTL5000 chip, if you *really* don't want to do the easiest thing and just edit control_sgtl5000.cpp.
 
Hi Paul,
I have already edited the control_sgtl5000.cpp and set the bit, it works.
Then I have to make the change with every update of the audio library, because I don't know exactly how it works with I2C.
But you could also add a method that sets bit 8 in the CHIP_ANA_ADC_CTRL register ;o)

Greetings
Bruno

PS: By the way, you are doing a wonderful job! I love the Teensy 4.x!
 
But you could also add a method that sets bit 8 in the CHIP_ANA_ADC_CTRL register ;o)

What should that function be named and how should it be documented?

Please look at the SGTL5000 documentation in the right-side panel of the design tool.

https://www.pjrc.com/teensy/gui/?info=AudioControlSGTL5000

If you want to seriously propose an addition to the library, at the very least it needs to have a name and description which fit well into the existing API and documentation. I'm *not* going to just add a "setEightBitsInADCCTRL" function!
 
Maybe just make these public:
Code:
	unsigned int read(unsigned int reg);
	bool write(unsigned int reg, unsigned int val);
.or DIYLAB could write a wrapper (descendant of AudioControlSGTL5000)
 
What should that function be named and how should it be documented?

Well, one could derive it from the data sheet (page 36)...

"ADC Volume Range Reduction
This bit shifts both right and left analog ADC volume range down by 6.0 dB.
0x0 = No change in ADC range
0x1 = ADC range reduced by 6.0 dB"

...and call the method "VolumeRangeReduction". :cool:

Greetings
Bruno
 
Maybe just make these public:
Code:
	unsigned int read(unsigned int reg);
	bool write(unsigned int reg, unsigned int val);


That indeed would be very usefull for many of us that have been "fiddling" with the SGTL5000 library itself, simply declaring these public allows easy development of additional functions in separate libraries !

regards
Cor
 
Status
Not open for further replies.
Back
Top