PDA

View Full Version : Teensyduino 1.37 Beta #2 (Arduino 1.8.3 support)



Paul
06-05-2017, 01:31 PM
Teensyduino 1.37 Beta #2

Here is a second beta test for Teensyduino 1.37.


Old beta download links removed. Please use the latest version:
https://www.pjrc.com/teensy/td_download.html


Changes since Teensyduino 1.37-beta1 (https://forum.pjrc.com/threads/44546-Teensyduino-1-37-Beta-1):

Support for Arduino 1.8.3
Drop Arduino 1.6.12 & 1.6.13 support
Fix FastLED with OctoWS2811 on Teensy 3.6

mjs513
06-05-2017, 01:52 PM
@Paul. Just downloaded the new installer and gave it a try. The issue with including "vector" is still persisting. See https://forum.pjrc.com/threads/44509-Arduino-1-8-3?p=144929&viewfull=1#post144929 for details.

KurtE
06-05-2017, 02:26 PM
@Paul. Just downloaded the new installer and gave it a try. The issue with including "vector" is still persisting. See https://forum.pjrc.com/threads/44509-Arduino-1-8-3?p=144929&viewfull=1#post144929 for details.

I believe the issue has to do with stuff in wiring.h...


#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

You can probably get the #include <vector> to work if you:
#undef min
#undef max
just before the include... Not sure what the proper fix is here as the min/max may be used in several other places in core...

mjs513
06-05-2017, 02:33 PM
@KurtE. It's interesting that in 1.36 never threw an error, worked no issue. But will give the undefs a try and let you know.

UPDATE1: Ok. It worked as you predicted. However, now anytime you use anything from the std C++ lib you need to make sure you preface it with the undef's. Like you said not sure what the fix is for this.

Update2: Just went into wiring.h and found that it does an undefined for abs from stdlib:

// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif

Couldn't you just add something like this:

// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#ifdef min
#undef min
#ifdef max
#undef max
#endif

But not sure why its needed between 1.36 and 1.37.

KurtE
06-05-2017, 02:44 PM
@KurtE. It's interesting that in 1.36 never threw an error, worked no issue. But will give the undefs a try and let you know.
My guess is that the wiring header changed with the new toolchain? Although that should have happened in 1.36...
The min/max macros were added 2 years ago (at least that is what the blame view says up on github).

The only other thing I can think of is maybe wire.h is being included now in some places where it was not before?

mjs513
06-05-2017, 03:03 PM
Just by way of an update on changing wiring.h. I added this to wiring.h:

// undefine stdlib's min and max if encountered
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif

Recompiled and got the same error message.

PaulStoffregen
06-05-2017, 03:07 PM
not sure why its needed between 1.36 and 1.37.

Might have something to do with my attempt to rewrite map() using templates. Now wiring.h includes a C++ header. Previously no part of the Arduino headers included any C++ headers.

mjs513
06-05-2017, 03:18 PM
As a test I commented out the two class templates that were added but still threw the error.

UPDATE: I messed up. Made the change in 1.8.2 instead of 1.8.3. Paul is right when I comment out the map classes it compiles no issue. Working too many ide's.

PaulStoffregen
06-05-2017, 03:22 PM
On C++14, tni raised a good point that we've effectively been on C++11 for years.

For 1.37, we've staying the C++11. I need to release in 2 to 3 weeks, and I'm just not willing to risk a language dialect chance with so little testing time.

But I do want to move forward. Like we did with to toolchain update 1.36-beta1 (https://forum.pjrc.com/threads/41568-Teensyduino-1-36-Beta-1-(ARM-Toolchain-Update)), I'll publish 1.38-beta1 shortly after 1.37 final release, with no changes other than switching to C++14.

This isn't an absolute guarantee 1.38 will end up using C++14. If we run into significant problems, or if Arduino makes another release quickly, it will end up looking like the first aborted toolchain update on 1.34-beta1, where 1.34-beta2 reverted to the old toolchain.

So the goal will be releasing 1.38 based on C++14. I'm going to need your feedback and help testing. We'll be able to start that process right after 1.37 releases.

KurtE
06-05-2017, 03:25 PM
Paul: Are you making some of the same changes to core that went into 1.8.3, like availableForWrite moving? likewise flush?

PaulStoffregen
06-05-2017, 03:44 PM
like availableForWrite moving? likewise flush?

Yes. In fact, these were already in 1.37-beta1, and on github.

https://github.com/PaulStoffregen/cores/commit/3580ee2bd0b18afe57a862cd0072a5d70fc6f5ae
https://github.com/PaulStoffregen/cores/commit/b01a30b0206b1a555d4c37877954b75e0b8d5b07

defragster
06-05-2017, 05:43 PM
... the IDE 1.8.3 thread was here :: Arduino-1-8-3 (https://forum.pjrc.com/threads/44509-Arduino-1-8-3/page2)

KurtE
06-05-2017, 05:45 PM
Put on the wrong thread. But the Clear Output button added to Monitor does not appear to do anything when working with Teensy

tni
06-05-2017, 06:11 PM
Might have something to do with my attempt to rewrite map() using templates. Now wiring.h includes a C++ header. Previously no part of the Arduino headers included any C++ headers.

It's a bad idea to have min / max macros in the first place. 'c++config.h', which is included with GCC undefines that crap. However, by including 'type_traits', you include 'c++config.h' in turn. You define min() / max() afterwards (so the undef isn't performed anymore), which breaks tons of C++ headers.

wiring.h:

// type_traits interferes with min() and other defines
// include it early, so we can define these later
// for Arduino compatibility

No, min / max macros interfere with everything. There are literally dozens of standard C++ member functions in various headers called min / max.

Unfortunately, non-macro versions will definitely break some code.

mjs513
06-05-2017, 07:15 PM
As FYI. The new map function seems to working rather nicely even thought it breaks the min/max macros. Pretty responsive to RC commands. What I mean by this is that I map RC throttle and steering ranges to motor control ranges, ie. 1000-2000 mapped to 0-225. When I move the throttle it appears to be reactive. In the past was a little more choppy.

PaulStoffregen
06-05-2017, 08:26 PM
Unfortunately, non-macro versions will definitely break some code.

Any ideas on what sort of breakage or compatiblity issues we could expect if I abandon the classic/legacy Arduino min() & max()?

tni
06-05-2017, 10:10 PM
Any ideas on what sort of breakage or compatiblity issues we could expect if I abandon the classic/legacy Arduino min() & max()?
Actually, your min() version is a statement expression (not a raw ternary operator) - that eliminates most (maybe all?) issues. Something like this should work for the C++ side:

C++11:



#include <utility>

template<class A, class B>
constexpr auto min(A&& a, B&& b) -> decltype(a < b ? std::forward<A>(a) : std::forward<B>(b)) {
return a < b ? std::forward<A>(a) : std::forward<B>(b);
}


C++14:



template<class A, class B>
constexpr decltype(auto) min(A&& a, B&& b) {
return a < b ? std::forward<A>(a) : std::forward<B>(b);
}


(I wouldn't put this in 1.37.)

mjs513
06-06-2017, 12:16 AM
@tni. I deleted the existing min/max in wiring.h and included your c++11 version, as well as max so the header now reads (hope I did it right):

#ifdef __cplusplus
#include <type_traits>
#include <utility>
// when the input number is an integer type, do all math as 32 bit signed long
template <class T, class A, class B, class C, class D>
long map(T _x, A _in_min, B _in_max, C _out_min, D _out_max, typename std::enable_if<std::is_integral<T>::value >::type* = 0)
{
long x = _x, in_min = _in_min, in_max = _in_max, out_min = _out_min, out_max = _out_max;
// Arduino's traditional algorithm
//return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
// st42's suggestion: https://github.com/arduino/Arduino/issues/2466#issuecomment-69873889
// more conversation:
// https://forum.pjrc.com/threads/44503-map()-function-improvements
if ((in_max - in_min) > (out_max - out_min)) {
return (x - in_min) * (out_max - out_min+1) / (in_max - in_min+1) + out_min;
} else {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
}
// when the input is a float or double, do all math using the input's type
template <class T, class A, class B, class C, class D>
T map(T x, A in_min, B in_max, C out_min, D out_max, typename std::enable_if<std::is_floating_point<T>::value >::type* = 0)
{
return (x - (T)in_min) * ((T)out_max - (T)out_min) / ((T)in_max - (T)in_min) + (T)out_min;
}

template<class A, class B>
constexpr auto min(A&& a, B&& b) -> decltype(a < b ? std::forward<A>(a) : std::forward<B>(b)) {
return a < b ? std::forward<A>(a) : std::forward<B>(b);
}

template<class A, class B>
constexpr auto max(A&& a, B&& b) -> decltype(a < b ? std::forward<A>(a) : std::forward<B>(b)) {
return a > b ? std::forward<A>(a) : std::forward<B>(b);
}
#endif

It complies fine with the changes using vector plus the libs that I referenced in the other thread. I also did compiles for a threaded version of one of my rover sketches which includes the encoder, NeoGPS, TeensyThreads and atomic and compiled fine. In addition, I compiled it with my version of the FreeIMU library which is pretty much all legacy Arduino libraries and again compiled without an issue. Hope this info helps.

Mike

PaulStoffregen
06-06-2017, 12:45 AM
I also did compiles for a threaded version of one of my rover sketches which includes the encoder, NeoGPS, TeensyThreads and atomic and compiled fine. In addition, I compiled it with my version of the FreeIMU library which is pretty much all legacy Arduino libraries and again compiled without an issue.

Do any of these fail to compile or work properly with wiring.h as it is now in 1.37-beta2?

hoek67
06-06-2017, 12:49 AM
Going to install it and try soon. Been having problems with SPI... Got the same hardware working on Due, Mega2560 and Uno but getting glitches with Teensy 3.1.

By glitches... I can't get Teensy to init my SSD1351 so started testing using my simplest SPI device... MAX7219. It seems to not transmit the 1st byte or something... my MAX7219 library has a test pattern function and it seems to be out with the Teensy. I have tried with standard SPI library and also a FIFO one, oddly both give the same results. However... I'm 1 step ahead of 2 days ago where I was getting nothing at all to happen.

I have tried different clock rates and even compiled Teensy to 16Mhz so there was no way the clock could be too fast.

I'll just install and see if anything changes and go from there.

mjs513
06-06-2017, 01:01 AM
FreeIMU compiles fine with current version of wiring. My rover sketches throws the min/max error if only if I use#include <vector>. I also tested it the USB Host Sheild 2.0 library and no issue.

mjs513
06-06-2017, 01:11 AM
Forgot to mention the issue is in stl_algobase.h

mjs513
06-06-2017, 02:30 AM
@PaulStroffregen. Just remembered that I had a sketch that uses the Eigen library (right now I have 3.25) for a Kalman filter that I use in conjunction with the FreeIMU library. I figured I would give that one a try and received numerous errors associated with min/max:


In file included from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\char_traits.h:39:0,

from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\ios:40,

from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\istream:38,

from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\sstream:38,

from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\complex:45,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/Eigen/Core:28,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/EigenArm.h:42,

from C:\Users\CYBERP~1\AppData\Local\Temp\arduino_modif ied_sketch_687549\FreeIMU_EKF2.ino:47:

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2

min(const _Tp& __a, const _Tp& __b, _Compare __comp)

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2

max(const _Tp& __a, const _Tp& __b, _Compare __comp)

^

In file included from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/Eigen/Core:157:0,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/EigenArm.h:42,

from C:\Users\CYBERP~1\AppData\Local\Temp\arduino_modif ied_sketch_687549\FreeIMU_EKF2.ino:47:

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:320:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:324:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:387:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return false; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:390:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return true; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:394:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:456:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:459:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max(char); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:463:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:523:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return -__SCHAR_MAX__ - 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:526:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:530:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:593:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return 0; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:596:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__ * 2U + 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:600:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:666:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:669:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (wchar_t); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:673:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:735:11: error: macro "min" requires 2 arguments, but only 1 given

min() noexcept { return __glibcxx_min (char16_t); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:738:11: error: macro "max" requires 2 arguments, but only 1 given

max() noexcept { return __glibcxx_max (char16_t); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:741:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:796:11: error: macro "min" requires 2 arguments, but only 1 given

min() noexcept { return __glibcxx_min (char32_t); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:799:11: error: macro "max" requires 2 arguments, but only 1 given

max() noexcept { return __glibcxx_max (char32_t); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:802:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:858:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return -__SHRT_MAX__ - 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:861:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:865:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:925:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return 0; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:928:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__ * 2U + 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:932:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:998:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1001:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1005:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1065:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return 0; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1068:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__ * 2U + 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1072:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1137:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_MAX__ - 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1140:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1144:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1204:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return 0; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1207:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__ * 2UL + 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1211:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1277:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1280:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1284:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1347:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return 0; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1350:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1354:38: error: macro "min" requires 2 arguments, but only 1 given

lowest() noexcept { return min(); }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1598:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1601:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1673:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1676:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __DBL_MAX__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1748:11: error: macro "min" requires 2 arguments, but only 1 given

min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MIN__; }

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\limits:1751:11: error: macro "max" requires 2 arguments, but only 1 given

max() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MAX__; }

^

In file included from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\stl_algo.h:60:0,

from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\algorithm:62,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/Eigen/Core:160,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/EigenArm.h:42,

from C:\Users\CYBERP~1\AppData\Local\Temp\arduino_modif ied_sketch_687549\FreeIMU_EKF2.ino:47:

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\algorithmfwd.h:362:41: error: macro "max" passed 3 arguments, but takes just 2

max(const _Tp&, const _Tp&, _Compare);

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\algorithmfwd.h:375:41: error: macro "min" passed 3 arguments, but takes just 2

min(const _Tp&, const _Tp&, _Compare);

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\algorithmfwd.h:403:30: error: macro "min" requires 2 arguments, but only 1 given

min(initializer_list<_Tp>);

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\algorithmfwd.h:413:30: error: macro "max" requires 2 arguments, but only 1 given

max(initializer_list<_Tp>);

^

In file included from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\stl_algo.h:66:0,

from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\algorithm:62,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/Eigen/Core:160,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/EigenArm.h:42,

from C:\Users\CYBERP~1\AppData\Local\Temp\arduino_modif ied_sketch_687549\FreeIMU_EKF2.ino:47:

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:76: 56: error: macro "max" requires 2 arguments, but only 1 given

_IntType __b = std::numeric_limits<_IntType>::max())

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:105 :57: error: macro "max" requires 2 arguments, but only 1 given

_IntType __b = std::numeric_limits<_IntType>::max())

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:149 :11: error: macro "min" requires 2 arguments, but only 1 given

min() const

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:156 :11: error: macro "max" requires 2 arguments, but only 1 given

max() const

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:227 :40: error: macro "min" requires 2 arguments, but only 1 given

const __uctype __urngmin = __urng.min();

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:228 :40: error: macro "max" requires 2 arguments, but only 1 given

const __uctype __urngmax = __urng.max();

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:296 :40: error: macro "min" requires 2 arguments, but only 1 given

const __uctype __urngmin = __urng.min();

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\uniform_int_dist.h:297 :40: error: macro "max" requires 2 arguments, but only 1 given

const __uctype __urngmax = __urng.max();

^

In file included from c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\algorithm:62:0,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/Eigen/Core:160,

from C:\Users\CyberPalin\Documents\Arduino\libraries\Ei gen325/EigenArm.h:42,

from C:\Users\CYBERP~1\AppData\Local\Temp\arduino_modif ied_sketch_687549\FreeIMU_EKF2.ino:47:

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\stl_algo.h:3445:34: error: macro "min" requires 2 arguments, but only 1 given

min(initializer_list<_Tp> __l)

^

c:\local programs\arduino-1.8.3\hardware\tools\arm\arm-none-eabi\include\c++\5.4.1\bits\stl_algo.h:3457:34: error: macro "max" requires 2 arguments, but only 1 given

max(initializer_list<_Tp> __l)

^

Multiple libraries were found for "SPI.h"
Used: C:\Local Programs\arduino-1.8.3\hardware\teensy\avr\libraries\SPI
Not used: C:\Users\CyberPalin\Documents\Arduino\libraries\Fl utterWirelessLibrary-master
Multiple libraries were found for "I2Cdev.h"
Used: C:\Users\CyberPalin\Documents\Arduino\libraries\I2 Cdev
Not used: C:\Users\CyberPalin\Documents\Arduino\libraries\Mo tionDriver
Error compiling for board Teensy 3.5.


Sorry to be the bearer of bad news.

hoek67
06-06-2017, 09:08 AM
Installed and tried the 1.37 Beta... had no problems compiling under Visual Micro.

Because of the problem I'm still having with SPI I tried a lot of different speeds and although all compiles and run I still get the original SPI problem.

I don't use many of the SPI functions and as previously mentioned the same code and wiring works on UNO, Mega and Due however on Teensy 3.1 it behaves differently.

I have tested on a SSD1305 OLED, SSD1351 OLED and MAX7219. All work fine except for on the Teensy. The OLEDS won't initialise so I switched to a single MAX7219 wired directly so I could hopefully get "something".

The small MAX7219 class just encapsulates a few SPI functions. My SPIBase class has hardware specific implementations if coded... or drops into standard SPI if nothing is found. I commented out the implementations for AVR and Due so it dropped into the standard library and it worked.

Oddly the behaviour for the Teensy is identical for the SPI standard library and a hardware specific one I was adapting.

While testing nothing else was connected and no interrupts happening.

I'm really at a loss as to what to try next. I suppose the logical step would be to try the Teensy hardware with a software bit-banged implementation however I feel it should be working as is.

I don't own a scope but used a led array on the pins for diagnostics and they seem to "flash" in a way that indicates all are getting "stuff" send to them.

The data being sent seems to miss a byte occasionally... and consistently.

I tried moving the SCK to 14 (from 13) and it was the same. Also moved the CS to other pins and it made no difference.

I have also tried compiling with a few different optimizations.




void setup()
{
delay(1000);

Serial.begin(9600);

Serial.println(F("Setup"));

cMAX7219 gmax;
gmax.setSCKDiv(utils::getMaxSCKDiv(16, false)); // 16 = 16 Mhz
gmax.begin("cMAX7219", SCK, MOSI, 15, 1, 1, 1); // teensy

gmax.shutdown(false); // wake
gmax.clearDisplay(0); // clear all
gmax.setIntensity(2); // intensity 2


for (int i = 0; i < 10; i++)
{
for (uint8_t x = 8; x--;) // loop for each column
{
gmax._chip_enable(0); // for a MAX there may be multiple device chains... 0 = cs[0], 1 = cs[1], etc
gmax._write8(_MAX_7219_OP_DIGIT0 + x);
gmax._write8(255 >> x);
gmax._chip_disable(0);
}

delay(1000);

}



part of the implementation is :-




void cDMA_spi_init()
{
static uint8_t done = 0;

if (!done)
{
done++;
SPI.begin();
Serial.println(F("SPI.begin();"));
}
}

bool cDMA_spi_check_div(uint8_t sckDivisor) // to do ... cache current div
{
uint32_t mhz = F_CPU / (uint32_t)sckDivisor;
SPI.beginTransaction(SPISettings(mhz, MSBFIRST, SPI_MODE0));

return false;
}

KurtE
06-06-2017, 12:14 PM
@hoek67 - Is there a link to your library? With simple test case? If so I will try to take a look and see if I notice anything...

hoek67
06-06-2017, 12:41 PM
OK... tracked down the problem.

Was in some old code... the most basic function "fastDigitalWrite" had the SET/CLEAR values transposed... so basically set was unsetting and unset was setting.

I tested that function using leds and "blink".... which made it hard to test that HIGH->ON and LOW->OFF.

Ended up making a SoftSPI class I could drop into my main classes. It ended up worse than the SPI lib cause fastDigitalWrite is used for everything.

I'd almost guess the SPI with FIFO and from standard lib will work when I put them back in.

glitches aside, the lower clocked Teensy 3.1 @72Mhz is giving the Due benchmarks a good workout.

tni
06-06-2017, 02:57 PM
Is there a reason Teensy LC still has broken DMA?

https://github.com/PaulStoffregen/cores/pull/241/files

KurtE
06-06-2017, 03:03 PM
Is there a reason Teensy LC still has broken DMA?

https://github.com/PaulStoffregen/cores/pull/241/files
Yes please :D - I will probably pull my semi duplicate (242) as the second half of it was already done (correct DMA channels for T3.5)

mjs513
06-06-2017, 05:06 PM
Just noticed something strange. Noticed that after I uploader some sketches early this morning my machine's fan kept spinning away. When I went to check something called teensy_reboot.exe was running and eating up CPU time. I just ended the task but forgot to check if teensy loader was open or not so not sure if the two are related. Also not sure if its related to 1.37-beta2. To be honest never saw that one before now.

Mike

KurtE
06-09-2017, 03:24 PM
Actually again, it would be great if you could pick up at least part of my Pull request #242 for DMA ...

There are three parts in it:
1) The DMA Channels were wrong for T3.5 for SPI1/2 - You already did this one.
2) Trying to do DMA on T-LC will often fault the processor as it was at times doing 8 bit writes to some registers that require 32 bit writes. This is Tni #241
3) DMA transfer count is broken as I mentioned in: https://forum.pjrc.com/threads/43048-How-best-to-manage-multiple-SPI-busses?p=142098&viewfull=1#post142098
The problem is if you call it: first with a count of 0x6 it works, then call with 0x200, it works, then if you call again with 6 it actually sets the count to 0x206... That is before it assumed if count < 512 you are using 9 bit count and rest is link field, so it leaves the upper bits including the 0x200 bit from previous count... Alternatively I may just update my SPI code to directly set BITER/CITER...

Thanks Paul

PaulStoffregen
06-12-2017, 12:36 PM
@PaulStroffregen. Just remembered that I had a sketch that uses the Eigen library (right now I have 3.25) for a Kalman filter that I use in conjunction with the FreeIMU library. I figured I would give that one a try and received numerous errors associated with min/max:

Ok then, let's give tni's suggestion from msg #17 (which he doesn't recommend) in 1.37-beta3.

https://github.com/PaulStoffregen/cores/commit/771ce665a0031ccef999f8324930126705b555e6

mjs513
06-12-2017, 12:58 PM
I replaced the wiring.h with the new one and seems to resolve the issues with min/max errors. Tried it with the EKF using Eigen lib as well as just <vector>.

Was tni referring to the c++11 version or the c++14 version in msg #17? Don't know enough why it is not recommended?

PaulStoffregen
06-12-2017, 01:40 PM
I tested with ILI9341 graphicstest. Seems to work fine.

Going to do some other testing with an issue on OctoWS2811, then package up 1.37-beta3 this afternoon or tomorrow morning.

If anyone seems a case where this min/max could break Arduino sketches, please speak up asap! It would be nice to also have C++ standard library headers & features work, but Arduino compatibility comes first.

PaulStoffregen
06-14-2017, 10:08 PM
Just a quick update... I've fallen a couple days behind. A couple internal issues here with PJRC and communication with Arduino devs have taken more time than expected.

As far as I know, issues with OctoWS2811 on newer WS2812B are the only remaining issue blocking 1.37-beta3, and hopefully a final 1.37 release soon.

If there are other urgent issues or fixes I've missed, please remind me now and I'll try to get them into 1.37-beta3, hopefully by Thursday morning.

Paul
06-15-2017, 03:17 PM
1.37-beta3 is available. Closing this thread. Please comment on 1.37-beta3.

https://forum.pjrc.com/threads/44904-Teensyduino-1-37-Beta-3