Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error with example 1 on Redboard Artemis #5

Closed
DesktopMan opened this issue Sep 26, 2023 · 3 comments
Closed

Compilation error with example 1 on Redboard Artemis #5

DesktopMan opened this issue Sep 26, 2023 · 3 comments
Assignees

Comments

@DesktopMan
Copy link

Trying to compile Example1_Basic_Readings.ino:

Arduino\libraries\SparkFun_ADXL313_Arduino_Library\src\SparkFunADXL313.cpp: In member function 'boolean ADXL313::beginSPI(uint8_t, arduino::SPIClass&)':
Arduino\libraries\SparkFun_ADXL313_Arduino_Library\src\SparkFunADXL313.cpp:78:21: error: no matching function for call to 'arduino::HardwareSPI::begin(int&)'
  _spiPort->begin(_CS);
                     ^
In file included from Arduino15\packages\SparkFun\hardware\apollo3\2.2.1\libraries\SPI\src/SPI.h:10,
                 from Arduino\libraries\SparkFun_ADXL313_Arduino_Library\src\SparkFunADXL313.h:46,
                 from Arduino\libraries\SparkFun_ADXL313_Arduino_Library\src\SparkFunADXL313.cpp:34:
Arduino15\packages\SparkFun\hardware\apollo3\2.2.1/cores/arduino/mbed-bridge/core-api/api/HardwareSPI.h:123:18: note: candidate: 'virtual void arduino::HardwareSPI::begin()'
     virtual void begin() = 0;
                  ^~~~~
Arduino15\packages\SparkFun\hardware\apollo3\2.2.1/cores/arduino/mbed-bridge/core-api/api/HardwareSPI.h:123:18: note:   candidate expects 0 arguments, 1 provided
Arduino\libraries\SparkFun_ADXL313_Arduino_Library\src\SparkFunADXL313.cpp:79:12: error: 'arduino::SPIClass' {aka 'class arduino::HardwareSPI'} has no member named 'setDataMode'
  _spiPort->setDataMode(SPI_MODE3);
            ^~~~~~~~~~~

exit status 1

Compilation error: exit status 1
@lewispg228
Copy link
Member

Hi @DesktopMan ,
Thanks for your message here. I was just working on this exact problem (similar Artemis-based hardware) yesterday and found a solution.

The CS pin control is handled within the ADXL313 library, so we don't really need to pass it to the SPI.begin() function. If we omit this argument, then the compile error goes away.

The setDataMode() function seems to have become depreciated, so the best way to make it SPI_MODE3 is to pass an SPISettings object inside the SPI function.

You need to make two small adjustments to the header file here:

https://github.com/sparkfun/SparkFun_ADXL313_Arduino_Library/blob/master/src/SparkFunADXL313.cpp#L78

https://github.com/sparkfun/SparkFun_ADXL313_Arduino_Library/blob/master/src/SparkFunADXL313.cpp#L79

image

Hope this helps and let us know how it goes,
Pete

PS. we will be working on a more permanent fix for this with a new release asap.

@lewispg228
Copy link
Member

Here's the code adjustment too, for easier copy/paste.

//_spiPort->begin(_CS); // throws a compile error, no such function
_spiPort->begin();
//_spiPort->setDataMode(SPI_MODE3); // old way of doing SPI settings, now you must pass in an SPISettings object
_spiPort->beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));

@DesktopMan DesktopMan changed the title Compilation error with example 1 on Redboard Artmis Compilation error with example 1 on Redboard Artemis Sep 26, 2023
@lewispg228 lewispg228 self-assigned this Jan 29, 2024
@lewispg228
Copy link
Member

This has been fixed. Please see this commit for details, and use the latest release (v1.0.3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants