Feather ESP32: Adafruit_MotorShield requesting non-existant SPI.h

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lamming
 
Posts: 15
Joined: Sun Nov 12, 2017 10:03 pm

Feather ESP32: Adafruit_MotorShield requesting non-existant SPI.h

Post by lamming »

In platformIO when I compile Adafruit_MotorShield it drags in AdafruitSPIDevice which in turn seeks SPI.h which seems no longer to exist. All latest libraries from Git. It all compiles+runs fine under Arduino 2 IDE.
Clearly some environment issue, but I'm stumped. Anyone else had this issue, or has a suggestion for tracking it down? //Mik

Below, the code fragment, and the error report

Code: Select all

#ifndef Adafruit_SPIDevice_h
#define Adafruit_SPIDevice_h

#include <Arduino.h>

#if !defined(SPI_INTERFACES_COUNT) ||                                          \
    (defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0))
// HW SPI available
#include <SPI.h>
#define BUSIO_HAS_HW_SPI
#else
// SW SPI ONLY
enum { SPI_MODE0, SPI_MODE1, SPI_MODE2, _SPI_MODE4 };
typedef uint8_t SPIClass;
#endif

Code: Select all

Processing featheresp32 (platform: espressif32; board: featheresp32; framework: arduino)
---------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/featheresp32.html
PLATFORM: Espressif 32 (6.1.0) > Adafruit ESP32 Feather
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20007.0 (2.0.7) 
 - tool-esptoolpy @ 1.40500.0 (4.5.0) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://BANNED/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 42 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Adafruit BusIO @ 1.14.1+sha.186bfb0
|   |-- Wire @ 2.0.0
|-- Adafruit Motor Shield V2 Library @ 1.1.1+sha.84e7eb0
|   |-- Adafruit BusIO @ 1.14.1+sha.186bfb0
|   |   |-- Wire @ 2.0.0
|   |-- Wire @ 2.0.0
|-- AccelStepper @ 1.64.0+sha.1255ab5
Building in release mode
Compiling .pio\build\featheresp32\libe83\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\featheresp32\libe83\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
In file included from .pio/libdeps/featheresp32/Adafruit BusIO/Adafruit_BusIO_Register.h:10,
                 from .pio/libdeps/featheresp32/Adafruit BusIO/Adafruit_BusIO_Register.cpp:1:
.pio/libdeps/featheresp32/Adafruit BusIO/Adafruit_SPIDevice.h:9:10: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://registry.platformio.org/search?q=header:SPI.h
*
*************************************************************

 #include <SPI.h>
          ^~~~~~~
compilation terminated.
In file included from .pio/libdeps/featheresp32/Adafruit BusIO/Adafruit_SPIDevice.cpp:1:
.pio/libdeps/featheresp32/Adafruit BusIO/Adafruit_SPIDevice.h:9:10: fatal error: SPI.h: No such file or directory

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Feather ESP32: Adafruit_MotorShield requesting non-existant SPI.h

Post by Franklin97355 »

You might look at this https://github.com/arduino/ArduinoCore- ... /src/SPI.h and see if it helps.
There is a community site you might try to ask here https://community.platformio.org/

User avatar
lamming
 
Posts: 15
Joined: Sun Nov 12, 2017 10:03 pm

Re: Feather ESP32: Adafruit_MotorShield requesting non-existant SPI.h

Post by lamming »

Thanks Franklin97355 - good chap!

Found that there seems to be some compiler/preprocessor problem with a complex #ifdef in Adafruit_SPIDevice.h (below).

Solution:
Included SPI.h in the top of my main routine and it went away. I'm getting old... this took me a day to figure out.

Solution also described in
https://community.platformio.org/t/adaf ... tory/14864

Code: Select all

#if !defined(SPI_INTERFACES_COUNT) ||                                          \
    (defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0))
// HW SPI available
#include <SPI.h>
#define BUSIO_HAS_HW_SPI
#else
// SW SPI ONLY
enum { SPI_MODE0, SPI_MODE1, SPI_MODE2, _SPI_MODE4 };
typedef uint8_t SPIClass;
#endif

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”