From 963c157bc5af4b2a0940a0bca2b2c309c5ad4f19 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Sun, 3 Aug 2014 18:01:55 +0200 Subject: [PATCH] Make sure that we send out empty bytes when receiving multiple bytes Also fixed some comments --- usbhost.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usbhost.h b/usbhost.h index e489da62..31c0e128 100644 --- a/usbhost.h +++ b/usbhost.h @@ -236,7 +236,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) { SPI_SS::Set(); #elif USING_SPI4TEENSY3 spi4teensy3::send(reg); - uint8_t rv = spi4teensy3::receive(); // Send empty byte + uint8_t rv = spi4teensy3::receive(); SPI_SS::Set(); #else SPDR = reg; @@ -266,6 +266,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* #if SPI_HAS_TRANSACTION SPI.transfer(reg); + memset(data_p, 0, nbytes); // Make sure we send out empty bytes SPI.transfer(data_p, nbytes); data_p += nbytes; #elif USING_SPI4TEENSY3 @@ -282,7 +283,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* SPDR = reg; while(!(SPSR & (1 << SPIF))); //wait while(nbytes) { - SPDR = 0; //send empty byte + SPDR = 0; // Send empty byte nbytes--; while(!(SPSR & (1 << SPIF))); #if 0