-
Notifications
You must be signed in to change notification settings - Fork 108
Add stm32l4r9 support #270
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
Conversation
3bbea81
to
0cfc616
Compare
After some discussion in the 'stm32-rs' matrix channel, I've decided to keep the manual approach in Please let me know what you think, and where there is still some work. |
Wow, nice one, I'm recalling awful mess w/ DMA registers. Nice to see you fixed this. |
I see the repository has undergone some restructuring causing merge conflicts. |
With the new feature gates this PR makes a much better fit. If you fix it up again I'll merge it :) |
48071f9
to
1f91e6b
Compare
The PR has been rebased to the latest master. fn set_request_line(&mut self, request_line: DmaInput) -> Result<(), Error> The error is only necessary because the |
Hi, I have an STM32L4+ (STM32L4R5ZIY6), https://dev.blues.io/hardware/swan-datasheet/, which I would like to try and get Rust on. Is the difference to the R9 large or could I base differences off this one? Would you mind sharing which board you are using with the R9, if you are on a dev board. Best regards, Gaute |
I don't think the difference should be very large if you get a PAC working for the R5/S5 devices, since they use the same reference manual (https://www.st.com/resource/en/reference_manual/dm00310109.pdf). |
Thanks, yes. I managed to copy over the ADC peripheral and build the adc module as well, that will probably be useful for this MCU aswell. It runs (https://github.com/gauteh/swan-stm32l4r5-quickstart), but haven't tested any peripherals yet. Completely dependent on your work here though, thanks ! Hope it can be merged soon, it seems to work on the R5 at least. |
There seems to be a bunch of differences in the clock controls between L4 and L4+. A presentation with some differences. It would probably be a lot of overlap between R5 and R9 regarding those, perhaps it would be better to work on one PR together? |
That's a good catch. The L4+ functionality does seem to be a superset or the regular L4, so I would think the current implementation also works for the newer devices, but will need to be extended to handle all new use-cases (like running up to 120MHz). Working together to improve L4+ support seems like a great idea. |
The stm32l4+ devices do not have this register, but use a separate peripheral (DMAMUX) for routing between peripherals and DMA controllers.
To make this implementation also usable by stm32l4+ devices, some additional use of `unsafe` is necessary because of PAC differences.
…ror. In the current release of the stm32l4 PAC, the `cnt` register of TIM3 and tim4 have an incorrect width. This was fixed in stm32-rs#669, once this is included in the next release, we will be able to start using TIM3 and TIM4.
The new stm32l4+ devices use a separate peripheral (DMAMUX) for routing a DMA request line between peripherals and DMA controllers, whereas the "old" stm32l4 devices use the `CSELR` register for request mapping. This module tries to abstract this difference, and provides a common interface for all L4 devices. This commit also enable the DMAMUX clock when required.
Good to know. Notably we are limited to 80Mhz for now. Definitely, that is the best. There are still a few questions on getting r5 into the PAC distribution, does not look like it is going to be a problem, but it would delay a joint PR. |
1f91e6b
to
9c789b9
Compare
Hi @korken89, could you let me know if this is suitable for merging? 🙏 |
Hi, I'd like to use this HAL with an STM32L4+ device, more specifically the STM32L4R9.
An
stm32l4r9
feature flag is available in the stm32l4 PAC, and has been added to this crate as well.From my point of view, the main challenge is working around the differences in mapping peripheral requests to DMA channels.
While the "normal" STM32L4 devices use a
CSEL
register, the new STM32L4+ devices have a dedicated DMAMUX peripheral.My idea is to create a unified interface, currently named
set_request_line
(taken from stm32h7xx_hal),which takes as argument the peripheral for the channel (the
PeripheralSelection
enum, which lists all possibilities).However, currently a lot of manual code is required to map this enum to the actual bits that should be used,
which has to be implemented differently for STM32L4 and STM32L4+ devices.
Maybe part of this could be generated from the SVD files.
I would like some feedback about this approach and suggestions for alternatives or ways to improve this.
The main implementation has been done in a new file (dmamux.rs) and uses a trait (
DmaMux
), this is all open to change.Also relates to issue #209 and PR #239. Both of these have been open for a while and seem stale.