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