8000 esp32/machine_i2s: Integrate new I2S IDF driver. by miketeachman · Pull Request #13727 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

esp32/machine_i2s: Integrate new I2S IDF driver. #13727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

miketeachman
Copy link
Contributor

The legacy I2S "shim" is removed and replaced by the new I2S driver. The new driver fixes a bug where mono audio plays only in one channel.
Application code size is reduced by 2672 bytes with this change. Tested on ESP32, ESP32+spiram, ESP32-S3 using example code from https://github.com/miketeachman/micropython-i2s-examples

Copy link
codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (4dc262c) to head (0b145fd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #13727   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files         161      161           
  Lines       21078    21078           
=======================================
  Hits        20739    20739           
  Misses        339      339           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@ricksorensen
Copy link
Contributor

Thanks -

Just tried this with SEEED XIAO ESP32-C3 - and it works. I ran your easy_wav_player using your mono and stereo wav files pulled from the local memory (so only 16-bit versions). I used pcm5102 for I2S to audio out.

@miketeachman
Copy link
Contributor Author

@ricksorensen Fantastic ! Thank you for testing this PR.

@@ -600,6 +600,7 @@ STATIC mp_uint_t machine_i2s_stream_write(mp_obj_t self_in, const void *buf_in,

return size;
} else { // blocking or asyncio mode

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this blank line can be removed, to keep coding style consistent (eg with the "if" part of this statement).

@@ -623,6 +625,7 @@ STATIC mp_uint_t machine_i2s_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_

if (flags & MP_STREAM_POLL_RD) {
if (self->mode != MICROPY_PY_MACHINE_I2S_CONSTANT_RX) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This blank line can go.

}
#endif
}

if (flags & MP_STREAM_POLL_WR) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line.

}
#endif
}
} else {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line.

// indicating that audio samples can be written to the I2S object
ret |= MP_STREAM_POLL_WR;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line.

.on_send_q_ovf = NULL,
};


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one blank line needed here (for consistency with the rest of this file)

}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line not needed

@dpgeorge
Copy link
Member

Thanks for this, it looks good!

I think the line CONFIG_I2S_SUPPRESS_DEPRECATE_WARN can now be removed from esp32/boards/sdkconfig.base.

@miketeachman
Copy link
Contributor Author

@dpgeorge thanks for reviewing this PR. I removed all the unnecessary blank lines. The macro could be removed after I included the header file for the new driver.

@projectgus
Copy link
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

@dpgeorge
Copy link
Member
dpgeorge commented Mar 8, 2024

I'm currently rebasing this on latest master and about to merge it.

The legacy I2S "shim" is removed and replaced by the new I2S driver.  The
new driver fixes a bug where mono audio plays only in one channel.

Application code size is reduced by 2672 bytes with this change.  Tested on
ESP32, ESP32+spiram, ESP32-S3 using example code from
https://github.com/miketeachman/micropython-i2s-examples

Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
@dpgeorge dpgeorge force-pushed the i2s-esp-mono-fix-pr-dec-2023 branch from 7ed5b34 to 0b145fd Compare March 8, 2024 02:33
@dpgeorge dpgeorge merged commit 0b145fd into micropython:master Mar 8, 2024
@ricksorensen ricksorensen mentioned this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0