Skip to content

Commit c141420

Browse files
committed
I2S compile error
1 parent 40a050c commit c141420

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/AudioI2S/I2SESP32.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class I2SBase {
3030
}
3131

3232
/// starts the DAC with the default config
33-
void begin(RxTxMode mode = TX_MODE) {
34-
begin(defaultConfig(mode));
33+
bool begin(RxTxMode mode = TX_MODE) {
34+
return begin(defaultConfig(mode));
3535
}
3636

3737

3838
/// starts the DAC
39-
void begin(I2SConfig cfg) {
39+
bool begin(I2SConfig cfg) {
4040
LOGD(LOG_METHOD);
4141
switch(cfg.rx_tx_mode){
4242
case TX_MODE:
@@ -52,7 +52,7 @@ class I2SBase {
5252
}
5353
int txPin = cfg.rx_tx_mode == TX_MODE ? cfg.pin_data : I2S_PIN_NO_CHANGE;
5454
int rxPin = cfg.rx_tx_mode == RX_MODE ? cfg.pin_data : I2S_PIN_NO_CHANGE;
55-
begin(cfg, txPin, rxPin);
55+
return begin(cfg, txPin, rxPin);
5656
}
5757

5858
/// we assume the data is already available in the buffer
@@ -108,7 +108,7 @@ class I2SBase {
108108
bool is_started = false;
109109

110110
/// starts the DAC
111-
void begin(I2SConfig cfg, int txPin, int rxPin) {
111+
bool begin(I2SConfig cfg, int txPin, int rxPin) {
112112
LOGD(LOG_METHOD);
113113
cfg.logInfo();
114114
this->cfg = cfg;
@@ -171,6 +171,7 @@ class I2SBase {
171171

172172
is_started = true;
173173
LOGD("%s - %s", __func__, "started");
174+
return true;
174175
}
175176

176177
// update the cfg.i2s.channel_format based on the number of channels

src/AudioI2S/I2SSAMD.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,23 @@ class I2SBase {
2222
}
2323

2424
/// starts the DAC with the default config
25-
void begin(RxTxMode mode = TX_MODE) {
26-
begin(defaultConfig())
25+
bool begin(RxTxMode mode = TX_MODE) {
26+
return begin(defaultConfig())
2727
}
2828

2929
/// starts the DAC
30-
void begin(I2SConfig cfg) {
30+
bool begin(I2SConfig cfg) {
3131
I2S.begin(cfg.i2s_format, cfg.sample_rate, cfg.bits_per_sample, cfg.is_master);
3232
if (cfg.mode = TX_MODE){
3333
I2S.enableTransmitter();
3434
} else {
3535
I2S.enableReceiver();
3636
}
37+
return true;
38+
}
39+
40+
bool begin() {
41+
return begin(cfg);
3742
}
3843

3944
/// stops the I2C and unistalls the driver

src/AudioI2S/I2SStream.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class I2S : public I2SBase {
3434
end();
3535
}
3636

37-
void begin(I2SConfig cfg) {
37+
bool begin(I2SConfig cfg) {
3838
LOGD(LOG_METHOD);
3939
// define bits per sampe from data type
4040
cfg.bits_per_sample = sizeof(T) * 8;
41-
I2SBase::begin(cfg);
41+
return I2SBase::begin(cfg);
4242
}
4343

4444
/// writes the data to the I2S interface
@@ -83,6 +83,10 @@ class I2SStream : public AudioStream {
8383
return i2s.defaultConfig(mode);
8484
}
8585

86+
bool begin() {
87+
return i2s.begin();
88+
}
89+
8690
/// Starts the I2S interface
8791
void begin(I2SConfig cfg) {
8892
LOGD(LOG_METHOD);

0 commit comments

Comments
 (0)