Skip to content

drivers: spi: stm32 half duplex support #75983

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

vai-rikar
Copy link
Contributor

@vai-rikar vai-rikar commented Jul 17, 2024

Add support for SPI_HALF_DUPLEX flag for STM32 SPI driver. Tested with stm32u575 with and without CONFIG_SPI_STM32_INTERRUPT, and with DMA.

Fixes #49446

@zephyrbot zephyrbot added area: SPI SPI bus platform: STM32 ST Micro STM32 labels Jul 17, 2024
@vai-rikar vai-rikar force-pushed the drivers-spi-stm32-half-duplex-support branch from 09a376e to fb33044 Compare July 17, 2024 13:24
@vai-rikar vai-rikar marked this pull request as draft July 18, 2024 05:51
@vai-rikar vai-rikar force-pushed the drivers-spi-stm32-half-duplex-support branch from fb33044 to 8f10035 Compare July 18, 2024 06:19
@vai-rikar vai-rikar marked this pull request as ready for review July 18, 2024 08:54
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Sep 17, 2024
@erwango erwango removed the Stale label Sep 17, 2024
@erwango
Copy link
Member

erwango commented Sep 17, 2024

I'm quite late to answer but thanks for this work, we'll review in coming weeks

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Nov 17, 2024
@erwango erwango removed the Stale label Nov 27, 2024
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for very late review.

Looks sane a priori. I didn't fully completed the review, but some comments.

I have 2 requests:

  • Would you mind rebasing (even if there is no conflicts), because I'd like to perform some testing on our test farm but this require to be in recent main due to recent ci changes in twister.
  • Any way we can excercise this code in CI ?

@vai-rikar vai-rikar force-pushed the drivers-spi-stm32-half-duplex-support branch from 8f10035 to 84fdaa0 Compare December 2, 2024 10:41
Add support for SPI_HALF_DUPLEX flag for STM32 SPI driver

Signed-off-by: Riku Karjalainen <[email protected]>
@vai-rikar vai-rikar force-pushed the drivers-spi-stm32-half-duplex-support branch from 84fdaa0 to dea9858 Compare December 3, 2024 10:56
@vai-rikar
Copy link
Contributor Author

Thanks for the review and comments.

  • Would you mind rebasing (even if there is no conflicts), because I'd like to perform some testing on our test farm but this require to be in recent main due to recent ci changes in twister.

Rebase done and fixed the issues mentioned.

  • Any way we can excercise this code in CI ?

Would be great if there were tests for this in CI. I'm not sure how this should be done and unfortunately I don't have time to looking into it in the next couple of months.

} else if (transfer_dir == LL_SPI_HALF_DUPLEX_TX) {
spi_context_update_tx(&data->ctx, frame_size_bytes, dma_len);
} else {
spi_context_update_rx(&data->ctx, frame_size_bytes, dma_len);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any possible value for transfer_dir than LL_SPI_HALF_DUPLEX_RX
maybe with
if (transfer_dir == LL_SPI_HALF_DUPLEX_RX) {
before the else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently transfer direction is set only to LL_SPI_FULL_DUPLEX, LL_SPI_HALF_DUPLEX_TX or LL_SPI_HALF_DUPLEX_RX. So LL_SPI_HALF_DUPLEX_RX is the only possibility in the else branch. I see that there are LL_SPI_SIMPLEX_TX/RX (stm32h7xx_ll_spi.h) definitions also but those are currently not used.

I can change this if you like, but there are multiple places where the if is omitted from the else branch.

@kartben
Copy link
Collaborator

kartben commented Dec 18, 2024

@FRASTM are you able to actually go as far as giving a +1 to move this forward?

@kartben
Copy link
Collaborator

kartben commented Jan 9, 2025

Ping @FRASTM

@kartben kartben merged commit 5011eba into zephyrproject-rtos:main Jan 9, 2025
25 checks passed
@vai-rikar vai-rikar deleted the drivers-spi-stm32-half-duplex-support branch January 28, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: SPI SPI bus platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STM32 SPI Set transfer direction is fixed
5 participants