一関 Aチーム / ArduinoUsbHostShield
Committer:
kotakku
Date:
Sat Jan 18 15:06:35 2020 +0000
Revision:
0:b1ce54272580
Child:
1:da31140f2a1c
1.0.0 first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kotakku 0:b1ce54272580 1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
kotakku 0:b1ce54272580 2
kotakku 0:b1ce54272580 3 This program is free software; you can redistribute it and/or modify
kotakku 0:b1ce54272580 4 it under the terms of the GNU General Public License as published by
kotakku 0:b1ce54272580 5 the Free Software Foundation; either version 2 of the License, or
kotakku 0:b1ce54272580 6 (at your option) any later version.
kotakku 0:b1ce54272580 7
kotakku 0:b1ce54272580 8 This program is distributed in the hope that it will be useful,
kotakku 0:b1ce54272580 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
kotakku 0:b1ce54272580 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kotakku 0:b1ce54272580 11 GNU General Public License for more details.
kotakku 0:b1ce54272580 12
kotakku 0:b1ce54272580 13 You should have received a copy of the GNU General Public License
kotakku 0:b1ce54272580 14 along with this program; if not, write to the Free Software
kotakku 0:b1ce54272580 15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
kotakku 0:b1ce54272580 16
kotakku 0:b1ce54272580 17 Contact information
kotakku 0:b1ce54272580 18 -------------------
kotakku 0:b1ce54272580 19
kotakku 0:b1ce54272580 20 Circuits At Home, LTD
kotakku 0:b1ce54272580 21 Web : http://www.circuitsathome.com
kotakku 0:b1ce54272580 22 e-mail : support@circuitsathome.com
kotakku 0:b1ce54272580 23 */
kotakku 0:b1ce54272580 24
kotakku 0:b1ce54272580 25 /*
kotakku 0:b1ce54272580 26 warning
kotakku 0:b1ce54272580 27 #define _usb_h_
kotakku 0:b1ce54272580 28 #define MBED_H
kotakku 0:b1ce54272580 29 */
kotakku 0:b1ce54272580 30
kotakku 0:b1ce54272580 31 #ifndef USB_HOST_SHIELD_SETTINGS_H
kotakku 0:b1ce54272580 32 #define USB_HOST_SHIELD_SETTINGS_H
kotakku 0:b1ce54272580 33 #include "macros.h"
kotakku 0:b1ce54272580 34
kotakku 0:b1ce54272580 35 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 36 // SPI Configuration
kotakku 0:b1ce54272580 37 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 38 #ifndef USB_SPI
kotakku 0:b1ce54272580 39 #define USB_SPI SPI
kotakku 0:b1ce54272580 40 //#define USB_SPI SPI1
kotakku 0:b1ce54272580 41 #endif
kotakku 0:b1ce54272580 42
kotakku 0:b1ce54272580 43 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 44 // DEBUGGING
kotakku 0:b1ce54272580 45 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 46
kotakku 0:b1ce54272580 47 /* Set this to 1 to activate serial debugging */
kotakku 0:b1ce54272580 48 #define ENABLE_UHS_DEBUGGING 0
kotakku 0:b1ce54272580 49
kotakku 0:b1ce54272580 50 /* This can be used to select which serial port to use for debugging if
kotakku 0:b1ce54272580 51 * multiple serial ports are available.
kotakku 0:b1ce54272580 52 * For example Serial3.
kotakku 0:b1ce54272580 53 */
kotakku 0:b1ce54272580 54
kotakku 0:b1ce54272580 55 #define USB_HOST_SERIAL ; //
kotakku 0:b1ce54272580 56 #ifndef USB_HOST_SERIAL
kotakku 0:b1ce54272580 57 #define USB_HOST_SERIAL //
kotakku 0:b1ce54272580 58 #endif
kotakku 0:b1ce54272580 59
kotakku 0:b1ce54272580 60 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 61 // Manual board activation
kotakku 0:b1ce54272580 62 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 63
kotakku 0:b1ce54272580 64 /* Set this to 1 if you are using an Arduino Mega ADK board with MAX3421e built-in */
kotakku 0:b1ce54272580 65 #define USE_UHS_MEGA_ADK 0 // If you are using Arduino 1.5.5 or newer there is no need to do this manually
kotakku 0:b1ce54272580 66
kotakku 0:b1ce54272580 67 /* Set this to 1 if you are using a Black Widdow */
kotakku 0:b1ce54272580 68 #define USE_UHS_BLACK_WIDDOW 0
kotakku 0:b1ce54272580 69
kotakku 0:b1ce54272580 70 /* Set this to a one to use the xmem2 lock. This is needed for multitasking and threading */
kotakku 0:b1ce54272580 71 #define USE_XMEM_SPI_LOCK 0
kotakku 0:b1ce54272580 72
kotakku 0:b1ce54272580 73 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 74 // Wii IR camera
kotakku 0:b1ce54272580 75 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 76
kotakku 0:b1ce54272580 77 /* Set this to 1 to activate code for the Wii IR camera */
kotakku 0:b1ce54272580 78 #define ENABLE_WII_IR_CAMERA 0
kotakku 0:b1ce54272580 79
kotakku 0:b1ce54272580 80 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 81 // MASS STORAGE
kotakku 0:b1ce54272580 82 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 83 // <<<<<<<<<<<<<<<< IMPORTANT >>>>>>>>>>>>>>>
kotakku 0:b1ce54272580 84 // Set this to 1 to support single LUN devices, and save RAM. -- I.E. thumb drives.
kotakku 0:b1ce54272580 85 // Each LUN needs ~13 bytes to be able to track the state of each unit.
kotakku 0:b1ce54272580 86 #ifndef MASS_MAX_SUPPORTED_LUN
kotakku 0:b1ce54272580 87 #define MASS_MAX_SUPPORTED_LUN 8
kotakku 0:b1ce54272580 88 #endif
kotakku 0:b1ce54272580 89
kotakku 0:b1ce54272580 90 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 91 // Set to 1 to use the faster spi4teensy3 driver.
kotakku 0:b1ce54272580 92 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 93 #ifndef USE_SPI4TEENSY3
kotakku 0:b1ce54272580 94 #define USE_SPI4TEENSY3 1
kotakku 0:b1ce54272580 95 #endif
kotakku 0:b1ce54272580 96
kotakku 0:b1ce54272580 97 // Disabled on the Teensy LC, as it is incompatible for now
kotakku 0:b1ce54272580 98 #if defined(__MKL26Z64__)
kotakku 0:b1ce54272580 99 #undef USE_SPI4TEENSY3
kotakku 0:b1ce54272580 100 #define USE_SPI4TEENSY3 0
kotakku 0:b1ce54272580 101 #endif
kotakku 0:b1ce54272580 102
kotakku 0:b1ce54272580 103 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 104 // AUTOMATIC Settings
kotakku 0:b1ce54272580 105 ////////////////////////////////////////////////////////////////////////////////
kotakku 0:b1ce54272580 106
kotakku 0:b1ce54272580 107 // No user serviceable parts below this line.
kotakku 0:b1ce54272580 108 // DO NOT change anything below here unless you are a developer!
kotakku 0:b1ce54272580 109
kotakku 0:b1ce54272580 110 #include "version_helper.h"
kotakku 0:b1ce54272580 111
kotakku 0:b1ce54272580 112 #if defined(__GNUC__) && defined(__AVR__)
kotakku 0:b1ce54272580 113 #ifndef GCC_VERSION
kotakku 0:b1ce54272580 114 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
kotakku 0:b1ce54272580 115 #endif
kotakku 0:b1ce54272580 116 #if GCC_VERSION < 40602 // Test for GCC < 4.6.2
kotakku 0:b1ce54272580 117 #ifdef PROGMEM
kotakku 0:b1ce54272580 118 #undef PROGMEM
kotakku 0:b1ce54272580 119 #define PROGMEM __attribute__((section(".progmem.data"))) // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734#c4
kotakku 0:b1ce54272580 120 #ifdef PSTR
kotakku 0:b1ce54272580 121 #undef PSTR
kotakku 0:b1ce54272580 122 #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0]; })) // Copied from pgmspace.h in avr-libc source
kotakku 0:b1ce54272580 123 #endif
kotakku 0:b1ce54272580 124 #endif
kotakku 0:b1ce54272580 125 #endif
kotakku 0:b1ce54272580 126 #endif
kotakku 0:b1ce54272580 127
kotakku 0:b1ce54272580 128 #if !defined(DEBUG_USB_HOST) && ENABLE_UHS_DEBUGGING
kotakku 0:b1ce54272580 129 #define DEBUG_USB_HOST
kotakku 0:b1ce54272580 130 #endif
kotakku 0:b1ce54272580 131
kotakku 0:b1ce54272580 132 #if !defined(WIICAMERA) && ENABLE_WII_IR_CAMERA
kotakku 0:b1ce54272580 133 #define WIICAMERA
kotakku 0:b1ce54272580 134 #endif
kotakku 0:b1ce54272580 135
kotakku 0:b1ce54272580 136 // To use some other locking (e.g. freertos),
kotakku 0:b1ce54272580 137 // define XMEM_ACQUIRE_SPI and XMEM_RELEASE_SPI to point to your lock and unlock.
kotakku 0:b1ce54272580 138 // NOTE: NO argument is passed. You have to do this within your routine for
kotakku 0:b1ce54272580 139 // whatever you are using to lock and unlock.
kotakku 0:b1ce54272580 140 #if !defined(XMEM_ACQUIRE_SPI)
kotakku 0:b1ce54272580 141 #if USE_XMEM_SPI_LOCK || defined(USE_MULTIPLE_APP_API)
kotakku 0:b1ce54272580 142 #include <xmem.h>
kotakku 0:b1ce54272580 143 #else
kotakku 0:b1ce54272580 144 #define XMEM_ACQUIRE_SPI() (void(0))
kotakku 0:b1ce54272580 145 #define XMEM_RELEASE_SPI() (void(0))
kotakku 0:b1ce54272580 146 #endif
kotakku 0:b1ce54272580 147 #endif
kotakku 0:b1ce54272580 148
kotakku 0:b1ce54272580 149 #if !defined(EXT_RAM) && defined(EXT_RAM_STACK) || defined(EXT_RAM_HEAP)
kotakku 0:b1ce54272580 150 #include <xmem.h>
kotakku 0:b1ce54272580 151 #else
kotakku 0:b1ce54272580 152 #define EXT_RAM 0
kotakku 0:b1ce54272580 153 #endif
kotakku 0:b1ce54272580 154
kotakku 0:b1ce54272580 155 #if defined(CORE_TEENSY) && defined(KINETISK)
kotakku 0:b1ce54272580 156 #define USING_SPI4TEENSY3 USE_SPI4TEENSY3
kotakku 0:b1ce54272580 157 #else
kotakku 0:b1ce54272580 158 #define USING_SPI4TEENSY3 0
kotakku 0:b1ce54272580 159 #endif
kotakku 0:b1ce54272580 160
kotakku 0:b1ce54272580 161 #if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__) || ARDUINO >= 10600) && !USING_SPI4TEENSY3
kotakku 0:b1ce54272580 162 #include <SPI.h> // Use the Arduino SPI library for the Arduino Due, Intel Galileo 1 & 2, Intel Edison or if the SPI library with transaction is available
kotakku 0:b1ce54272580 163 #endif
kotakku 0:b1ce54272580 164 #ifdef RBL_NRF51822
kotakku 0:b1ce54272580 165 #include <nrf_gpio.h>
kotakku 0:b1ce54272580 166 #include <SPI_Master.h>
kotakku 0:b1ce54272580 167 #define SPI SPI_Master
kotakku 0:b1ce54272580 168 #define MFK_CASTUINT8T (uint8_t) // RBLs return type for sizeof needs casting to uint8_t
kotakku 0:b1ce54272580 169 #endif
kotakku 0:b1ce54272580 170 #if defined(__PIC32MX__) || defined(__PIC32MZ__)
kotakku 0:b1ce54272580 171 #include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library
kotakku 0:b1ce54272580 172 #endif
kotakku 0:b1ce54272580 173
kotakku 0:b1ce54272580 174 #if defined(ESP8266) || defined(ESP32)
kotakku 0:b1ce54272580 175 #define MFK_CASTUINT8T (uint8_t) // ESP return type for sizeof needs casting to uint8_t
kotakku 0:b1ce54272580 176 #endif
kotakku 0:b1ce54272580 177
kotakku 0:b1ce54272580 178 /*
kotakku 0:b1ce54272580 179 #ifdef STM32F4
kotakku 0:b1ce54272580 180 #include "stm32f4xx_hal.h"
kotakku 0:b1ce54272580 181 extern SPI_HandleTypeDef SPI_Handle; // Needed to be declared in your main.cpp
kotakku 0:b1ce54272580 182 #endif
kotakku 0:b1ce54272580 183 */
kotakku 0:b1ce54272580 184
kotakku 0:b1ce54272580 185 // Fix defines on Arduino Due
kotakku 0:b1ce54272580 186 #ifdef ARDUINO_SAM_DUE
kotakku 0:b1ce54272580 187 #ifdef tokSETUP
kotakku 0:b1ce54272580 188 #undef tokSETUP
kotakku 0:b1ce54272580 189 #endif
kotakku 0:b1ce54272580 190 #ifdef tokIN
kotakku 0:b1ce54272580 191 #undef tokIN
kotakku 0:b1ce54272580 192 #endif
kotakku 0:b1ce54272580 193 #ifdef tokOUT
kotakku 0:b1ce54272580 194 #undef tokOUT
kotakku 0:b1ce54272580 195 #endif
kotakku 0:b1ce54272580 196 #ifdef tokINHS
kotakku 0:b1ce54272580 197 #undef tokINHS
kotakku 0:b1ce54272580 198 #endif
kotakku 0:b1ce54272580 199 #ifdef tokOUTHS
kotakku 0:b1ce54272580 200 #undef tokOUTHS
kotakku 0:b1ce54272580 201 #endif
kotakku 0:b1ce54272580 202 #endif
kotakku 0:b1ce54272580 203
kotakku 0:b1ce54272580 204 // Set defaults
kotakku 0:b1ce54272580 205 #ifndef MFK_CASTUINT8T
kotakku 0:b1ce54272580 206 #define MFK_CASTUINT8T
kotakku 0:b1ce54272580 207 #endif
kotakku 0:b1ce54272580 208
kotakku 0:b1ce54272580 209 // Workaround issue: https://github.com/esp8266/Arduino/issues/2078
kotakku 0:b1ce54272580 210 #ifdef ESP8266
kotakku 0:b1ce54272580 211 #undef PROGMEM
kotakku 0:b1ce54272580 212 #define PROGMEM
kotakku 0:b1ce54272580 213 #undef PSTR
kotakku 0:b1ce54272580 214 #define PSTR(s) (s)
kotakku 0:b1ce54272580 215 #undef pgm_read_byte
kotakku 0:b1ce54272580 216 #define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t *>(addr))
kotakku 0:b1ce54272580 217 #undef pgm_read_word
kotakku 0:b1ce54272580 218 #define pgm_read_word(addr) (*reinterpret_cast<const uint16_t *>(addr))
kotakku 0:b1ce54272580 219 #endif
kotakku 0:b1ce54272580 220
kotakku 0:b1ce54272580 221 #ifdef ARDUINO_ESP8266_WIFIO
kotakku 0:b1ce54272580 222 #error "This board is currently not supported"
kotakku 0:b1ce54272580 223 #endif
kotakku 0:b1ce54272580 224
kotakku 0:b1ce54272580 225 #endif /* SETTINGS_H */