mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added support for the Intel Galileo
Still not tested
This commit is contained in:
parent
32c6b91e5a
commit
a3db3d9451
5 changed files with 73 additions and 14 deletions
2
Usb.h
2
Usb.h
|
@ -26,12 +26,12 @@ e-mail : support@circuitsathome.com
|
|||
// None of these should ever be included by a driver, or a user's sketch.
|
||||
#include "settings.h"
|
||||
#include "printhex.h"
|
||||
#include "avrpins.h"
|
||||
#include "message.h"
|
||||
#include "hexdump.h"
|
||||
#include "sink_parser.h"
|
||||
#include "max3421e.h"
|
||||
#include "address.h"
|
||||
#include "avrpins.h"
|
||||
#include "usb_ch9.h"
|
||||
#include "usbhost.h"
|
||||
#include "UsbCore.h"
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef MAX3421e<P53, P54> MAX3421E; // Arduino Mega ADK
|
|||
#elif defined(ARDUINO_AVR_BALANDUINO)
|
||||
typedef MAX3421e<P20, P19> MAX3421E; // Balanduino
|
||||
#else
|
||||
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.) or Teensy 2.0 and 3.0
|
||||
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Galileo or Teensy 2.0 and 3.0
|
||||
#endif
|
||||
|
||||
/* Common setup data constant combinations */
|
||||
|
|
53
avrpins.h
53
avrpins.h
|
@ -747,9 +747,7 @@ public:
|
|||
|
||||
#endif // Arduino pin definitions
|
||||
|
||||
#endif // __AVR__
|
||||
|
||||
#if defined(__arm__)
|
||||
#elif defined(__arm__)
|
||||
|
||||
// pointers are 32 bits on ARM
|
||||
#define pgm_read_pointer(p) pgm_read_dword(p)
|
||||
|
@ -950,6 +948,53 @@ MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected
|
|||
|
||||
#endif
|
||||
|
||||
#endif // __arm__
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
// Pointers are 32 bits on x86
|
||||
#define pgm_read_pointer(p) pgm_read_dword(p)
|
||||
|
||||
#define MAKE_PIN(className, pin) \
|
||||
class className { \
|
||||
public: \
|
||||
static void Set() { \
|
||||
digitalWrite(pin, HIGH); \
|
||||
} \
|
||||
static void Clear() { \
|
||||
digitalWrite(pin, LOW); \
|
||||
} \
|
||||
static void SetDirRead() { \
|
||||
pinMode(pin, INPUT); \
|
||||
} \
|
||||
static void SetDirWrite() { \
|
||||
pinMode(pin, OUTPUT); \
|
||||
} \
|
||||
static uint8_t IsSet() { \
|
||||
return digitalRead(pin); \
|
||||
} \
|
||||
};
|
||||
|
||||
MAKE_PIN(P0, 0);
|
||||
MAKE_PIN(P1, 1);
|
||||
MAKE_PIN(P2, 2);
|
||||
MAKE_PIN(P3, 3);
|
||||
MAKE_PIN(P4, 4);
|
||||
MAKE_PIN(P5, 5);
|
||||
MAKE_PIN(P6, 6);
|
||||
MAKE_PIN(P7, 7);
|
||||
MAKE_PIN(P8, 8);
|
||||
MAKE_PIN(P9, 9);
|
||||
MAKE_PIN(P10, 10);
|
||||
MAKE_PIN(P11, 11);
|
||||
MAKE_PIN(P12, 12);
|
||||
MAKE_PIN(P13, 13);
|
||||
|
||||
#undef MAKE_PIN
|
||||
|
||||
#else
|
||||
#error "Please define board in avrpins.h"
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _avrpins_h_
|
||||
|
|
|
@ -137,8 +137,8 @@ e-mail : support@circuitsathome.com
|
|||
#define USING_SPI4TEENSY3 0
|
||||
#endif
|
||||
|
||||
#if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || ARDUINO >= 158) && !USING_SPI4TEENSY3
|
||||
#include <SPI.h> // Use the Arduino SPI library for the Arduino Due or if the SPI library with transaction is available
|
||||
#if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__) || ARDUINO >= 158) && !USING_SPI4TEENSY3
|
||||
#include <SPI.h> // Use the Arduino SPI library for the Arduino Due, Intel Galileo or if the SPI library with transaction is available
|
||||
#endif
|
||||
|
||||
#endif /* SETTINGS_H */
|
||||
|
|
24
usbhost.h
24
usbhost.h
|
@ -43,12 +43,16 @@ public:
|
|||
SPI_SS::SetDirWrite();
|
||||
SPI_SS::Set();
|
||||
}
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__)
|
||||
static void init() {
|
||||
SPI_SS::SetDirWrite();
|
||||
SPI_SS::Set();
|
||||
SPI.begin();
|
||||
#ifdef __ARDUINO_X86__
|
||||
SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the API
|
||||
#else
|
||||
SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
static void init() {
|
||||
|
@ -78,6 +82,8 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi;
|
|||
typedef SPi< P13, P11, P12, P10 > spi;
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
typedef SPi< P76, P75, P74, P10 > spi;
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
typedef SPi< P13, P11, P12, P10 > spi;
|
||||
#else
|
||||
#error "No SPI entry in usbhost.h"
|
||||
#endif
|
||||
|
@ -148,7 +154,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
|
|||
c[0] = reg | 0x02;
|
||||
c[1] = data;
|
||||
spi4teensy3::send(c, 2);
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg | 0x02);
|
||||
SPI.transfer(data);
|
||||
#else
|
||||
|
@ -184,13 +190,17 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
|
|||
spi4teensy3::send(reg | 0x02);
|
||||
spi4teensy3::send(data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__))
|
||||
SPI.transfer(reg | 0x02);
|
||||
while(nbytes) {
|
||||
SPI.transfer(*data_p);
|
||||
nbytes--;
|
||||
data_p++; // advance data pointer
|
||||
}
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg | 0x02);
|
||||
SPI.transferBuffer(data_p, NULL, nbytes);
|
||||
data_p += nbytes;
|
||||
#else
|
||||
SPDR = (reg | 0x02); //set WR bit and send register number
|
||||
while(nbytes) {
|
||||
|
@ -230,7 +240,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
|
|||
#endif
|
||||
SPI_SS::Clear();
|
||||
|
||||
#if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || SPI_HAS_TRANSACTION
|
||||
#if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || SPI_HAS_TRANSACTION || defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg);
|
||||
uint8_t rv = SPI.transfer(0); // Send empty byte
|
||||
SPI_SS::Set();
|
||||
|
@ -273,12 +283,16 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
|
|||
spi4teensy3::send(reg);
|
||||
spi4teensy3::receive(data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__))
|
||||
SPI.transfer(reg);
|
||||
while(nbytes) {
|
||||
*data_p++ = SPI.transfer(0);
|
||||
nbytes--;
|
||||
}
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg);
|
||||
SPI.transferBuffer(NULL, data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#else
|
||||
SPDR = reg;
|
||||
while(!(SPSR & (1 << SPIF))); //wait
|
||||
|
|
Loading…
Reference in a new issue