Merge pull request #4474 from jepler/fix-spi-frequency

mimxrt: SPI: Set the TCR value returned by MasterBaudSetRate
This commit is contained in:
Scott Shawcroft 2021-03-25 08:59:21 -07:00 committed by GitHub
commit e9ceb9263e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -187,6 +187,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
LPSPI_Enable(self->spi, false); LPSPI_Enable(self->spi, false);
uint32_t tcrPrescaleValue; uint32_t tcrPrescaleValue;
self->baudrate = LPSPI_MasterSetBaudRate(self->spi, config.baudRate, LPSPI_MASTER_CLK_FREQ, &tcrPrescaleValue); self->baudrate = LPSPI_MasterSetBaudRate(self->spi, config.baudRate, LPSPI_MASTER_CLK_FREQ, &tcrPrescaleValue);
self->spi->TCR = (self->spi->TCR & ~LPSPI_TCR_PRESCALE_MASK) | LPSPI_TCR_PRESCALE(tcrPrescaleValue);
LPSPI_Enable(self->spi, true); LPSPI_Enable(self->spi, true);
claim_pin(self->clock->pin); claim_pin(self->clock->pin);
@ -236,6 +237,7 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
LPSPI_Enable(self->spi, false); LPSPI_Enable(self->spi, false);
uint32_t tcrPrescaleValue; uint32_t tcrPrescaleValue;
self->baudrate = LPSPI_MasterSetBaudRate(self->spi, baudrate, LPSPI_MASTER_CLK_FREQ, &tcrPrescaleValue); self->baudrate = LPSPI_MasterSetBaudRate(self->spi, baudrate, LPSPI_MASTER_CLK_FREQ, &tcrPrescaleValue);
self->spi->TCR = (self->spi->TCR & ~LPSPI_TCR_PRESCALE_MASK) | LPSPI_TCR_PRESCALE(tcrPrescaleValue);
LPSPI_Enable(self->spi, true); LPSPI_Enable(self->spi, true);
if ((polarity == common_hal_busio_spi_get_polarity(self)) && if ((polarity == common_hal_busio_spi_get_polarity(self)) &&