Skip to content

Commit db4d3e0

Browse files
pablo-mendozaigrr
authored andcommitted
Free memory we allocated and actually stop i2s. (#3191)
1 parent af0f5ed commit db4d3e0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cores/esp8266/core_esp8266_i2s.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ void ICACHE_FLASH_ATTR i2s_slc_end(){
146146
SLCIE = 0;
147147
SLCTXL &= ~(SLCTXLAM << SLCTXLA); // clear TX descriptor address
148148
SLCRXL &= ~(SLCRXLAM << SLCRXLA); // clear RX descriptor address
149+
150+
for (int x = 0; x<SLC_BUF_CNT; x++) {
151+
free(i2s_slc_buf_pntr[x]);
152+
}
149153
}
150154

151155
//This routine pushes a single, 32-bit sample to the I2S buffers. Call this at (on average)
@@ -238,8 +242,16 @@ void ICACHE_FLASH_ATTR i2s_begin(){
238242
}
239243

240244
void ICACHE_FLASH_ATTR i2s_end(){
241-
i2s_slc_end();
245+
I2SC &= ~I2STXS;
246+
247+
//Reset I2S
248+
I2SC &= ~(I2SRST);
249+
I2SC |= I2SRST;
250+
I2SC &= ~(I2SRST);
251+
242252
pinMode(2, INPUT);
243253
pinMode(3, INPUT);
244254
pinMode(15, INPUT);
255+
256+
i2s_slc_end();
245257
}

0 commit comments

Comments
 (0)