Skip to content

Commit 0837f2d

Browse files
mikeysklarclaude
andcommitted
TLV320_Tone_Arduino: add headphone support and Pico 2W (RP2350) hardware reset
- Add hardware reset on pin 7 (RST), required for RP2350 codec init, harmless on RP2040 - Add commented-out headphone output block for users without a speaker Tested on Raspberry Pi Pico (RP2040) and Pico 2W (RP2350). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 92a79a1 commit 0837f2d

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

TLV320DAC3100_Examples/TLV320_Tone_Arduino/TLV320_Tone_Arduino.ino

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
Adafruit_TLV320DAC3100 codec; // Create codec object
1212

13-
#define pBCLK D9 // BITCLOCK - I2S clock
14-
#define pWS D10 // LRCLOCK - Word select
15-
#define pDOUT D11 // DATA - I2S data
13+
#define pBCLK D9 // BITCLOCK - I2S clock
14+
#define pWS D10 // LRCLOCK - Word select
15+
#define pDOUT D11 // DATA - I2S data
16+
#define pRESET 7 // RST - hardware reset (required for Pico 2W / RP2350)
1617

1718
// Create I2S port
1819
I2S i2s(OUTPUT);
@@ -31,6 +32,14 @@ void setup() {
3132

3233
while (!Serial) delay(10);
3334
Serial.println("\n\nTLV320DAC3100 Sine Tone Test");
35+
36+
// Hardware reset - required for Pico 2W (RP2350), harmless on Pico (RP2040)
37+
pinMode(pRESET, OUTPUT);
38+
digitalWrite(pRESET, LOW);
39+
delay(100);
40+
digitalWrite(pRESET, HIGH);
41+
delay(100);
42+
3443
// Start I2C communication with codec
3544
Serial.println("Initializing codec...");
3645
if (!codec.begin()) {
@@ -106,6 +115,13 @@ void setup() {
106115
Serial.println("Failed to configure speaker output!");
107116
}
108117

118+
// Uncomment to use headphone output instead of (or in addition to) speaker
119+
// codec.configureHeadphoneDriver(true, true, TLV320_HP_COMMON_1_35V, false);
120+
// codec.setHPLVolume(true, 0);
121+
// codec.setHPRVolume(true, 0);
122+
// codec.configureHPL_PGA(9, true);
123+
// codec.configureHPR_PGA(9, true);
124+
109125
// Initialize I2S peripheral
110126
Serial.println("Initializing I2S...");
111127
i2s.setBCLK(pBCLK);

0 commit comments

Comments
 (0)