drivers: spi_mcux_lpspi: fix baudrate change when switching devices
When configuring an LPSPI module for a new device with different baud rate, the module needs to be disabled for the baud rate change to take effect. This adds the necessary call to LPSPI_Enable before initializing the module. Fixes #51177 Signed-off-by: Jonas Otto <jonas@jonasotto.com>
This commit is contained in:
parent
ffed8388e7
commit
d3415e2ce1
1 changed files with 9 additions and 0 deletions
|
@ -226,6 +226,15 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Setting the baud rate in LPSPI_MasterInit requires module to be disabled */
|
||||
LPSPI_Enable(base, false);
|
||||
while ((base->CR & LPSPI_CR_MEN_MASK) != 0U) {
|
||||
/* Wait until LPSPI is disabled. Datasheet:
|
||||
* After writing 0, MEN (Module Enable) remains set until the LPSPI has completed
|
||||
* the current transfer and is idle.
|
||||
*/
|
||||
}
|
||||
|
||||
LPSPI_MasterInit(base, &master_config, clock_freq);
|
||||
|
||||
LPSPI_MasterTransferCreateHandle(base, &data->handle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue