1010
1111Adafruit_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
1819I2S i2s (OUTPUT);
@@ -31,6 +32,14 @@ void setup() {
3132
3233 while (!Serial) delay (10 );
3334 Serial.println (" \n\n TLV320DAC3100 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 ()) {
@@ -92,7 +101,7 @@ void setup() {
92101 !codec.setChannelVolume (true , 18 )) { // Right DAC +0dB
93102 Serial.println (" Failed to configure DAC volume control!" );
94103 }
95-
104+
96105
97106 if (!codec.setChannelVolume (false , 12.0 ) ||
98107 !codec.setChannelVolume (true , 12.0 )) {
@@ -106,6 +115,13 @@ void setup() {
106115 Serial.println (" Failed to configure speaker output!" );
107116 }
108117
118+ // Headphone output
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