From 08ddabf7a5c5607626c467c70d63ee4bee4ebe0c Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 20:09:27 +0100 Subject: [PATCH] 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); \ } \ };