Merge branch 'master' of github.com:felis/USB_Host_Shield_2.0

This commit is contained in:
Andrew J. Kroll 2017-12-01 10:44:10 -05:00
commit 08121e1701
13 changed files with 72 additions and 73 deletions

12
BTD.cpp
View file

@ -335,15 +335,13 @@ void BTD::EndpointXtract(uint8_t conf, uint8_t iface __attribute__((unused)), ui
bConfNum = conf; bConfNum = conf;
uint8_t index; uint8_t index;
if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) { // Interrupt In endpoint found if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) { // Interrupt In endpoint found
index = BTD_EVENT_PIPE; index = BTD_EVENT_PIPE;
epInfo[index].bmNakPower = USB_NAK_NOWAIT; epInfo[index].bmNakPower = USB_NAK_NOWAIT;
} else { } else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) // Bulk endpoint found
if((pep->bmAttributes & 0x02) == 2) // Bulk endpoint found index = ((pep->bEndpointAddress & 0x80) == 0x80) ? BTD_DATAIN_PIPE : BTD_DATAOUT_PIPE;
index = ((pep->bEndpointAddress & 0x80) == 0x80) ? BTD_DATAIN_PIPE : BTD_DATAOUT_PIPE; else
else return;
return;
}
// Fill the rest of endpoint data structure // Fill the rest of endpoint data structure
epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F);

View file

@ -321,7 +321,7 @@ void ADK::EndpointXtract(uint8_t conf, uint8_t iface __attribute__((unused)), ui
bConfNum = conf; bConfNum = conf;
if((pep->bmAttributes & 0x02) == 2) { if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) {
uint8_t index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; uint8_t index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
// Fill in the endpoint info structure // Fill in the endpoint info structure
epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F);

View file

@ -237,10 +237,9 @@ void ACM::EndpointXtract(uint8_t conf, uint8_t iface __attribute__((unused)), ui
uint8_t index; uint8_t index;
if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80)
index = epInterruptInIndex; index = epInterruptInIndex;
else else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK)
if((pep->bmAttributes & 0x02) == 2)
index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
else else
return; return;

View file

@ -229,10 +229,9 @@ void FTDI::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t prot
uint8_t index; uint8_t index;
if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80)
index = epInterruptInIndex; index = epInterruptInIndex;
else else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK)
if((pep->bmAttributes & 0x02) == 2)
index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
else else
return; return;

View file

@ -546,7 +546,7 @@ void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t
bConfNum = conf; bConfNum = conf;
bIfaceNum = iface; bIfaceNum = iface;
if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) { if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) {
if(pep->bInterval > bInterval) bInterval = pep->bInterval; if(pep->bInterval > bInterval) bInterval = pep->bInterval;
// Fill in the endpoint info structure // Fill in the endpoint info structure

View file

@ -313,29 +313,27 @@ void HIDComposite::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint
bNumIface++; bNumIface++;
} }
if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT)
index = epInterruptInIndex; index = (pep->bEndpointAddress & 0x80) == 0x80 ? epInterruptInIndex : epInterruptOutIndex;
else
index = epInterruptOutIndex;
if(!SelectInterface(iface, proto)) if(!SelectInterface(iface, proto))
index = 0; index = 0;
if(index) { if(index) {
// Fill in the endpoint info structure // Fill in the endpoint info structure
epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F); epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F);
epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize; epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize;
epInfo[bNumEP].bmSndToggle = 0; epInfo[bNumEP].bmSndToggle = 0;
epInfo[bNumEP].bmRcvToggle = 0; epInfo[bNumEP].bmRcvToggle = 0;
epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT; epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT;
// Fill in the endpoint index list // Fill in the endpoint index list
piface->epIndex[index] = bNumEP; //(pep->bEndpointAddress & 0x0F); piface->epIndex[index] = bNumEP; //(pep->bEndpointAddress & 0x0F);
if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints
pollInterval = pep->bInterval; pollInterval = pep->bInterval;
bNumEP++; bNumEP++;
} }
} }

View file

@ -315,10 +315,8 @@ void HIDUniversal::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint
bNumIface++; bNumIface++;
} }
if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT)
index = epInterruptInIndex; index = (pep->bEndpointAddress & 0x80) == 0x80 ? epInterruptInIndex : epInterruptOutIndex;
else
index = epInterruptOutIndex;
if(index) { if(index) {
// Fill in the endpoint info structure // Fill in the endpoint info structure

View file

@ -31,7 +31,7 @@
"type": "git", "type": "git",
"url": "https://github.com/felis/USB_Host_Shield_2.0.git" "url": "https://github.com/felis/USB_Host_Shield_2.0.git"
}, },
"version": "1.3.0", "version": "1.3.1",
"license": "GPL-2.0", "license": "GPL-2.0",
"examples": "examples":
[ [

View file

@ -1,5 +1,5 @@
name=USB Host Shield Library 2.0 name=USB Host Shield Library 2.0
version=1.3.0 version=1.3.1
author=Oleg Mazurov (Circuits@Home) <mazurov@circuitsathome.com>, Kristian Lauszus (TKJ Electronics) <kristianl@tkjelectronics.com>, Andrew Kroll <xxxajk@gmail.com>, Alexei Glushchenko (Circuits@Home) <alex-gl@mail.ru> author=Oleg Mazurov (Circuits@Home) <mazurov@circuitsathome.com>, Kristian Lauszus (TKJ Electronics) <kristianl@tkjelectronics.com>, Andrew Kroll <xxxajk@gmail.com>, Alexei Glushchenko (Circuits@Home) <alex-gl@mail.ru>
maintainer=Oleg Mazurov (Circuits@Home) <mazurov@circuitsathome.com>, Kristian Lauszus (TKJ Electronics) <kristianl@tkjelectronics.com>, Andrew Kroll <xxxajk@gmail.com> maintainer=Oleg Mazurov (Circuits@Home) <mazurov@circuitsathome.com>, Kristian Lauszus (TKJ Electronics) <kristianl@tkjelectronics.com>, Andrew Kroll <xxxajk@gmail.com>
sentence=Revision 2.0 of MAX3421E-based USB Host Shield Library. sentence=Revision 2.0 of MAX3421E-based USB Host Shield Library.

View file

@ -550,7 +550,7 @@ void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t
uint8_t index; uint8_t index;
#if 1 #if 1
if((pep->bmAttributes & 0x02) == 2) { if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) {
index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
// Fill in the endpoint info structure // Fill in the endpoint info structure
epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F);
@ -564,10 +564,9 @@ void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t
} }
#else #else
if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80)
index = epInterruptInIndex; index = epInterruptInIndex;
else else if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK)
if((pep->bmAttributes & 0x02) == 2)
index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
else else
return; return;

View file

@ -19,6 +19,14 @@ e-mail : support@circuitsathome.com
#define USB_HOST_SHIELD_SETTINGS_H #define USB_HOST_SHIELD_SETTINGS_H
#include "macros.h" #include "macros.h"
////////////////////////////////////////////////////////////////////////////////
// SPI Configuration
////////////////////////////////////////////////////////////////////////////////
#ifndef USB_SPI
#define USB_SPI SPI
//#define USB_SPI SPI1
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DEBUGGING // DEBUGGING
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -304,7 +304,7 @@ uint8_t USBH_MIDI::parseConfigDescr( uint8_t addr, uint8_t conf )
USBTRACE("-EPAddr:"), D_PrintHex(epDesc->bEndpointAddress, 0x80); USBTRACE("-EPAddr:"), D_PrintHex(epDesc->bEndpointAddress, 0x80);
USBTRACE(" bmAttr:"), D_PrintHex(epDesc->bmAttributes, 0x80); USBTRACE(" bmAttr:"), D_PrintHex(epDesc->bmAttributes, 0x80);
USBTRACE2(" MaxPktSz:", (uint8_t)epDesc->wMaxPacketSize); USBTRACE2(" MaxPktSz:", (uint8_t)epDesc->wMaxPacketSize);
if ((epDesc->bmAttributes & 0x02) == 2) {//bulk if ((epDesc->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_BULK) {//bulk
uint8_t index; uint8_t index;
if( isMidi ) if( isMidi )
index = ((epDesc->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; index = ((epDesc->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;

View file

@ -41,7 +41,7 @@ public:
} }
#elif defined(SPI_HAS_TRANSACTION) #elif defined(SPI_HAS_TRANSACTION)
static void init() { static void init() {
SPI.begin(); // The SPI library with transaction will take care of setting up the pins - settings is set in beginTransaction() USB_SPI.begin(); // The SPI library with transaction will take care of setting up the pins - settings is set in beginTransaction()
SPI_SS::SetDirWrite(); SPI_SS::SetDirWrite();
SPI_SS::Set(); SPI_SS::Set();
} }
@ -54,17 +54,17 @@ public:
static void init() { static void init() {
SPI_SS::SetDirWrite(); SPI_SS::SetDirWrite();
SPI_SS::Set(); SPI_SS::Set();
SPI.begin(); USB_SPI.begin();
#if defined(__MIPSEL__) #if defined(__MIPSEL__)
SPI.setClockDivider(1); USB_SPI.setClockDivider(1);
#elif defined(__ARDUINO_X86__) #elif defined(__ARDUINO_X86__)
#ifdef SPI_CLOCK_1M // Hack used to check if setClockSpeed is available #ifdef SPI_CLOCK_1M // Hack used to check if setClockSpeed is available
SPI.setClockSpeed(12000000); // The MAX3421E can handle up to 26MHz, but in practice this was the maximum that I could reliably use USB_SPI.setClockSpeed(12000000); // The MAX3421E can handle up to 26MHz, but in practice this was the maximum that I could reliably use
#else #else
SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the old API USB_SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the old API
#endif #endif
#elif !defined(RBL_NRF51822) #elif !defined(RBL_NRF51822)
SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz USB_SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz
#endif #endif
} }
#else #else
@ -167,7 +167,7 @@ template< typename SPI_SS, typename INTR >
void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) { void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
XMEM_ACQUIRE_SPI(); XMEM_ACQUIRE_SPI();
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
#endif #endif
SPI_SS::Clear(); SPI_SS::Clear();
@ -180,15 +180,15 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
uint8_t c[2]; uint8_t c[2];
c[0] = reg | 0x02; c[0] = reg | 0x02;
c[1] = data; c[1] = data;
SPI.transfer(c, 2); USB_SPI.transfer(c, 2);
#elif defined(STM32F4) #elif defined(STM32F4)
uint8_t c[2]; uint8_t c[2];
c[0] = reg | 0x02; c[0] = reg | 0x02;
c[1] = data; c[1] = data;
HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY); HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY);
#elif !defined(SPDR) // ESP8266 #elif !defined(SPDR) // ESP8266
SPI.transfer(reg | 0x02); USB_SPI.transfer(reg | 0x02);
SPI.transfer(data); USB_SPI.transfer(data);
#else #else
SPDR = (reg | 0x02); SPDR = (reg | 0x02);
while(!(SPSR & (1 << SPIF))); while(!(SPSR & (1 << SPIF)));
@ -198,7 +198,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
SPI_SS::Set(); SPI_SS::Set();
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.endTransaction(); USB_SPI.endTransaction();
#endif #endif
XMEM_RELEASE_SPI(); XMEM_RELEASE_SPI();
return; return;
@ -210,7 +210,7 @@ template< typename SPI_SS, typename INTR >
uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
XMEM_ACQUIRE_SPI(); XMEM_ACQUIRE_SPI();
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
#endif #endif
SPI_SS::Clear(); SPI_SS::Clear();
@ -219,12 +219,12 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
spi4teensy3::send(data_p, nbytes); spi4teensy3::send(data_p, nbytes);
data_p += nbytes; data_p += nbytes;
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266)
SPI.transfer(reg | 0x02); USB_SPI.transfer(reg | 0x02);
SPI.transfer(data_p, nbytes); USB_SPI.transfer(data_p, nbytes);
data_p += nbytes; data_p += nbytes;
#elif defined(__ARDUINO_X86__) #elif defined(__ARDUINO_X86__)
SPI.transfer(reg | 0x02); USB_SPI.transfer(reg | 0x02);
SPI.transferBuffer(data_p, NULL, nbytes); USB_SPI.transferBuffer(data_p, NULL, nbytes);
data_p += nbytes; data_p += nbytes;
#elif defined(STM32F4) #elif defined(STM32F4)
uint8_t data = reg | 0x02; uint8_t data = reg | 0x02;
@ -232,9 +232,9 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY); HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
data_p += nbytes; data_p += nbytes;
#elif !defined(SPDR) // ESP8266 #elif !defined(SPDR) // ESP8266
SPI.transfer(reg | 0x02); USB_SPI.transfer(reg | 0x02);
while(nbytes) { while(nbytes) {
SPI.transfer(*data_p); USB_SPI.transfer(*data_p);
nbytes--; nbytes--;
data_p++; // advance data pointer data_p++; // advance data pointer
} }
@ -251,7 +251,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
SPI_SS::Set(); SPI_SS::Set();
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.endTransaction(); USB_SPI.endTransaction();
#endif #endif
XMEM_RELEASE_SPI(); XMEM_RELEASE_SPI();
return ( data_p); return ( data_p);
@ -273,7 +273,7 @@ template< typename SPI_SS, typename INTR >
uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) { uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
XMEM_ACQUIRE_SPI(); XMEM_ACQUIRE_SPI();
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
#endif #endif
SPI_SS::Clear(); SPI_SS::Clear();
@ -287,8 +287,8 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
HAL_SPI_Receive(&SPI_Handle, &rv, 1, HAL_MAX_DELAY); HAL_SPI_Receive(&SPI_Handle, &rv, 1, HAL_MAX_DELAY);
SPI_SS::Set(); SPI_SS::Set();
#elif !defined(SPDR) || defined(SPI_HAS_TRANSACTION) #elif !defined(SPDR) || defined(SPI_HAS_TRANSACTION)
SPI.transfer(reg); USB_SPI.transfer(reg);
uint8_t rv = SPI.transfer(0); // Send empty byte uint8_t rv = USB_SPI.transfer(0); // Send empty byte
SPI_SS::Set(); SPI_SS::Set();
#else #else
SPDR = reg; SPDR = reg;
@ -300,7 +300,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
#endif #endif
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.endTransaction(); USB_SPI.endTransaction();
#endif #endif
XMEM_RELEASE_SPI(); XMEM_RELEASE_SPI();
return (rv); return (rv);
@ -312,7 +312,7 @@ template< typename SPI_SS, typename INTR >
uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
XMEM_ACQUIRE_SPI(); XMEM_ACQUIRE_SPI();
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
#endif #endif
SPI_SS::Clear(); SPI_SS::Clear();
@ -321,13 +321,13 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
spi4teensy3::receive(data_p, nbytes); spi4teensy3::receive(data_p, nbytes);
data_p += nbytes; data_p += nbytes;
#elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266)
SPI.transfer(reg); USB_SPI.transfer(reg);
memset(data_p, 0, nbytes); // Make sure we send out empty bytes memset(data_p, 0, nbytes); // Make sure we send out empty bytes
SPI.transfer(data_p, nbytes); USB_SPI.transfer(data_p, nbytes);
data_p += nbytes; data_p += nbytes;
#elif defined(__ARDUINO_X86__) #elif defined(__ARDUINO_X86__)
SPI.transfer(reg); USB_SPI.transfer(reg);
SPI.transferBuffer(NULL, data_p, nbytes); USB_SPI.transferBuffer(NULL, data_p, nbytes);
data_p += nbytes; data_p += nbytes;
#elif defined(STM32F4) #elif defined(STM32F4)
HAL_SPI_Transmit(&SPI_Handle, &reg, 1, HAL_MAX_DELAY); HAL_SPI_Transmit(&SPI_Handle, &reg, 1, HAL_MAX_DELAY);
@ -335,9 +335,9 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
HAL_SPI_Receive(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY); HAL_SPI_Receive(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
data_p += nbytes; data_p += nbytes;
#elif !defined(SPDR) // ESP8266 #elif !defined(SPDR) // ESP8266
SPI.transfer(reg); USB_SPI.transfer(reg);
while(nbytes) { while(nbytes) {
*data_p++ = SPI.transfer(0); *data_p++ = USB_SPI.transfer(0);
nbytes--; nbytes--;
} }
#else #else
@ -363,7 +363,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
SPI_SS::Set(); SPI_SS::Set();
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
SPI.endTransaction(); USB_SPI.endTransaction();
#endif #endif
XMEM_RELEASE_SPI(); XMEM_RELEASE_SPI();
return ( data_p); return ( data_p);