energia / cc3200-core

6 stars 10 forks source link

CC3200 SPI Issue #5

Closed rei-vilo closed 7 years ago

rei-vilo commented 8 years ago

When the SPI library is called from a library, compilation fails, even when SPI has been included in the main sketch.

"/Users/ReiVilo/Library/Energia15/packages/energia/tools/arm-none-eabi-gcc/4.8.4-20140725/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD -mcpu=cortex-m4 -mthumb -DF_CPU=80000000L -DARDUINO=10610 -DENERGIA=10610 -DENERGIA_CC3200-LAUNCHXL -DENERGIA_ARCH_CC3200 "-I/Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/variants/CC3200-LAUNCHXL" "-I/Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/system/driverlib" "-I/Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/system/inc" "-I/Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/system" -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -mabi=aapcs "-I/Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/cores/cc3200" "-I/Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/variants/CC3200-LAUNCHXL" "/var/folders/hz/wncgspfd5wxgzmly78yvzk_m0000gn/T/build2bd1d110e6c47d509a7edf46f7b5491e.tmp/sketch/myLibrary.cpp" -o "/var/folders/hz/wncgspfd5wxgzmly78yvzk_m0000gn/T/build2bd1d110e6c47d509a7edf46f7b5491e.tmp/sketch/myLibrary.cpp.o" In file included from /var/folders/hz/wncgspfd5wxgzmly78yvzk_m0000gn/T/build2bd1d110e6c47d509a7edf46f7b5491e.tmp/sketch/myLibrary.h:1:0, from /var/folders/hz/wncgspfd5wxgzmly78yvzk_m0000gn/T/build2bd1d110e6c47d509a7edf46f7b5491e.tmp/sketch/myLibrary.cpp:1: /Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/system/driverlib/SPI.h:143:57: error: 'tBoolean' has not been declared extern unsigned long SPIIntStatus(unsigned long ulBase, tBoolean bMasked); ^ /var/folders/hz/wncgspfd5wxgzmly78yvzk_m0000gn/T/build2bd1d110e6c47d509a7edf46f7b5491e.tmp/sketch/myLibrary.cpp: In function 'void beginSPI()': myLibrary.cpp:5: error: 'SPI' was not declared in this scope SPI.begin(); ^ exit status 1 'SPI' was not declared in this scope

  • Solution

The arm-none-eabi-g++ command line is missing the include -I/Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc3200/1.0.2/libraries/SPI.

#include "myLibrary.h"
#include "SPI.h"

void setup() {
  // put your setup code here, to run once:
  beginSPI();
}

void loop() {
  // put your main code here, to run repeatedly:

}
#include "SPI.h"

void beginSPI();
#include "myLibrary.h"

void beginSPI()
{
  SPI.begin();

}
rei-vilo commented 8 years ago

Actually, there are two SPI libraries:

rei-vilo commented 8 years ago

Order matters!

tom-giesberg commented 8 years ago

How can I make use of the "solution" above? Is there a make file or something to edit?

Thanks in advance.

robertinant commented 8 years ago

You can easily work around it for now by editing the file: /Energia15/packages/energia/hardware/cc3200/1.0.2/platform.txt. Look for:

compiler.driverlib.c.flags="-I{build.system.path}/driverlib" "-I{build.system.path}/inc" "-I{build.system.path}”
and replace it with:
compiler.driverlib.c.flags="-I{build.system.path}" "-I{build.system.path}/inc" "-I{build.system.path}”
rei-vilo commented 8 years ago

Is this trick also valid for the Pervasive Displays library?

Thank you.

robertinant commented 8 years ago

Yes it is. The issue is that there is a C compiler include flag that points at {build.system.path}/driverlib. This is an error and it should be {build.system.path}. Driverlib headers should be included with driverlib/xzy.h

tom-giesberg commented 8 years ago

Thanks, Robert, it worked like a charm.

rei-vilo commented 8 years ago

For Mac OS X users:

sri30 commented 7 years ago

I'm facing the same problem as well,but I'm running Energia on Windows 10. Could you please help me out?

rei-vilo commented 7 years ago

You need to look for the corresponding folder on Windows and perform the same operation as in https://github.com/energia/cc3200-core/issues/5#issuecomment-247780464

sri30 commented 7 years ago

I'm using Energia version 1.6.10E18, and in the path E:\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia the only folder I can find is named MSP30 even though I've installed the CC3200 board support package from the board manager. There is only one platform.txt file in the entire Energia installation folder and it doesn't have the above lines of code in it. Appreciate the help,thanks.

StefanSch commented 7 years ago

On windows the path looks like this: c:\Users\yourname\AppData\Local\Energia15\packages\energia\hardware\cc3200\1.0.2\platform.txt

sri30 commented 7 years ago

Thank you so much@StefanSch . The sketch compiles without errors now. :-)

rei-vilo commented 7 years ago

Although this issue is closed, the solution should be committed.

robertinant commented 7 years ago

Fixed and committed.

rei-vilo commented 7 years ago

Thanks!

rei-vilo commented 7 years ago

Still to be released.