From 32c6b91e5a1eece453404590492d5f69df95a72c Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Sun, 24 Aug 2014 15:56:36 -0700 Subject: [PATCH 01/14] All virtual functions inside BluetoothService needed to be pure for the Intel Galileo --- BTD.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BTD.h b/BTD.h index 3a639abb..c62ad5eb 100755 --- a/BTD.h +++ b/BTD.h @@ -214,13 +214,13 @@ public: * Used to pass acldata to the Bluetooth service. * @param ACLData Pointer to the incoming acldata. */ - virtual void ACLData(uint8_t* ACLData); + virtual void ACLData(uint8_t* ACLData) = 0; /** Used to run the different state machines in the Bluetooth service. */ - virtual void Run(); + virtual void Run() = 0; /** Used to reset the Bluetooth service. */ - virtual void Reset(); + virtual void Reset() = 0; /** Used to disconnect both the L2CAP Channel and the HCI Connection for the Bluetooth service. */ - virtual void disconnect(); + virtual void disconnect() = 0; }; /** From a3db3d9451c17fdd6f28597017f853c79f1b1ce2 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Sun, 24 Aug 2014 16:40:18 -0700 Subject: [PATCH 02/14] Added support for the Intel Galileo Still not tested --- Usb.h | 2 +- UsbCore.h | 2 +- avrpins.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++----- settings.h | 4 ++-- usbhost.h | 24 +++++++++++++++++++----- 5 files changed, 73 insertions(+), 14 deletions(-) diff --git a/Usb.h b/Usb.h index d903ff51..8fbac80d 100644 --- a/Usb.h +++ b/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" diff --git a/UsbCore.h b/UsbCore.h index 76d9d5ee..5a54328f 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -38,7 +38,7 @@ typedef MAX3421e MAX3421E; // Arduino Mega ADK #elif defined(ARDUINO_AVR_BALANDUINO) typedef MAX3421e MAX3421E; // Balanduino #else -typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.) or Teensy 2.0 and 3.0 +typedef MAX3421e 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 */ diff --git a/avrpins.h b/avrpins.h index c59e9c52..b19897b8 100644 --- a/avrpins.h +++ b/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__) -#endif //_avrpins_h_ +#include + +// 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_ diff --git a/settings.h b/settings.h index b1010786..93891b84 100644 --- a/settings.h +++ b/settings.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 // 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 // Use the Arduino SPI library for the Arduino Due, Intel Galileo or if the SPI library with transaction is available #endif #endif /* SETTINGS_H */ diff --git a/usbhost.h b/usbhost.h index 31c0e128..37f9465c 100644 --- a/usbhost.h +++ b/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 From af4c3f673c22147c82fd5a4e765b4aa06cd64f62 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Sun, 24 Aug 2014 17:10:50 -0700 Subject: [PATCH 03/14] The analog pins can also be used as digital pins --- avrpins.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/avrpins.h b/avrpins.h index b19897b8..b7d05b38 100644 --- a/avrpins.h +++ b/avrpins.h @@ -948,7 +948,7 @@ MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected #endif -#elif defined(__ARDUINO_X86__) +#elif defined(__ARDUINO_X86__) // Intel Galileo #include @@ -989,6 +989,12 @@ MAKE_PIN(P10, 10); MAKE_PIN(P11, 11); MAKE_PIN(P12, 12); MAKE_PIN(P13, 13); +MAKE_PIN(P14, 14); // A0 +MAKE_PIN(P15, 15); // A1 +MAKE_PIN(P16, 16); // A2 +MAKE_PIN(P17, 17); // A3 +MAKE_PIN(P18, 18); // A4 +MAKE_PIN(P19, 19); // A5 #undef MAKE_PIN From 81a861d4d5f7f1a294affaaab69851d6de1ee2bc Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Tue, 2 Sep 2014 00:18:05 -0700 Subject: [PATCH 04/14] Mention Arduino Galileo in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 58599d42..7d45ca3c 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,8 @@ By default serial debugging is disabled. To turn it on simply change ```ENABLE_U Currently the following boards are supported by the library: * All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.) -* Arduino Due - * If you are using the Arduino Due, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. +* Arduino Due and Arduino Galileo + * If you are using the Arduino Due or Galileo, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. * Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x) * Note if you are using the Teensy 3.x you should download this SPI library as well: . You should then add ```#include ``` to your .ino file. * Balanduino From 4ab24d9973e53908853c3fb8ce0fae31052a3e32 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Sun, 7 Sep 2014 22:06:19 -0700 Subject: [PATCH 05/14] No need to __ARDUINO_X86__ to have it's own entry --- usbhost.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/usbhost.h b/usbhost.h index 37f9465c..bf2bf5ac 100644 --- a/usbhost.h +++ b/usbhost.h @@ -78,12 +78,10 @@ typedef SPi< Pb1, Pb2, Pb3, Pb0 > spi; typedef SPi< Pb5, Pb3, Pb4, Pb2 > spi; #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi; -#elif defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__)) +#elif (defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__))) || defined(__ARDUINO_X86__) 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 @@ -190,7 +188,7 @@ 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); @@ -283,7 +281,7 @@ 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); From 2dfca7d936e985b4dd3fab4cc609fbcac0a7bc16 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 3 Mar 2015 20:00:28 +0100 Subject: [PATCH 06/14] Update submodules --- examples/testusbhostFAT/Arduino_Makefile_master | 2 +- examples/testusbhostFAT/RTClib | 2 +- examples/testusbhostFAT/generic_storage | 2 +- examples/testusbhostFAT/xmem2 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/testusbhostFAT/Arduino_Makefile_master b/examples/testusbhostFAT/Arduino_Makefile_master index 7ada91a9..94c560c8 160000 --- a/examples/testusbhostFAT/Arduino_Makefile_master +++ b/examples/testusbhostFAT/Arduino_Makefile_master @@ -1 +1 @@ -Subproject commit 7ada91a90027ccb7558b74087fb68d3940ecf64d +Subproject commit 94c560c854c7a1dfc35e9de9db05de1b202de6c6 diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index b119b97e..c30fcdf1 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit b119b97e1484a08aebcf24e070113d78c82fb023 +Subproject commit c30fcdf1f112de581de7b145a97630539e5cff44 diff --git a/examples/testusbhostFAT/generic_storage b/examples/testusbhostFAT/generic_storage index 72b5bf46..9233df8b 160000 --- a/examples/testusbhostFAT/generic_storage +++ b/examples/testusbhostFAT/generic_storage @@ -1 +1 @@ -Subproject commit 72b5bf467a1c2479ba7354ee4d864e382c167425 +Subproject commit 9233df8bc2cd0c16d363c8e298398b6eaefad257 diff --git a/examples/testusbhostFAT/xmem2 b/examples/testusbhostFAT/xmem2 index 2bf8f633..77b03342 160000 --- a/examples/testusbhostFAT/xmem2 +++ b/examples/testusbhostFAT/xmem2 @@ -1 +1 @@ -Subproject commit 2bf8f633e7f9bc5a7bf4c00f3f45c7b79484198e +Subproject commit 77b033420485f7d3d35430c0e8d4d844aa894834 From dd0296ca6570d2b9fdccbd6b116eb03d9d42eace Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 3 Mar 2015 23:11:45 +0100 Subject: [PATCH 07/14] Replaced #if with #elif for MIPSEL --- avrpins.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/avrpins.h b/avrpins.h index d312f9c8..46bcf722 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1010,7 +1010,6 @@ MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24)); #undef MAKE_PIN - #else #error "Please define board in avrpins.h" @@ -1066,12 +1065,7 @@ MAKE_PIN(P19, 19); // A5 #undef MAKE_PIN -#else -#error "Please define board in avrpins.h" - -#endif - -#if defined(__MIPSEL__) +#elif defined(__MIPSEL__) // MIPSEL (MIPS architecture using a little endian byte order) // MIPS size_t = 4 @@ -1114,6 +1108,10 @@ MAKE_PIN(P12, 12); // MAKE_PIN(P13, 13); // #undef MAKE_PIN + +#else +#error "Please define board in avrpins.h" + #endif #endif //_avrpins_h_ From cc14152c54d597518550b49e1bc8bc16396936a8 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 16:31:29 +0100 Subject: [PATCH 08/14] Slow SPI devices like the Galileo might actually read it as stabilised in the first go --- examples/board_qc/board_qc.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/board_qc/board_qc.ino b/examples/board_qc/board_qc.ino index 2d8529e4..573c3ce0 100644 --- a/examples/board_qc/board_qc.ino +++ b/examples/board_qc/board_qc.ino @@ -121,7 +121,7 @@ void setup() { } Usb.regWr(rUSBCTL, 0x00); //release from reset uint16_t j = 0; - for(j = 0; j < 65535; j++) { //tracking off to on time + for(j = 1; j < 65535; j++) { //tracking off to on time if(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { E_Notify(PSTR(" Time to stabilize - "), 0x80); Serial.print(j, DEC); From 424e35192374a3ed75d42110695afb230d16e777 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 18:24:41 +0100 Subject: [PATCH 09/14] Put avrpins include back at original order Also some whitespace fixes --- README.md | 2 +- Usb.h | 2 +- usbhost.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 22f07ad6..4df40f13 100644 --- a/README.md +++ b/README.md @@ -322,4 +322,4 @@ LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0 LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0 ``` -* This means that your dongle does not support 2.0+EDR, so you will need another dongle. Please see the following [list](https://github.com/felis/USB_Host_Shield_2.0/wiki/Bluetooth-dongles) for tested working dongles. +* This means that your dongle does not support 2.0+EDR, so you will need another dongle. Please see the following [list](https://github.com/felis/USB_Host_Shield_2.0/wiki/Bluetooth-dongles) for tested working dongles. \ No newline at end of file diff --git a/Usb.h b/Usb.h index fa801891..47bd626c 100644 --- a/Usb.h +++ b/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" diff --git a/usbhost.h b/usbhost.h index 4e6154da..56cfd396 100644 --- a/usbhost.h +++ b/usbhost.h @@ -524,4 +524,4 @@ uint8_t MAX3421e< SPI_SS, INTR >::IntHandler() { // return( GPINIRQ ); //} -#endif //_USBHOST_H_ +#endif // _USBHOST_H_ From d881e514ee75480ae00bb2e99f47512aff44e29c Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 18:25:26 +0100 Subject: [PATCH 10/14] Check for MIPSEL at the same place as Teensy 3.x and Galileo --- usbhost.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/usbhost.h b/usbhost.h index 56cfd396..da710a1b 100644 --- a/usbhost.h +++ b/usbhost.h @@ -87,14 +87,12 @@ typedef SPi< Pb1, Pb2, Pb3, Pb0 > spi; typedef SPi< Pb5, Pb3, Pb4, Pb2 > spi; #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi; -#elif (defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__))) || defined(__ARDUINO_X86__) +#elif (defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__))) || defined(__ARDUINO_X86__) || defined(__MIPSEL__) typedef SPi< P13, P11, P12, P10 > spi; #elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) typedef SPi< P76, P75, P74, P10 > spi; #elif defined(RBL_NRF51822) typedef SPi< P16, P18, P17, P10 > spi; -#elif defined(__MIPSEL__) -typedef SPi< P13, P11, P12, P10 > spi; #else #error "No SPI entry in usbhost.h" #endif From 08ddabf7a5c5607626c467c70d63ee4bee4ebe0c Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 20:09:27 +0100 Subject: [PATCH 11/14] Use much faster GPIO pin 2 and 3 on Intel Galileo & Intel Galileo 2 --- README.md | 5 +++-- UsbCore.h | 4 +++- avrpins.h | 21 +++++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4df40f13..53b55204 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,9 @@ By default serial debugging is disabled. To turn it on simply change ```ENABLE_U Currently the following boards are supported by the library: * All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.) -* Arduino Due and Arduino Galileo - * If you are using the Arduino Due or Galileo, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. +* Arduino Due, Intel Galileo and Intel Galileo 2 + * If you are using the Arduino Due, Intel Galileo or Intel Galileo 2, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. + * Note that both the Intel Galileo and Intel Galileo 2 use pin 2 and 3 as INT and SS pin respectively by default, so some modifications to the shield are needed. See the "Interface modifications" section in the [hardware manual](https://www.circuitsathome.com/usb-host-shield-hardware-manual) for more information. * Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x) * Note if you are using the Teensy 3.x you should download this SPI library as well: . You should then add ```#include ``` to your .ino file. * Balanduino diff --git a/UsbCore.h b/UsbCore.h index d76f1858..d8356d04 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -37,8 +37,10 @@ typedef MAX3421e MAX3421E; // Teensy++ 1.0 and 2.0 typedef MAX3421e MAX3421E; // Arduino Mega ADK #elif defined(ARDUINO_AVR_BALANDUINO) typedef MAX3421e MAX3421E; // Balanduino +#elif defined(__ARDUINO_X86__) +typedef MAX3421e MAX3421E; // The Intel Galileo and Intel Galileo 2 both support much faster read and write speed at pin 2 and 3 #else -typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Galileo or Teensy 2.0 and 3.0 +typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.) or Teensy 2.0 and 3.0 #endif /* Common setup data constant combinations */ diff --git a/avrpins.h b/avrpins.h index 7acf492a..3f02d5c4 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1015,30 +1015,39 @@ MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24)); #endif -#elif defined(__ARDUINO_X86__) // Intel Galileo +#elif defined(__ARDUINO_X86__) // Intel Galileo and Intel Galileo 2 #include // Pointers are 32 bits on x86 #define pgm_read_pointer(p) pgm_read_dword(p) +// Pin 2 and 3 support a higher rate, so it is recommended to use one of these as the SS pin. +// I know Intel Galileo 2 support higher rate at some other pins as well, but 2 and 3 are only +// available on the original Intel Galileo. #define MAKE_PIN(className, pin) \ class className { \ public: \ static void Set() { \ - digitalWrite(pin, HIGH); \ + fastDigitalWrite(pin, HIGH); \ } \ static void Clear() { \ - digitalWrite(pin, LOW); \ + fastDigitalWrite(pin, LOW); \ } \ static void SetDirRead() { \ - pinMode(pin, INPUT); \ + if (pinToFastPin(pin)) \ + pinMode(pin, INPUT_FAST); \ + else \ + pinMode(pin, INPUT); \ } \ static void SetDirWrite() { \ - pinMode(pin, OUTPUT); \ + if (pinToFastPin(pin)) \ + pinMode(pin, OUTPUT_FAST); \ + else \ + pinMode(pin, OUTPUT); \ } \ static uint8_t IsSet() { \ - return digitalRead(pin); \ + return fastDigitalRead(pin); \ } \ }; From 42a26346fa7b552f7a271ce2d276b4fe669b70e4 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 20:47:48 +0100 Subject: [PATCH 12/14] Added support for Intel Edison Closes #132 --- README.md | 2 +- UsbCore.h | 2 +- avrpins.h | 14 ++++++++++---- settings.h | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 53b55204..ac543395 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ By default serial debugging is disabled. To turn it on simply change ```ENABLE_U Currently the following boards are supported by the library: * All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.) -* Arduino Due, Intel Galileo and Intel Galileo 2 +* Arduino Due, Intel Galileo, Intel Galileo 2, and Intel Edison * If you are using the Arduino Due, Intel Galileo or Intel Galileo 2, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. * Note that both the Intel Galileo and Intel Galileo 2 use pin 2 and 3 as INT and SS pin respectively by default, so some modifications to the shield are needed. See the "Interface modifications" section in the [hardware manual](https://www.circuitsathome.com/usb-host-shield-hardware-manual) for more information. * Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x) diff --git a/UsbCore.h b/UsbCore.h index d8356d04..0b1ded02 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -40,7 +40,7 @@ typedef MAX3421e MAX3421E; // Balanduino #elif defined(__ARDUINO_X86__) typedef MAX3421e MAX3421E; // The Intel Galileo and Intel Galileo 2 both support much faster read and write speed at pin 2 and 3 #else -typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.) or Teensy 2.0 and 3.0 +typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison or Teensy 2.0 and 3.0 #endif /* Common setup data constant combinations */ diff --git a/avrpins.h b/avrpins.h index 3f02d5c4..2b94d609 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1015,16 +1015,22 @@ MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24)); #endif -#elif defined(__ARDUINO_X86__) // Intel Galileo and Intel Galileo 2 +#elif defined(__ARDUINO_X86__) // Intel Galileo, Intel Galileo 2 and Intel Edison #include // Pointers are 32 bits on x86 #define pgm_read_pointer(p) pgm_read_dword(p) -// Pin 2 and 3 support a higher rate, so it is recommended to use one of these as the SS pin. -// I know Intel Galileo 2 support higher rate at some other pins as well, but 2 and 3 are only -// available on the original Intel Galileo. +#if PLATFORM_ID == 0xE1 // Edison platform id +#define pinToFastPin(pin) 1 // As far as I can tell all pins can be used as fast pins +#endif + +// Pin 2 and 3 on the Intel Galileo 1 & 2 support a higher rate, +// so it is recommended to use one of these as the SS pin. +// I know Intel Galileo 2 support higher rate at some other pins as well, +// but 2 and 3 are only available on the original Intel Galileo. + #define MAKE_PIN(className, pin) \ class className { \ public: \ diff --git a/settings.h b/settings.h index 33757495..5c060354 100644 --- a/settings.h +++ b/settings.h @@ -130,7 +130,7 @@ e-mail : support@circuitsathome.com #endif #if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) || defined(__ARDUINO_X86__) || ARDUINO >= 10600) && !USING_SPI4TEENSY3 -#include // Use the Arduino SPI library for the Arduino Due, RedBearLab nRF51822 or if the SPI library with transaction is available +#include // Use the Arduino SPI library for the Arduino Due, RedBearLab nRF51822, Intel Galileo 1 & 2, Intel Edison 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 From 4e80db2b3f06633c55fbd1d4806bc6af66bfb638 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 21:20:06 +0100 Subject: [PATCH 13/14] Use setClockSpeed to increase SPI clock speed This is only available in newer version of the API. It can be downloaded here: http://www.intel.com/support/edison/sb/CS-035180.htm and can both be used with the Edison and the Galileo Note that I tried to set the clock rate higher than 12 MHz, but it did not work --- usbhost.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usbhost.h b/usbhost.h index da710a1b..0a2b7bff 100644 --- a/usbhost.h +++ b/usbhost.h @@ -51,7 +51,11 @@ public: #if defined(__MIPSEL__) SPI.setClockDivider(1); #elif defined(__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 + #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 + #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 + #endif #else SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz #endif From b41150643f280906bc8c207bef968671dfdf18b4 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sun, 5 Apr 2015 13:01:24 +0200 Subject: [PATCH 14/14] Only use pin 2 and 3 as INT and SS when using Intel Galileo 1 --- README.md | 2 +- UsbCore.h | 6 +++--- avrpins.h | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ac543395..146fc47f 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Currently the following boards are supported by the library: * All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.) * Arduino Due, Intel Galileo, Intel Galileo 2, and Intel Edison * If you are using the Arduino Due, Intel Galileo or Intel Galileo 2, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. - * Note that both the Intel Galileo and Intel Galileo 2 use pin 2 and 3 as INT and SS pin respectively by default, so some modifications to the shield are needed. See the "Interface modifications" section in the [hardware manual](https://www.circuitsathome.com/usb-host-shield-hardware-manual) for more information. + * Note that the Intel Galileo uses pin 2 and 3 as INT and SS pin respectively by default, so some modifications to the shield are needed. See the "Interface modifications" section in the [hardware manual](https://www.circuitsathome.com/usb-host-shield-hardware-manual) for more information. * Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x) * Note if you are using the Teensy 3.x you should download this SPI library as well: . You should then add ```#include ``` to your .ino file. * Balanduino diff --git a/UsbCore.h b/UsbCore.h index 0b1ded02..5c6c7710 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -37,10 +37,10 @@ typedef MAX3421e MAX3421E; // Teensy++ 1.0 and 2.0 typedef MAX3421e MAX3421E; // Arduino Mega ADK #elif defined(ARDUINO_AVR_BALANDUINO) typedef MAX3421e MAX3421E; // Balanduino -#elif defined(__ARDUINO_X86__) -typedef MAX3421e MAX3421E; // The Intel Galileo and Intel Galileo 2 both support much faster read and write speed at pin 2 and 3 +#elif defined(__ARDUINO_X86__) && PLATFORM_ID == 0x06 +typedef MAX3421e MAX3421E; // The Intel Galileo supports much faster read and write speed at pin 2 and 3 #else -typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison or Teensy 2.0 and 3.0 +typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison, Intel Galileo 2 or Teensy 2.0 and 3.0 #endif /* Common setup data constant combinations */ diff --git a/avrpins.h b/avrpins.h index 2b94d609..4e60e3a2 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1026,10 +1026,8 @@ MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24)); #define pinToFastPin(pin) 1 // As far as I can tell all pins can be used as fast pins #endif -// Pin 2 and 3 on the Intel Galileo 1 & 2 support a higher rate, +// Pin 2 and 3 on the Intel Galileo supports a higher rate, // so it is recommended to use one of these as the SS pin. -// I know Intel Galileo 2 support higher rate at some other pins as well, -// but 2 and 3 are only available on the original Intel Galileo. #define MAKE_PIN(className, pin) \ class className { \