Skip to content

drivers: spi_bitbang: Increase supported word size to 32 bits #80773

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

Merged
merged 1 commit into from
May 31, 2025

Conversation

morsisko
Copy link
Contributor

@morsisko morsisko commented Nov 2, 2024

This change introduces support for words up to 32 bits size for the spi_bitbang driver.

As there is no uint24_t type for words size in range 17-24 bits, it is assumed that uint32_t will be used as a base type for the data buffer (instead of using uint8_t[3] which could introduce issues related to alignment).

For 20 bits word size:
pulseview_2024-11-01_23-49-21

For 32 bits word size:
pulseview_2024-11-01_23-58-24


/* As there is no uint24_t, it is assumed uint32_t will be used as the buffer base type. */
if (data->dfs == 3) {
data->dfs = 4;
Copy link
Collaborator

Choose a reason for hiding this comment

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

that does not sound right, see line 233: you will advance into tx/rx buffers by 4 even for dfs of 3.

So far it seems you can remove that changes, as you anyway coalesce case 3 into case 4 in subsequent switches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see line 233: you will advance into tx/rx buffers by 4 even for dfs of 3
Yes, this is intended. Removing that line would force users to use uint24_t (which doesn't exist in zephyr, so probably uint8_t[3] would be required as a base type for the buffer). Not sure this is best idea, as for some platforms it could cause issues regarding misalignment.

If you wish, I can change it, but I believe some hardware implementations accepts 4 bytes input, even when the dfs is 3, to avoid the misalignment mentioned above.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nevermind, your explanation makes sense

@morsisko morsisko requested a review from tbursztyka December 21, 2024 17:03
This change introduces support for words up to 32 bits size
to the spi_bitbang driver

Signed-off-by: Michal Morsisko <[email protected]>
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 Feb 21, 2025
@morsisko
Copy link
Contributor Author

morsisko commented Mar 5, 2025

bump to remove stale label

@github-actions github-actions bot removed the Stale label Mar 5, 2025
Copy link

github-actions bot commented May 4, 2025

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 May 4, 2025
@morsisko
Copy link
Contributor Author

comment to remove stale label

@github-actions github-actions bot removed the Stale label May 11, 2025
@nashif nashif merged commit e87e054 into zephyrproject-rtos:main May 31, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: SPI SPI bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants