mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge pull request #137 from felis/SPI
Implement Arduino SPI transaction API
This commit is contained in:
commit
7c40645ff1
41 changed files with 132 additions and 46 deletions
|
@ -8,7 +8,8 @@
|
|||
#include <usbhub.h>
|
||||
#include "KeyboardParser.h"
|
||||
#include "MouseParser.h"
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include <PS3BT.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
#include <PS3BT.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include <PS3BT.h>
|
||||
#include <SPP.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <PS4BT.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include <SPP.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <SPP.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -13,7 +13,8 @@ Otherwise, wire up a IR LED yourself.
|
|||
|
||||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <hid.h>
|
||||
#include <hiduniversal.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include <hidescriptorparser.h>
|
||||
#include <usbhub.h>
|
||||
#include "pgmstrings.h"
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include <usbhub.h>
|
||||
|
||||
#include "le3dp_rptparser.h"
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
#include <usbhub.h>
|
||||
|
||||
#include "scale_rptparser.h"
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
*/
|
||||
|
||||
#include <PS3USB.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <PS4USB.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <PSBuzz.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <usbhub.h>
|
||||
|
||||
#include "pgmstrings.h"
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include <XBOXOLD.h>
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
*/
|
||||
|
||||
#include <XBOXRECV.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
*/
|
||||
|
||||
#include <XBOXUSB.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "pgmstrings.h"
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <adk.h>
|
||||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <adk.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <adk.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <adk.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
/* otherwise press any key after getting GPIO error to complete the test */
|
||||
/**/
|
||||
#include <usbhub.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#include <usbhub.h>
|
||||
|
||||
#include "pgmstrings.h"
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <usbhub.h>
|
||||
#include "pgmstrings.h"
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]
|
||||
|
||||
#include <max_LCD.h>
|
||||
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
/* CDC support */
|
||||
#include <cdcacm.h>
|
||||
#include <cdcprolific.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
/* CDC support */
|
||||
#include <cdcacm.h>
|
||||
#include <cdcprolific.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#include <cdcprolific.h>
|
||||
|
||||
#include <TinyGPS.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
/* CDC support */
|
||||
#include <cdcacm.h>
|
||||
#include <cdcprolific.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7e76562151522380e1dc65501991a408d6f2ae94
|
||||
Subproject commit 94c560c854c7a1dfc35e9de9db05de1b202de6c6
|
|
@ -129,10 +129,11 @@ e-mail : support@circuitsathome.com
|
|||
#define USING_SPI4TEENSY3 0
|
||||
#endif
|
||||
|
||||
#if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822)
|
||||
#include <SPI.h> // Use the Arduino SPI library for the Arduino Due and RedBearLab nRF51822
|
||||
#if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) || ARDUINO >= 10600) && !USING_SPI4TEENSY3
|
||||
#include <SPI.h> // Use the Arduino SPI library for the Arduino Due, RedBearLab nRF51822 or if the SPI library with transaction is available
|
||||
#endif
|
||||
#if defined(__PIC32MX__) || defined(__PIC32MZ__)
|
||||
#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library
|
||||
#endif
|
||||
|
||||
#endif /* SETTINGS_H */
|
||||
|
|
73
usbhost.h
73
usbhost.h
|
@ -27,10 +27,15 @@ e-mail : support@circuitsathome.com
|
|||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* SPI initialization */
|
||||
template< typename SPI_CLK, typename SPI_MOSI, typename SPI_MISO, typename SPI_SS > class SPi {
|
||||
public:
|
||||
#if USING_SPI4TEENSY3
|
||||
#if SPI_HAS_TRANSACTION
|
||||
static void init() {
|
||||
SPI.begin(); // The SPI library with transaction will take care of setting up the pins - settings is set in beginTransaction()
|
||||
}
|
||||
#elif USING_SPI4TEENSY3
|
||||
static void init() {
|
||||
// spi4teensy3 inits everything for us, except /SS
|
||||
// CLK, MOSI and MISO are hard coded for now.
|
||||
|
@ -144,8 +149,17 @@ MAX3421e< SPI_SS, INTR >::MAX3421e() {
|
|||
template< typename SPI_SS, typename INTR >
|
||||
void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
|
||||
XMEM_ACQUIRE_SPI();
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
|
||||
#endif
|
||||
SPI_SS::Clear();
|
||||
#if USING_SPI4TEENSY3
|
||||
|
||||
#if SPI_HAS_TRANSACTION
|
||||
uint8_t c[2];
|
||||
c[0] = reg | 0x02;
|
||||
c[1] = data;
|
||||
SPI.transfer(c, 2);
|
||||
#elif USING_SPI4TEENSY3
|
||||
uint8_t c[2];
|
||||
c[0] = reg | 0x02;
|
||||
c[1] = data;
|
||||
|
@ -159,7 +173,11 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
|
|||
SPDR = data;
|
||||
while(!(SPSR & (1 << SPIF)));
|
||||
#endif
|
||||
|
||||
SPI_SS::Set();
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.endTransaction();
|
||||
#endif
|
||||
XMEM_RELEASE_SPI();
|
||||
return;
|
||||
};
|
||||
|
@ -169,8 +187,16 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
|
|||
template< typename SPI_SS, typename INTR >
|
||||
uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
|
||||
XMEM_ACQUIRE_SPI();
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
|
||||
#endif
|
||||
SPI_SS::Clear();
|
||||
#if USING_SPI4TEENSY3
|
||||
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.transfer(reg | 0x02);
|
||||
SPI.transfer(data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#elif USING_SPI4TEENSY3
|
||||
spi4teensy3::send(reg | 0x02);
|
||||
spi4teensy3::send(data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
|
@ -191,7 +217,11 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
|
|||
}
|
||||
while(!(SPSR & (1 << SPIF)));
|
||||
#endif
|
||||
|
||||
SPI_SS::Set();
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.endTransaction();
|
||||
#endif
|
||||
XMEM_RELEASE_SPI();
|
||||
return ( data_p);
|
||||
}
|
||||
|
@ -211,23 +241,31 @@ void MAX3421e< SPI_SS, INTR >::gpioWr(uint8_t data) {
|
|||
template< typename SPI_SS, typename INTR >
|
||||
uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
|
||||
XMEM_ACQUIRE_SPI();
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
|
||||
#endif
|
||||
SPI_SS::Clear();
|
||||
#if USING_SPI4TEENSY3
|
||||
|
||||
#if !defined(SPDR) || SPI_HAS_TRANSACTION
|
||||
SPI.transfer(reg);
|
||||
uint8_t rv = SPI.transfer(0); // Send empty byte
|
||||
SPI_SS::Set();
|
||||
#elif USING_SPI4TEENSY3
|
||||
spi4teensy3::send(reg);
|
||||
uint8_t rv = spi4teensy3::receive();
|
||||
SPI_SS::Set();
|
||||
#elif !defined(SPDR)
|
||||
SPI.transfer(reg);
|
||||
uint8_t rv = SPI.transfer(0);
|
||||
SPI_SS::Set();
|
||||
#else
|
||||
SPDR = reg;
|
||||
while(!(SPSR & (1 << SPIF)));
|
||||
SPDR = 0; //send empty byte
|
||||
SPDR = 0; // Send empty byte
|
||||
while(!(SPSR & (1 << SPIF)));
|
||||
SPI_SS::Set();
|
||||
uint8_t rv = SPDR;
|
||||
#endif
|
||||
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.endTransaction();
|
||||
#endif
|
||||
XMEM_RELEASE_SPI();
|
||||
return (rv);
|
||||
}
|
||||
|
@ -237,8 +275,17 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
|
|||
template< typename SPI_SS, typename INTR >
|
||||
uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
|
||||
XMEM_ACQUIRE_SPI();
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
|
||||
#endif
|
||||
SPI_SS::Clear();
|
||||
#if USING_SPI4TEENSY3
|
||||
|
||||
#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
|
||||
spi4teensy3::send(reg);
|
||||
spi4teensy3::receive(data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
|
@ -252,7 +299,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
|
||||
|
@ -268,7 +315,11 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SPI_SS::Set();
|
||||
#if SPI_HAS_TRANSACTION
|
||||
SPI.endTransaction();
|
||||
#endif
|
||||
XMEM_RELEASE_SPI();
|
||||
return ( data_p);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue