Open davidgiven opened 6 months ago
That's probably expected behavior for the scenario. Not having Serial
is pretty rare, since that's a pretty basic Arduino feature.
As a work around, can try just deleting Adafruit_BusIO_Register.h
and Adafruit_BusIO_Register.cpp
from the library. The "register" classes are additional convenience features not required for basic SPIDevice
usage.
This looks like a dupe of #111
Disabling the serial device is a supported configuration; having to edit the library to make it work is very much unexpected behaviour...
What I'm specifically trying to do here is to use SoftwareSerial instead of the hard-coded Serial, as the pins that Serial uses by default are in use for something else. I couldn't find any way to configure this that would make BusIO compile; there don't seem to be any user hooks to allow me to declare my own Serial device before the BusIO headers get included. The obvious trick of just defining Adafruit_BusIO_Register_h
to suppress the inclusion doesn't work. I suspect some kind of .ino
preprocessing magic is reordering things.
Regarding deleting the Register classes: I am not using these directly; they're getting included by Adafruit_GFX, which I don't have any control over.
Is there a known way to check for this across all platforms? The preprocessor logic in this PR doesn't seem to work in the case of STM32 BSP: https://github.com/adafruit/Adafruit_BusIO/pull/112
Adding that to your basic test sketch:
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
#include <Adafruit_SPIDevice.h>
#endif
void setup() {}
void loop() {}
still produces the compile time fail.
This works however:
#if !defined(NDEBUG)
#include <Adafruit_SPIDevice.h>
#endif
void setup() {}
void loop() {}
since that is what the STM32 BSP seems to add via a -D
on the command line.
It seems like each BSP does their own thing?
Adafruit_BusIO_Register.h
contains these prototypes:If I try to configure my platform without a generic Serial instance, then compilation of the BusIO libraries fails with a 'Serial not declared' error. I feel like these two prototypes (and the implementation in the
.cpp
file, of course) should probably be guarded with something so that they're only included if a Serial instance is present, but I don't know what that would be.(Alternatively, this might be an STM32Duino issue where it's not doing the right thing if you disable the automatic serial port --- please let me know.)
Disable the serial port via the Tools menu, and compile. You get: