pjrestrepo 0 Posted September 26, 2014 Share Posted September 26, 2014 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 Quote Link to post Share on other sites
energia 485 Posted September 26, 2014 Share Posted September 26, 2014 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; Quote Link to post Share on other sites
energia 485 Posted September 26, 2014 Share Posted September 26, 2014 Not sure if you have ever dealt with patches but in case you have not. The function getEvent and getSensor are missing the {} at the end. Hope this helps. pjrestrepo 1 Quote Link to post Share on other sites
pjrestrepo 0 Posted September 26, 2014 Author Share Posted September 26, 2014 Yes, it now compiles. Thanks for your help! And thanks for adding the second message regarding the missing {}. I never dealt with patches. In Emacs I use ediff, but now I am using windows... Thanks again, Pedro Quote Link to post Share on other sites
pjrestrepo 0 Posted September 27, 2014 Author Share Posted September 27, 2014 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 Quote Link to post Share on other sites
moderboy 1 Posted November 29, 2016 Share Posted November 29, 2016 That will be Wire.setModule() what you are searcing. Anyhow i have downloaded your files, fired up the test code attached, selected my chosen Wire.module and it works nice. Havent looked in the code yet, but thanks for it! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.