Skip to content
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

drivers:platform:stm32: Update SPI desc frequency with configured frequency #2392

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion drivers/platform/stm32/stm32_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,41 @@ static int stm32_spi_config(struct no_os_spi_desc *desc)
switch (div) {
case 0 ... 2:
prescaler = SPI_BAUDRATEPRESCALER_2;
desc->max_speed_hz = sdesc->input_clock / 2;
Copy link
Contributor

@buha buha Dec 13, 2024

Choose a reason for hiding this comment

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

hmmm, to be honest i think here it'd be better to keep both, max_speed_hz is the requested maximum speed and there could be an actual_speed_hz with the computed one

i don't think the proposed change is good as it is, either we drop it or we implement both if you really want this info in the desc but this would imply that we populate actual_speed_hz on all platforms

break;
case 3 ... 4:
prescaler = SPI_BAUDRATEPRESCALER_4;
desc->max_speed_hz = sdesc->input_clock / 4;
break;
case 5 ... 8:
prescaler = SPI_BAUDRATEPRESCALER_8;
desc->max_speed_hz = sdesc->input_clock / 8;
break;
case 9 ... 16:
prescaler = SPI_BAUDRATEPRESCALER_16;
desc->max_speed_hz = sdesc->input_clock / 16;
break;
case 17 ... 32:
prescaler = SPI_BAUDRATEPRESCALER_32;
desc->max_speed_hz = sdesc->input_clock / 32;
break;
case 33 ... 64:
prescaler = SPI_BAUDRATEPRESCALER_64;
desc->max_speed_hz = sdesc->input_clock / 64;
break;
case 65 ... 128:
prescaler = SPI_BAUDRATEPRESCALER_128;
desc->max_speed_hz = sdesc->input_clock / 128;
break;
default:
prescaler = SPI_BAUDRATEPRESCALER_256;
desc->max_speed_hz = sdesc->input_clock / 256;
break;
}
} else
} else {
prescaler = SPI_BAUDRATEPRESCALER_64;
desc->max_speed_hz = sdesc->input_clock / 64;
}

switch (desc->device_id) {
#if defined(SPI1)
Expand Down