Skip to content
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

Support claiming unused SM/channels for audio #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Daft-Freak
Copy link
Contributor

Uses a dma_channel/pio_sm of 0xFF to mean "claim unused". (Considered changing the configs to signed and/or adding some defines, but thought I should try the smallest change first...)

This change was motivated by finding that I'd written this in a project:

uint8_t dma_channel = dma_claim_unused_channel(true);
uint8_t pio_sm = pio_claim_unused_sm(audio_pio, true);

dma_channel_unclaim(dma_channel);
pio_sm_unclaim(audio_pio, pio_sm);

struct audio_i2s_config config = {
  .data_pin = PICO_AUDIO_I2S_DATA_PIN,
  .clock_pin_base = PICO_AUDIO_I2S_CLOCK_PIN_BASE,
  .dma_channel = dma_channel,
  .pio_sm = pio_sm,
};

Ugh.

@Gadgetoid
Copy link

Oh hello, I have written this same code 😆

https://github.com/Gadgetoid/pico-tinyusb-i2s-speaker/blob/28b0c9a034615d38c22e05df83c8f74009fd0f85/src/i2s_audio.c#L42-L46

Probably borrowed the idea from you.

@MichaelBell
Copy link
Contributor

+1 for this. Or I would support just removing them from the config entirely and always claiming - it's a pretty small change to existing projects that would also flag for people to remove their workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants