Skip to content

Draft: I2S HAL implementation (for embedded-hal v1.x) #145

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

Closed
wants to merge 2 commits into from

Conversation

maxekman
Copy link

@maxekman maxekman commented Apr 28, 2020

This is a WIP and possible reference implementation for the embedded-hal proposal for a I2S interface: rust-embedded/embedded-hal#204

Not ready for review, left here in the open for comments and opinions.

Builds on #144 to be compatible with the HAL proposal https://github.com/eldruin/embedded-hal/tree/i2s, which is based on the master branch of embedded-hal.

  • Fully support all devices with the macro system.
  • Support possible second I2SPPL clock source in some devices (I think).
  • Calculate viable audio clock frequencies. A bit tricky because the calculation is spread out between the RCC and I2S setup, they both have mult and div settings that have to play together to achieve the correct final MCKL out.
  • Provide example, can be copied from the stm32f407-disc crate when done.
  • Configurable I2S standard (Philips, right, left etc) and bit depth.

@maxekman maxekman changed the title I2S HAL implementation Draft: I2S HAL implementation Apr 28, 2020
@maxekman maxekman force-pushed the i2s branch 3 times, most recently from 4bc2048 to b9ec85e Compare April 30, 2020 11:05
@maxekman maxekman changed the title Draft: I2S HAL implementation Draft: I2S HAL implementation (for embedded-hal v1.x) May 14, 2020
@maxekman maxekman force-pushed the i2s branch 2 times, most recently from 13add4e to 832d610 Compare September 13, 2020 21:06
@YruamaLairba
Copy link
Contributor

I written a message here ? where is it ? i was saying i'm interested by your i2s work.

why it doesn't progress anymore ? because the i2s clock abstraction is near impossible to design ?

@maxekman
Copy link
Author

@YruamaLairba Not sure where your other messages are, but I did see the email notification a while back. I have unfortunately not had time to work on this lately. I agree that the clock interface is tricky (or near impossible) but have not yet given it much thought. I have only worked on the actual HAL implementation, not the setup code.

bors bot added a commit that referenced this pull request Apr 15, 2021
265: Add I2S communication using SPI peripherals r=therealprof a=samcrow

# Introduction

Welcome to my first large pull request, which adds support for I2S audio communication using supported SPI peripherals. Like the way we support CAN with the bxcan library, I am proposing to support I2S using my [stm32_i2s_v12x](https://crates.io/crates/stm32_i2s_v12x) library.

Although stm32_i2s_v12x is in a separate repository, we can also talk about it here.

# Notes

* The I2S module is available if the `i2s` feature is enabled, in order to not increase compile time for applications that don't use I2S.
* All four modes are supported: master transmit, master receive, slave transmit, and slave receive.
* Basic support for DMA, interrupts, and error detection is provided.
* All STM32F4 models are supported.
* I added two examples that run on the STM32F411E-DISCO board and send audio to the on-board DAC. One of them uses DMA.

These changes are not perfect, so criticism and suggestions are welcome.

# Limitations

* No support for full-duplex communication
* I have tested master transmit mode fairly thoroughly, but have not tested the other modes.
* No support for embedded-hal I2S traits
  * [The I2S pull request](rust-embedded/embedded-hal#204) is still under review. The proposed traits look compatible with this driver code. Until that pull request gets merged and released, people can still use this driver code directly.

# Related work

* SAI driver pull request in this repository: #248
* Another, less complete, pull request for I2S in this repository: #212
  * also #145
* embedded-hal pull request for I2S traits: rust-embedded/embedded-hal#204 

Co-authored-by: Sam Crow <[email protected]>
Co-authored-by: Sam Crow <[email protected]>
@maxekman
Copy link
Author

I'll close this as @samcrow has merged I2S support. Thanks for finishing it!

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.

2 participants