piolib/i2s: fix the left and right channel comments - #63
Open
deadprogram wants to merge 1 commit into
Open
deadprogram wants to merge 1 commit into
deadprogram wants to merge 1 commit into
Conversation
The comments said LRCLK=1 is the left channel. In the Philips I2S bus specification LRCLK=0 is the left channel. The program sends bits 31 to 16 while LRCLK=1, so the low half of each WriteStereo frame is the left sample. The code does not change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the comments in the I2S program. They said LRCLK=1 is the left channel, but in the Philips I2S bus specification LRCLK=0 is the left channel and LRCLK=1 is the right channel.
The code does not change. The program shifts MSB first and starts at the entry point with LRCLK=1. So bits 31 to 16 of each frame go out while LRCLK=1, which is the right channel, and bits 15 to 0 go out while LRCLK=0, which is the left channel. Each loop sends its last bit one clock after LRCLK changes, as I2S requires.
This PR also documents that WriteStereo takes the left sample in the low half of each frame. The new I2S drivers for nRF52 (tinygo-org/tinygo#5786) and esp32xx (tinygo-org/tinygo#5787) use the same layout, and both were checked by ear on a PCM5102 DAC.
The pio I2S example builds for the pico. I did not test this change on RP2040 hardware, because only comments change.