Skip to content

Commit 0bd50a4

Browse files
committed
Workaround issue with SPI_HAS_TRANSACTION is just defined and not set to a value in the ESP8266 Arduino core
1 parent 0b3f4d9 commit 0bd50a4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

usbhost.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ template< typename SPI_CLK, typename SPI_MOSI, typename SPI_MISO, typename SPI_S
3939
SPI_SS::SetDirWrite();
4040
SPI_SS::Set();
4141
}
42-
#elif SPI_HAS_TRANSACTION
42+
#elif defined(SPI_HAS_TRANSACTION)
4343
static void init() {
4444
SPI.begin(); // The SPI library with transaction will take care of setting up the pins - settings is set in beginTransaction()
4545
SPI_SS::SetDirWrite();
@@ -154,7 +154,7 @@ MAX3421e< SPI_SS, INTR >::MAX3421e() {
154154
template< typename SPI_SS, typename INTR >
155155
void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
156156
XMEM_ACQUIRE_SPI();
157-
#if SPI_HAS_TRANSACTION
157+
#if defined(SPI_HAS_TRANSACTION)
158158
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
159159
#endif
160160
SPI_SS::Clear();
@@ -164,7 +164,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
164164
c[0] = reg | 0x02;
165165
c[1] = data;
166166
spi4teensy3::send(c, 2);
167-
#elif SPI_HAS_TRANSACTION
167+
#elif defined(SPI_HAS_TRANSACTION)
168168
uint8_t c[2];
169169
c[0] = reg | 0x02;
170170
c[1] = data;
@@ -185,7 +185,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
185185
#endif
186186

187187
SPI_SS::Set();
188-
#if SPI_HAS_TRANSACTION
188+
#if defined(SPI_HAS_TRANSACTION)
189189
SPI.endTransaction();
190190
#endif
191191
XMEM_RELEASE_SPI();
@@ -197,7 +197,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
197197
template< typename SPI_SS, typename INTR >
198198
uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
199199
XMEM_ACQUIRE_SPI();
200-
#if SPI_HAS_TRANSACTION
200+
#if defined(SPI_HAS_TRANSACTION)
201201
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
202202
#endif
203203
SPI_SS::Clear();
@@ -206,7 +206,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
206206
spi4teensy3::send(reg | 0x02);
207207
spi4teensy3::send(data_p, nbytes);
208208
data_p += nbytes;
209-
#elif SPI_HAS_TRANSACTION
209+
#elif defined(SPI_HAS_TRANSACTION)
210210
SPI.transfer(reg | 0x02);
211211
SPI.transfer(data_p, nbytes);
212212
data_p += nbytes;
@@ -238,7 +238,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
238238
#endif
239239

240240
SPI_SS::Set();
241-
#if SPI_HAS_TRANSACTION
241+
#if defined(SPI_HAS_TRANSACTION)
242242
SPI.endTransaction();
243243
#endif
244244
XMEM_RELEASE_SPI();
@@ -260,7 +260,7 @@ void MAX3421e< SPI_SS, INTR >::gpioWr(uint8_t data) {
260260
template< typename SPI_SS, typename INTR >
261261
uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
262262
XMEM_ACQUIRE_SPI();
263-
#if SPI_HAS_TRANSACTION
263+
#if defined(SPI_HAS_TRANSACTION)
264264
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
265265
#endif
266266
SPI_SS::Clear();
@@ -274,7 +274,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
274274
uint8_t rv = 0;
275275
HAL_SPI_Receive(&SPI_Handle, &rv, 1, HAL_MAX_DELAY);
276276
SPI_SS::Set();
277-
#elif !defined(SPDR) || SPI_HAS_TRANSACTION
277+
#elif !defined(SPDR) || defined(SPI_HAS_TRANSACTION)
278278
SPI.transfer(reg);
279279
uint8_t rv = SPI.transfer(0); // Send empty byte
280280
SPI_SS::Set();
@@ -287,7 +287,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
287287
uint8_t rv = SPDR;
288288
#endif
289289

290-
#if SPI_HAS_TRANSACTION
290+
#if defined(SPI_HAS_TRANSACTION)
291291
SPI.endTransaction();
292292
#endif
293293
XMEM_RELEASE_SPI();
@@ -299,7 +299,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
299299
template< typename SPI_SS, typename INTR >
300300
uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
301301
XMEM_ACQUIRE_SPI();
302-
#if SPI_HAS_TRANSACTION
302+
#if defined(SPI_HAS_TRANSACTION)
303303
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
304304
#endif
305305
SPI_SS::Clear();
@@ -308,7 +308,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
308308
spi4teensy3::send(reg);
309309
spi4teensy3::receive(data_p, nbytes);
310310
data_p += nbytes;
311-
#elif SPI_HAS_TRANSACTION
311+
#elif defined(SPI_HAS_TRANSACTION)
312312
SPI.transfer(reg);
313313
memset(data_p, 0, nbytes); // Make sure we send out empty bytes
314314
SPI.transfer(data_p, nbytes);
@@ -350,7 +350,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
350350
#endif
351351

352352
SPI_SS::Set();
353-
#if SPI_HAS_TRANSACTION
353+
#if defined(SPI_HAS_TRANSACTION)
354354
SPI.endTransaction();
355355
#endif
356356
XMEM_RELEASE_SPI();

0 commit comments

Comments
 (0)