Jump to content
43oh

Problem porting Adafruit's ADXL345 library to Energia


Recommended Posts

Hello all,

 

I have been programming the Arduinos for several years now, and just started to work with the Tiva C series, using the Energia environment. I ported some of the Adafruit libraries without any problem, but am running into a problem trying to port the Adafruit ADXL345 3 axis accelerometer board library. This is a nice unit that works with 3.3 or 5 v, and has either i2c or ISP interfaces. Adafruit has a sensor class library:

 

https://learn.adafruit.com/using-the-adafruit-unified-sensor-driver/creating-a-unified-sensor-driver

 

Each sensor has its specific library within that class. For the ADXL345, the library is at 

 

https://github.com/adafruit/Adafruit_ADXL345

 

I substituted the references to Arduino and its include header files to Energia.h, but am getting a loader error that I can't really understand:

 
Adafruit_ADXL345_master\Adafruit_ADXL345_U.cpp.o: In function `Adafruit_Sensor::Adafruit_Sensor()':
Adafruit_ADXL345_U.cpp:(.text._ZN15Adafruit_SensorC2Ev[_ZN15Adafruit_SensorC5Ev]+0x1c): undefined reference to `vtable for Adafruit_Sensor'
collect2.exe: error: ld returned 1 exit status
 
I am attaching the relevant files, as converted, including the example
 
I am using the TM4C123G launchpad, and Energia 0101E0013
 
I'd appreciate any suggestions,
 
Pedro

Adafruit_ADXL345_U.h

Adafruit_ADXL345_U.cpp

sensortest.ino

Adafruit_Sensor.cpp

Adafruit_Sensor.h

Link to post
Share on other sites

The Adafruit_Sensor class should provide definitions for all virtual functions which it does not. avr gcc probably only warns whereas the arm gcc compiler is a bit more strict and error's on the missing definition. The error is very cryptic and does not really tell you what is going on. The error is probably a mistake of the author since the first virtual function is done right but the 2nd and third are not declared correctly. Below is the patch you want to apply to Adafruit_Sensor.h

diff -u Adafruit_Sensor.h.org Adafruit_Sensor.h
--- Adafruit_Sensor.h.org	2014-09-26 12:17:49.000000000 -0700
+++ Adafruit_Sensor.h	2014-09-26 12:18:05.000000000 -0700
@@ -143,8 +143,8 @@
 
   // These must be defined by the subclass
   virtual void enableAutoRange(bool enabled) {};
-  virtual void getEvent(sensors_event_t*);
-  virtual void getSensor(sensor_t*);
+  virtual void getEvent(sensors_event_t*) {};
+  virtual void getSensor(sensor_t*) {};
   
  private:
   bool _autoRange;
Link to post
Share on other sites

The library is ported but nothing comes out on the monitor:

 

I have tried all 4 sets of ports on the TM4C123G, have pull up resistors (I don't have 2.2K, but 2K should be close enough). One post indicated that there is a need to select the ports with TwoWire.SetModule(), but there is no such function in the Wire Library.

 

Any ideas?

 

Thanks,

 

Pedro

Link to post
Share on other sites
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...