-
Couldn't load subscription status.
- Fork 8.1k
drivers: spi_ll_stm32: Enable SPI driver for F1 family #5413
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
5b9fdb1 to
9c62b21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that SPI related? If the interrupt driver requires CONFIG_POLL=y, maybe it should select it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copy/paste some CONFIG_* from the spi_loopback prj.conf and forget to remove it. I will fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't master NSS be output push pull?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to RM0008 NSS can be configured as
Hardware master /slave -> Input floating/ Input pull-up / Input pull-down
Hardware master/ NSS output enabled -> Alternate function push-pull
Software -> Not used. Can be used as a GPIO
I just added the first option to support multi master bus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this part is a bit tricky, it might be worse adding some comments.
You could also provide definitions for NSS output enabled, even if not used.
It might help user to understand what he need.
Exact reference to User manual (§25.3.1: Slave select (NSS) pin management) would also help.
drivers/spi/spi_ll_stm32.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this remain outside the new if statement, instead of moving inside? Similar questions below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it should but it broke spi_loopback test. If the spi_context_update_rx() is not called, it will never move to the second rx_buf. I still try to understand why we use a null rx_buf in spi_loopback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to move spi_context_update_rx() inside if and push another commit which will substitute null rx_bufs with dummy_rx_bufs in spi_loopback test. How does that sound to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, so the .buf = NULL inside of the rx_bufs definitions (like in spi_rx_half_end()) in the spi_loopback test is breaking things, you mean?
If so, perhaps this is a bug in the SPI core? Haven't had time to look into it in detail, just to be clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, so the .buf = NULL inside of the rx_bufs definitions (like in spi_rx_half_end()) in the spi_loopback test is breaking things, you mean?
Yes, it causes bus error on some SoCs (e.g. stm32f103, stm32f334).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your response!
@tbursztyka, could the test possibly be structuring its buffers incorrectly from what you meant?
If not, perhaps this is a bug in the STM32 area.
9c62b21 to
596bd63
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for docs
c142511 to
8577922
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments otherwise looks good
drivers/spi/spi_ll_stm32.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using && data->ctx.rx_buf as you did for tx?
It makes both change and code lighter.
I guess this is a leftover from initial commit. Latest code allows you to do it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it.
drivers/spi/spi_ll_stm32.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it.
drivers/spi/spi_ll_stm32.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it.
drivers/spi/spi_ll_stm32.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this part is a bit tricky, it might be worse adding some comments.
You could also provide definitions for NSS output enabled, even if not used.
It might help user to understand what he need.
Exact reference to User manual (§25.3.1: Slave select (NSS) pin management) would also help.
8577922 to
4ffb815
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erwango Is this clear enough? STM32_PIN_SPI_MASTER_NSS_OUTPUT_ENABLED is too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is fine, thanks
4ffb815 to
1326a41
Compare
|
recheck |
|
(FTR, my questions on this PR are all addressed. Not adding a +1 as I haven't looked at it in detail) |
|
All this NULL buffers should be clarified, apart from that it's OK for me. |
|
I'd like to have @tbursztyka review the changes around these NULL buffers check, the spi loopback test is running correctly on F0, L4 and F4. |
ee5b12f to
f95e5fd
Compare
Codecov Report
@@ Coverage Diff @@
## master #5413 +/- ##
==========================================
- Coverage 54.46% 51.29% -3.17%
==========================================
Files 458 441 -17
Lines 43413 42268 -1145
Branches 8307 8063 -244
==========================================
- Hits 23644 21683 -1961
- Misses 19628 20066 +438
- Partials 141 519 +378
Continue to review full report at Codecov.
|
|
it's not working for me.
Problem seems to be, that |
|
@dwagenk Could you try it again? It should be fixed now. |
|
@ydamigos it's working now. Thanks |
ext/hal/st/stm32cube/CMakeLists.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary anymore after PR #4646 is merged. Works for me without.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
I rebased it to resolve some conflicts. |
Enables SPI driver for STM32F1 SoCs Signed-off-by: Yannis Damigos <[email protected]>
Enable SPI1 port on olimexino_stm32. Signed-off-by: Yannis Damigos <[email protected]>
TX/RX buffer may be NULL, so check them before use. Signed-off-by: Yannis Damigos <[email protected]>
|
Now that PR #5785 is merged, I rebased it against master and removed the DNM flag. Please review it again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ok on nucleo_f103rb
|
@dwagenk still have issues with this? |
|
no, ydamigos solved those problems right away!
|
Enables SPI driver for STM32F1 SoCs.
Tested on olimexino_stm32 using spi_loopback test.
Fixes #1281 and #3850.