Skip to content

Commit 8b1024e

Browse files
committed
Make return codes consistent with other Arduino API's
1 parent dad4909 commit 8b1024e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

libraries/I2S/examples/InputSerialPlotter/InputSerialPlotter.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void setup() {
2929
}
3030

3131
// start I2S at 8 kHz with 32-bits per sample
32-
if (I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
32+
if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
3333
Serial.println("Failed to initialize I2S!");
3434
while (1); // do nothing
3535
}

libraries/I2S/examples/SimpleTone/SimpleTone.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void setup() {
3232
Serial.println("I2S simple tone");
3333

3434
// start I2S at the sample rate with 16-bits per sample
35-
if (I2S.begin(I2S_PHILIPS_MODE, sampleRate, 16)) {
35+
if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, 16)) {
3636
Serial.println("Failed to initialize I2S!");
3737
while (1); // do nothing
3838
}

libraries/I2S/src/I2S.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int I2SClass::begin(int mode, int bitsPerSample)
6060
int I2SClass::begin(int mode, long sampleRate, int bitsPerSample, bool driveClock)
6161
{
6262
if (_state != I2S_STATE_IDLE) {
63-
return 1;
63+
return 0;
6464
}
6565

6666
switch (mode) {
@@ -71,7 +71,7 @@ int I2SClass::begin(int mode, long sampleRate, int bitsPerSample, bool driveCloc
7171

7272
default:
7373
// invalid mode
74-
return 1;
74+
return 0;
7575
}
7676

7777
switch (bitsPerSample) {
@@ -83,7 +83,7 @@ int I2SClass::begin(int mode, long sampleRate, int bitsPerSample, bool driveCloc
8383

8484
default:
8585
// invalid bits per sample
86-
return 1;
86+
return 0;
8787
}
8888

8989
// try to allocate a DMA channel
@@ -93,7 +93,7 @@ int I2SClass::begin(int mode, long sampleRate, int bitsPerSample, bool driveCloc
9393

9494
if (_dmaChannel < 0) {
9595
// no DMA channel available
96-
return 1;
96+
return 0;
9797
}
9898

9999
if (_beginCount == 0) {
@@ -148,7 +148,7 @@ int I2SClass::begin(int mode, long sampleRate, int bitsPerSample, bool driveCloc
148148

149149
_doubleBuffer.reset();
150150

151-
return 0;
151+
return 1;
152152
}
153153

154154
void I2SClass::end()

0 commit comments

Comments
 (0)