From 4158a501a953792e7c0e3eff1a25957e45fe56df Mon Sep 17 00:00:00 2001 From: Joe Bowbeer Date: Fri, 3 Feb 2017 22:44:51 -0800 Subject: [PATCH] Add Arduino 101 mods from https://github.com/KitPan/USB_Host_Shield_2.0 --- avrpins.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ usbhost.h | 4 ++++ 2 files changed, 56 insertions(+) diff --git a/avrpins.h b/avrpins.h index e782de8b..ce50d16a 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1167,6 +1167,58 @@ MAKE_PIN(P19, GPIOC, GPIO_PIN_0); // A5 #endif +#elif defined(__ARDUINO_ARC__) + +#include +// Pointers are 32 bits on arc +#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); //PWM +MAKE_PIN(P4, 4); +MAKE_PIN(P5, 5); //PWM +MAKE_PIN(P6, 6); //PWM +MAKE_PIN(P7, 7); +MAKE_PIN(P8, 8); +MAKE_PIN(P9, 9); //PWM + +MAKE_PIN(P10, 10); //SPI SS +MAKE_PIN(P11, 11); //SPI MOSI +MAKE_PIN(P12, 12); //SPI MISO +MAKE_PIN(P13, 13); //SPI SCK / BUILTIN LED + +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 SDA +MAKE_PIN(P19, 19); // A5 SCL +MAKE_PIN(P20, 20); // ATN + +#undef MAKE_PIN + #elif defined(__ARDUINO_X86__) // Intel Galileo, Intel Galileo 2 and Intel Edison #include diff --git a/usbhost.h b/usbhost.h index 705aeebf..cbff60cb 100644 --- a/usbhost.h +++ b/usbhost.h @@ -63,6 +63,8 @@ public: #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 +#elif defined(__ARDUINO_ARC__) + SPI.setClockDivider(SPI_CLOCK_DIV2); #elif !defined(RBL_NRF51822) SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz #endif @@ -97,6 +99,8 @@ typedef SPi< P13, P11, P12, P10 > spi; typedef SPi< P76, P75, P74, P10 > spi; #elif defined(RBL_NRF51822) typedef SPi< P16, P18, P17, P10 > spi; +#elif defined(__ARDUINO_ARC__) +typedef SPi< P13, P11, P12, P10 > spi; #else #error "No SPI entry in usbhost.h" #endif