@@ -257,13 +257,13 @@ bool shared_module_bitbangio_spi_transfer(bitbangio_spi_obj_t *self, const uint8
257257 for (size_t i = 0 ; i < len ; ++ i ) {
258258 uint8_t data_out = dout [i ];
259259 uint8_t data_in = 0 ;
260- for (int j = 0 ; j < 8 ; ++ j , data_out <<= 1 ) {
261- common_hal_digitalio_digitalinout_set_value (& self -> mosi , (data_out >> 7 ) & 1 );
262- common_hal_digitalio_digitalinout_set_value (& self -> clock , 1 - self -> polarity );
263- data_in = (data_in << 1 ) | common_hal_digitalio_digitalinout_get_value (& self -> miso );
264- common_hal_digitalio_digitalinout_set_value (& self -> clock , self -> polarity );
265- }
266- din [i ] = data_in ;
260+ for (int j = 0 ; j < 8 ; ++ j , data_out <<= 1 ) {
261+ common_hal_digitalio_digitalinout_set_value (& self -> mosi , (data_out >> 7 ) & 1 );
262+ common_hal_digitalio_digitalinout_set_value (& self -> clock , 1 - self -> polarity );
263+ data_in = (data_in << 1 ) | common_hal_digitalio_digitalinout_get_value (& self -> miso );
264+ common_hal_digitalio_digitalinout_set_value (& self -> clock , self -> polarity );
265+ }
266+ din [i ] = data_in ;
267267
268268 if (dest != NULL ) {
269269 dest [i ] = data_in ;
@@ -279,20 +279,20 @@ bool shared_module_bitbangio_spi_transfer(bitbangio_spi_obj_t *self, const uint8
279279 for (int j = 0 ; j < 8 ; ++ j , data_out <<= 1 ) {
280280 common_hal_digitalio_digitalinout_set_value (& self -> mosi , (data_out >> 7 ) & 1 );
281281 if (self -> phase == 0 ) {
282- common_hal_mcu_delay_us (delay_half );
283- common_hal_digitalio_digitalinout_set_value (& self -> clock , 1 - self -> polarity );
284- } else {
285- common_hal_digitalio_digitalinout_set_value (& self -> clock , 1 - self -> polarity );
286- common_hal_mcu_delay_us (delay_half );
287- }
288- data_in = (data_in << 1 ) | common_hal_digitalio_digitalinout_get_value (& self -> miso );
289- if (self -> phase == 0 ) {
290- common_hal_mcu_delay_us (delay_half );
291- common_hal_digitalio_digitalinout_set_value (& self -> clock , self -> polarity );
292- } else {
293- common_hal_digitalio_digitalinout_set_value (& self -> clock , self -> polarity );
294- common_hal_mcu_delay_us (delay_half );
295- }
282+ common_hal_mcu_delay_us (delay_half );
283+ common_hal_digitalio_digitalinout_set_value (& self -> clock , 1 - self -> polarity );
284+ } else {
285+ common_hal_digitalio_digitalinout_set_value (& self -> clock , 1 - self -> polarity );
286+ common_hal_mcu_delay_us (delay_half );
287+ }
288+ data_in = (data_in << 1 ) | common_hal_digitalio_digitalinout_get_value (& self -> miso );
289+ if (self -> phase == 0 ) {
290+ common_hal_mcu_delay_us (delay_half );
291+ common_hal_digitalio_digitalinout_set_value (& self -> clock , self -> polarity );
292+ } else {
293+ common_hal_digitalio_digitalinout_set_value (& self -> clock , self -> polarity );
294+ common_hal_mcu_delay_us (delay_half );
295+ }
296296 }
297297 din [i ] = data_in ;
298298
0 commit comments