Skip to content

Commit 9d5e6a2

Browse files
committed
house clean up
1 parent 03bfda3 commit 9d5e6a2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/arduino/Adafruit_USBH_Host.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ void tuh_max3421_spi_cs_api(uint8_t rhport, bool active) {
202202
return;
203203
}
204204
Adafruit_USBH_Host *host = Adafruit_USBH_Host::_instance;
205+
SPIClass *spi = host->_spi;
205206

206207
if (active) {
207208
// MAX3421e max clock is 26MHz
@@ -213,10 +214,10 @@ void tuh_max3421_spi_cs_api(uint8_t rhport, bool active) {
213214
uint32_t const max_clock = 26000000ul;
214215
#endif
215216

216-
host->_spi->beginTransaction(SPISettings(max_clock, MSBFIRST, SPI_MODE0));
217+
spi->beginTransaction(SPISettings(max_clock, MSBFIRST, SPI_MODE0));
217218
digitalWrite(Adafruit_USBH_Host::_instance->_cs, LOW);
218219
} else {
219-
host->_spi->endTransaction();
220+
spi->endTransaction();
220221
digitalWrite(Adafruit_USBH_Host::_instance->_cs, HIGH);
221222
}
222223
}
@@ -229,6 +230,7 @@ bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const *tx_buf,
229230
return false;
230231
}
231232
Adafruit_USBH_Host *host = Adafruit_USBH_Host::_instance;
233+
SPIClass *spi = host->_spi;
232234

233235
#ifdef ARDUINO_ARCH_SAMD
234236
// SAMD cannot use transfer(tx_buf, rx_buf, len) API since it default to use
@@ -240,16 +242,16 @@ bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const *tx_buf,
240242
if (tx_buf) {
241243
data = tx_buf[count];
242244
}
243-
data = host->_spi->transfer(data);
245+
data = spi->transfer(data);
244246

245247
if (rx_buf) {
246248
rx_buf[count] = data;
247249
}
248250
}
249251
#elif defined(ARDUINO_ARCH_ESP32)
250-
host->_spi->transferBytes(tx_buf, rx_buf, xfer_bytes);
252+
spi->transferBytes(tx_buf, rx_buf, xfer_bytes);
251253
#else
252-
host->_spi->transfer(tx_buf, rx_buf, xfer_bytes);
254+
spi->transfer(tx_buf, rx_buf, xfer_bytes);
253255
#endif
254256

255257
return true;

0 commit comments

Comments
 (0)