@@ -489,9 +489,8 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_master_trans(spi_host_t host, spi_
489
489
SPI [host ]-> data_buf [y ] = trans -> mosi [y ];
490
490
}
491
491
} else {
492
- ESP_LOGW (TAG ,"Using unaligned data may reduce transmission efficiency" );
493
- memset (spi_object [host ]-> buf , 0 , sizeof (uint32_t ) * 16 );
494
- memcpy (spi_object [host ]-> buf , trans -> mosi , trans -> bits .mosi / 8 + (trans -> bits .mosi % 8 ) ? 1 : 0 );
492
+ memcpy (spi_object [host ]-> buf , trans -> mosi , trans -> bits .mosi / 8 + ((trans -> bits .mosi % 8 ) ? 1 : 0 ));
493
+
495
494
for (x = 0 ; x < trans -> bits .mosi ; x += 32 ) {
496
495
y = x / 32 ;
497
496
SPI [host ]-> data_buf [y ] = spi_object [host ]-> buf [y ];
@@ -522,19 +521,17 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_master_trans(spi_host_t host, spi_
522
521
if (trans -> bits .miso && trans -> miso ) {
523
522
while (SPI [host ]-> cmd .usr );
524
523
525
- if ((uint32_t )(trans -> miso ) % 4 == 0 ) {
524
+ if ((uint32_t )(trans -> miso ) % 4 == 0 && trans -> bits . miso % 32 == 0 ) {
526
525
for (x = 0 ; x < trans -> bits .miso ; x += 32 ) {
527
526
y = x / 32 ;
528
527
trans -> miso [y ] = SPI [host ]-> data_buf [y ];
529
528
}
530
529
} else {
531
- ESP_LOGW (TAG ,"Using unaligned data may reduce transmission efficiency" );
532
- memset (spi_object [host ]-> buf , 0 , sizeof (uint32_t ) * 16 );
533
530
for (x = 0 ; x < trans -> bits .miso ; x += 32 ) {
534
531
y = x / 32 ;
535
532
spi_object [host ]-> buf [y ] = SPI [host ]-> data_buf [y ];
536
533
}
537
- memcpy (trans -> miso , spi_object [host ]-> buf , trans -> bits .miso / 8 + (trans -> bits .miso % 8 ) ? 1 : 0 );
534
+ memcpy (trans -> miso , spi_object [host ]-> buf , trans -> bits .miso / 8 + (( trans -> bits .miso % 8 ) ? 1 : 0 ) );
538
535
}
539
536
}
540
537
@@ -577,7 +574,7 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_slave_trans(spi_host_t host, spi_t
577
574
} else {
578
575
ESP_LOGW (TAG ,"Using unaligned data may reduce transmission efficiency" );
579
576
memset (spi_object [host ]-> buf , 0 , sizeof (uint32_t ) * 16 );
580
- memcpy (spi_object [host ]-> buf , trans -> miso , trans -> bits .miso / 8 + (trans -> bits .miso % 8 ) ? 1 : 0 );
577
+ memcpy (spi_object [host ]-> buf , trans -> miso , trans -> bits .miso / 8 + (( trans -> bits .miso % 8 ) ? 1 : 0 ) );
581
578
for (x = 0 ; x < trans -> bits .miso ; x += 32 ) {
582
579
y = x / 32 ;
583
580
SPI [host ]-> data_buf [y ] = spi_object [host ]-> buf [y ];
@@ -599,7 +596,7 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_slave_trans(spi_host_t host, spi_t
599
596
y = x / 32 ;
600
597
spi_object [host ]-> buf [y ] = SPI [host ]-> data_buf [y ];
601
598
}
602
- memcpy (trans -> mosi , spi_object [host ]-> buf , trans -> bits .mosi / 8 + (trans -> bits .mosi % 8 ) ? 1 : 0 );
599
+ memcpy (trans -> mosi , spi_object [host ]-> buf , trans -> bits .mosi / 8 + (( trans -> bits .mosi % 8 ) ? 1 : 0 ) );
603
600
}
604
601
}
605
602
0 commit comments