Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Patch, SPI.transfer16()#2524

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
drmcnelson wants to merge2 commits intostm32duino:main
base:main
Choose a base branch
Loading
fromdrmcnelson:main
Draft

Conversation

@drmcnelson
Copy link

@drmcnelsondrmcnelson commentedSep 23, 2024
edited by fpistm
Loading

Implement SPI.transfer16() as a true 16 bit transfer

Implement SPI.transfer16() as a true 16 bit transferSigned-off-by: Dr M <drmcnelson@gmail.com>
@uzi18
Copy link

Why did you removeddefined(STM32U0xx) ?

@drmcnelson
Copy link
Author

Actually, I did not remove it either.

It was not in my version of that file. I will make the correction.

Correction,  defined(STM32U0xx)Signed-off-by: Dr M <drmcnelson@gmail.com>
@fpistmfpistm self-requested a reviewOctober 20, 2025 12:25
@stm32duinostm32duino deleted a comment fromuzi18Oct 21, 2025
@fpistm
Copy link
Member

Hi@drmcnelson
Sorry for the delay looking at this PR.

In fact there is a mistake. UsingLL_SPI_TransmitData16is not enough to properly transfer 16bit.

handle->Init.DataSize=SPI_DATASIZE_8BIT;

It requires to configure the data size toSPI_DATASIZE_16BIT.

So it should require to manage it.
Several way:

  1. Adding below code inspi_transfer16 (same for thespi_transfer withLL_SPI_DATAWIDTH_8BIT
if (LL_SPI_GetDataWidth(_SPI)!=LL_SPI_DATAWIDTH_16BIT) {/* Change data width to 16 bit */LL_SPI_Disable(_SPI);LL_SPI_SetDataWidth(_SPI,LL_SPI_DATAWIDTH_16BIT);LL_SPI_Enable(_SPI);  }

This add at least 1 check per transfer.

  1. Kept transfer16 as it is and add a 2 new API, one to change the size and one to callLL_SPI_TransmitData16.

  2. Add an API to change the data size before calling thetransfer16 but this will break all Arduino sketches.

  3. maybe other way...

@drmcnelson
Copy link
Author

@fpistm Wonderful, thank you, and thank for you looking at it.

How about a variable transfer size? Some ADCs are 18 bit (or larger) and some are daisy-chainable, so that transfers could be several times 18 bits (or larger). I have been doing this by hand for an acoustic imaging array, but with the new world of 32 bit processors and higher precision preripherals, maybe it's time to upgrade the SPI interface for everybody.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fpistmfpistmAwaiting requested review from fpistm

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@drmcnelson@uzi18@fpistm

[8]ページ先頭

©2009-2025 Movatter.jp