esp32/machine_spi: Calculate actual attained baudrate.
Calculate the actual baudrate that the hardware is capable of achieving and remember it so that printing the SPI object will show this. Fixes #7530.
This commit is contained in:
parent
98c5703027
commit
eb3029c669
@ -144,10 +144,14 @@ STATIC void machine_hw_spi_init_internal(
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (baudrate != -1 && baudrate != self->baudrate) {
|
||||
if (baudrate != -1) {
|
||||
// calculate the actual clock frequency that the SPI peripheral can produce
|
||||
baudrate = spi_get_actual_clock(APB_CLK_FREQ, baudrate, 0);
|
||||
if (baudrate != self->baudrate) {
|
||||
self->baudrate = baudrate;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (polarity != -1 && polarity != self->polarity) {
|
||||
self->polarity = polarity;
|
||||
|
Loading…
Reference in New Issue
Block a user