From e5f8f688211e0360814320dba7e2e108d23ae6d6 Mon Sep 17 00:00:00 2001 From: Topo-png <67564355+Topo-png@users.noreply.github.com> Date: Mon, 9 Aug 2021 19:08:46 -0400 Subject: [PATCH] Add files via upload Changes per https://github.com/felis/USB_Host_Shield_2.0/pull/654. Builds successfully for Sparkfun Redboar Artemis ATP --- UsbCore.h | 2 - avrpins.h | 115 ++++++++++++++++++++++++++++++----------------------- settings.h | 4 -- usbhost.h | 10 ++++- 4 files changed, 74 insertions(+), 57 deletions(-) diff --git a/UsbCore.h b/UsbCore.h index 0cf79a53..8574d29c 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -52,8 +52,6 @@ typedef MAX3421e MAX3421E; // ESP8266 boards typedef MAX3421e MAX3421E; // ESP32 boards #elif (defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) typedef MAX3421e MAX3421E; // Sanguino -#elif defined(AM_PART_APOLLO3) -typedef MAX3421e MAX3421E; // Sparkfun Redboard Artemis All the pins #else typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison, Intel Galileo 2 or Teensy 2.0 and 3.x #endif diff --git a/avrpins.h b/avrpins.h index 26c65c51..ff3a1b88 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1358,56 +1358,73 @@ MAKE_PIN(P33, (9)); #elif defined(AM_PART_APOLLO3) // Sparkfun Artemis Redboard & ATP variant -#include "Arduino.h" \ +#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); \ + } \ +}; -#define P0 0 -#define P1 1 -#define P2 2 -#define P3 3 -#define P4 4 -#define P5 5 -#define P6 6 -#define P7 7 -#define P8 8 -#define P9 9 -#define P10 10 -#define P11 11 -#define P12 12 -#define P13 13 -#define P14 14 -#define P15 15 -#define P16 16 -#define P17 17 -#define P18 18 -#define P19 19 -#define P20 20 -#define P21 21 -#define P22 22 -#define P23 23 -#define P24 24 -#define P25 25 -#define P26 26 -#define P27 27 -#define P28 28 -#define P29 29 -#define P30 30 -#define P31 31 -#define P32 32 -#define P33 33 -#define P34 34 -#define P35 35 -#define P36 36 -#define P37 37 - -#if defined(AM_PACKAGE_BGA) - #define P38 38 - #define P39 39 - #define P40 40 - #define P41 41 - #define P42 42 - #define P43 43 - #define P44 44 - #define P45 45 +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); +MAKE_PIN(P14, 14); +MAKE_PIN(P15, 15); +MAKE_PIN(P16, 16); +MAKE_PIN(P17, 17); +MAKE_PIN(P18, 18); +MAKE_PIN(P19, 19); +MAKE_PIN(P20, 20); +MAKE_PIN(P21, 21); +MAKE_PIN(P22, 22); +MAKE_PIN(P23, 23); +MAKE_PIN(P24, 24); +MAKE_PIN(P25, 25); +MAKE_PIN(P26, 26); +MAKE_PIN(P27, 27); +MAKE_PIN(P28, 28); +MAKE_PIN(P29, 29); +MAKE_PIN(P30, 30); +MAKE_PIN(P31, 31); +MAKE_PIN(P32, 35); +MAKE_PIN(P33, 33); +MAKE_PIN(P34, 34); +MAKE_PIN(P35, 35); +MAKE_PIN(P36, 36); +MAKE_PIN(P37, 37); +MAKE_PIN(P38, 38); +MAKE_PIN(P39, 39); +#ifdef AM_PACKAGE_BGA // All The Pins (ATP) variant +MAKE_PIN(P40, 40); +MAKE_PIN(P41, 41); +MAKE_PIN(P42, 42); +MAKE_PIN(P43, 43); +MAKE_PIN(P44, 44); +MAKE_PIN(P45, 45); #endif #else diff --git a/settings.h b/settings.h index b08de21f..6b134dfb 100644 --- a/settings.h +++ b/settings.h @@ -175,10 +175,6 @@ e-mail : support@circuitsathome.com extern SPI_HandleTypeDef SPI_Handle; // Needed to be declared in your main.cpp #endif -#ifdef AM_PART_APOLLO3 -#include -#endif - // Fix defines on Arduino Due #ifdef ARDUINO_SAM_DUE #ifdef tokSETUP diff --git a/usbhost.h b/usbhost.h index a3b5c0cf..6b776a1d 100644 --- a/usbhost.h +++ b/usbhost.h @@ -57,6 +57,11 @@ public: static void init() { // Should be initialized by the user manually for now } +#elif defined(AM_PART_APOLLO3) + + static void init() { + SPI::begin(); + } #elif !defined(SPDR) static void init() { SPI_SS::SetDirWrite(); @@ -123,7 +128,7 @@ typedef SPi< P18, P23, P19, P5 > spi; #elif defined(ARDUINO_NRF52840_FEATHER) typedef SPi< P26, P25, P24, P5 > spi; #elif defined(AM_PART_APOLLO3) -typedef SPi< P5, P7, P6, P13> spi; +typedef SPi< P13, P11, P12, P10 > spi; #else #error "No SPI entry in usbhost.h" #endif @@ -430,8 +435,9 @@ int8_t MAX3421e< SPI_SS, INTR >::Init() { // Also avoids the vbus flicker issue confusing some devices. /* pin and peripheral setup */ SPI_SS::SetDirWrite(); + SPI_SS::Set(); - spi::init(); + spi::init(); INTR::SetDirRead(); XMEM_RELEASE_SPI(); /* MAX3421E - full-duplex SPI, level interrupt */