jvoermans / Wind_Input_V1

Sketch for measuring pressure and IMU using Platformio
0 stars 0 forks source link

digitalPinToPort error #6

Closed jvoermans closed 1 year ago

jvoermans commented 1 year ago

@jerabaul29

I've put the libraries in the local folder now, but still get the same error:

lib\Adafruit_BusIO\Adafruit_SPIDevice.cpp: In constructor 'Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t, int8_t, int8_t, int8_t, uint32_t, BusIOBitOrder, uint8_t)':
lib\Adafruit_BusIO\Adafruit_SPIDevice.cpp:59:48: error: 'digitalPinToPort' was not declared in this scope; did you mean 'digitalPinToInterrupt'?
   59 |   csPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(cspin));
      |                                                ^~~~~~~~~~~~~~~~
      |                                                digitalPinToInterrupt
lib\Adafruit_BusIO\Adafruit_SPIDevice.cpp:59:29: error: 'portOutputRegister' was not declared in this scope
   59 |   csPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(cspin));
      |                             ^~~~~~~~~~~~~~~~~~
lib\Adafruit_BusIO\Adafruit_SPIDevice.cpp:60:15: error: 'digitalPinToBitMask' was not declared in this scope
   60 |   csPinMask = digitalPinToBitMask(cspin);
      |               ^~~~~~~~~~~~~~~~~~~
lib\Adafruit_BusIO\Adafruit_SPIDevice.cpp:66:33: error: 'portInputRegister' was not declared in this scope
   66 |     misoPort = (BusIO_PortReg *)portInputRegister(digitalPinToPort(misopin));
      |                                 ^~~~~~~~~~~~~~~~~
*** [.pio\build\SparkFun_RedBoard_Artemis\libf10\Adafruit_BusIO\Adafruit_SPIDevice.cpp.o] Error 1

I don't get this error in the Arduino IDE. I can't seem to find the cause of the problem online (I saw someone solved the error by including #include <Arduino.h> but that's already there...) Do you get the error as well?

The error doesn't appear if you remove the reference to the IMU library.

jerabaul29 commented 1 year ago

I think I know where this comes from and why this works for the Arduino IDE and not PlatformIO :) .

Basically, I encountered this issue when developing also in the arduino IDE, and this is documented and fixed here: https://github.com/jerabaul29/OpenMetBuoy-v2021a/blob/main/development_environment/setup_arduino_v1-8_environment/Instructions.md , the point that says "I also encountered some difficulties compiling the "Adafruit_BusIO" due to some missing mapping that are expected by the Adafruit library". I think that you followed the instructions there when setting things up for the Arduino IDE (which is why it works - the library used by the Arduino IDE on your machine is my library at the moment due to the installation process you went through a while back), but platformio uses the local git submodule library that is the Adafruit one at the moment, not the arduino ide (patched) library you installed following the instruction there :) .

The solution for this should be simple: follow the same instructions that are described in the installation guide for the arduino IDE setup, but within the current lib folder; i.e.:

~/Desktop/Git/Wind_Input_V1> git submodule deinit -f lib/Adafruit_BusIO/
~/Desktop/Git/Wind_Input_V1> rm -rf .git/modules/lib/Adafruit_BusIO/
~/Desktop/Git/Wind_Input_V1> git rm -f lib/Adafruit_BusIO/
~/Desktop/Git/Wind_Input_V1> git submodule add git@github.com:jerabaul29/Adafruit_BusIO.git lib/Adafruit_BusIO
~/Desktop/Git/Wind_Input_V1> cd lib/Adafruit_BusIO/
~/Desktop/Git/Wind_Input_V1/lib/Adafruit_BusIO> git checkout fix/SPI_with_Artemis

After this, things should work again :) .

jvoermans commented 1 year ago

Perfect, it compiles now. Thanks again for the extensive elaboration, it really helps. I vaguely remember the fix you suggested, but only after you mentioned it :)

jerabaul29 commented 1 year ago

Excellent :) .

Yes, this is the issue using system wide libraries / dependencies: this produces dependencies that are "undocumented in the code", for example the fact that the Arduino IDE uses a given library that is not the standard one (as the case here) is not visible anywhere from just looking at the repo (except reading in details my guides).

This will be much, much better here with this platformio project where all the dependencies are local: the submodules contain all the information about exactly what libraries are used in which version, and all the user needs to do is clone and init the submodules and all works out of the box - ie the code contains all the information out of the box, nothing is hidden through global libraries that are not visible from the git project :) .

So this will be a huge simplification / improvement by using platformio compared with arduino ide :) .