AUnit  1.5.5
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
Flash.h
Go to the documentation of this file.
1 /*
2 MIT License
3 
4 Copyright (c) 2018 Brian T. Park
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 
68 #ifndef AUNIT_FLASH_H
69 #define AUNIT_FLASH_H
70 
71 class __FlashStringHelper;
72 
78 #define AUNIT_FPSTR(pstr) reinterpret_cast<const __FlashStringHelper *>(pstr)
79 
80 #if defined(ARDUINO_ARCH_AVR)
81 
82  #include <avr/pgmspace.h>
83  #define AUNIT_F(x) F(x)
84 
85 #elif defined(ARDUINO_ARCH_SAMD)
86 
87  #include <avr/pgmspace.h>
88  #define AUNIT_F(x) F(x)
89 
90 #elif defined(ESP8266)
91 
92  #include <pgmspace.h>
93  #define AUNIT_F(x) F(x)
94 
95 #elif defined(ESP32)
96 
97  #include <pgmspace.h>
98  #define AUNIT_F(x) F(x)
99 
100  // ESP32 cores don't seem to define SERIAL_PORT_MONITOR
101  #if ! defined(SERIAL_PORT_MONITOR)
102  #define SERIAL_PORT_MONITOR Serial
103  #endif
104 
105 #elif defined(ARDUINO_ARCH_STM32)
106 
107  #include <avr/pgmspace.h>
108  #define AUNIT_F(x) F(x)
109 
110 #elif defined(EPOXY_DUINO)
111 
112  #include <pgmspace.h>
113  #define AUNIT_F(x) F(x)
114 
115 #elif defined(ARDUINO_ARCH_MEGAAVR)
116 
117  #error MegaAVR not supported, https://github.com/bxparks/AUnit/issues/56
118 
119 #else
120 
121  #warning Untested platform, AUnit may still work...
122 
123  #include <avr/pgmspace.h>
124  #define AUNIT_F(x) F(x)
125 
126  #if ! defined(SERIAL_PORT_MONITOR)
127  #define SERIAL_PORT_MONITOR Serial
128  #endif
129 
130 #endif
131 
132 // Define SERIAL_PORT_MONITOR consistently. We should also rename this file to
133 // something like "compat.h".
134 #if defined(ARDUINO_SAMD_ZERO)
135  // If have a real Arduino Zero and using the "Arduino/Genuino Zero (Native
136  // USB Port)" configuration on the Arduino IDE, you may need to uncomment
137  // the following to clobber SERIAL_PORT_MONITOR to point to the correct
138  // SerialUSB.
139  //
140  // On the other hand, if you are using a SparkFun breakout board, or one of
141  // the "SAMD21 M0 Mini" clones, you should be using the SparkFun SAMD Boards,
142  // and selecting the "SparkFun SAMD21 Dev Breakout" or the "SparkFun SAMD21
143  // Mini Breakout" settings, which will set the SERIAL_PORT_MONITOR macro
144  // correctly to SerialUSB.
145  #if 0
146  #undef SERIAL_PORT_MONITOR
147  #define SERIAL_PORT_MONITOR SerialUSB
148  #endif
149 
150 #endif // ARDUINO_SAMD_ZERO
151 
152 #endif // AUNIT_FLASH_H