@@ -210,6 +210,18 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
210
210
211
211
bool common_hal_busio_spi_configure (busio_spi_obj_t * self ,
212
212
uint32_t baudrate , uint8_t polarity , uint8_t phase , uint8_t bits ) {
213
+
214
+ LPSPI_Enable (self -> spi , false);
215
+ uint32_t tcrPrescaleValue ;
216
+ self -> baudrate = LPSPI_MasterSetBaudRate (self -> spi , baudrate , LPSPI_MASTER_CLK_FREQ , & tcrPrescaleValue );
217
+ LPSPI_Enable (self -> spi , true);
218
+
219
+ if ((polarity == common_hal_busio_spi_get_polarity (self )) &&
220
+ (phase == common_hal_busio_spi_get_phase (self )) &&
221
+ (bits == ((self -> spi -> TCR & LPSPI_TCR_FRAMESZ_MASK ) >> LPSPI_TCR_FRAMESZ_SHIFT )) + 1 ) {
222
+ return true;
223
+ }
224
+
213
225
lpspi_master_config_t config = { 0 };
214
226
LPSPI_MasterGetDefaultConfig (& config );
215
227
@@ -221,11 +233,6 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
221
233
LPSPI_Deinit (self -> spi );
222
234
LPSPI_MasterInit (self -> spi , & config , LPSPI_MASTER_CLK_FREQ );
223
235
224
- LPSPI_Enable (self -> spi , false);
225
- uint32_t tcrPrescaleValue ;
226
- self -> baudrate = LPSPI_MasterSetBaudRate (self -> spi , config .baudRate , LPSPI_MASTER_CLK_FREQ , & tcrPrescaleValue );
227
- LPSPI_Enable (self -> spi , true);
228
-
229
236
return true;
230
237
}
231
238
0 commit comments