Jump to content

Use Energia library functions in ordinary CCS project

Recommended Posts

Hello everyone,


I got to a point, where my project seems to get to big for Energia. I really like Energia for its simple Upload functionality and most of all for the easy to use c++ libraries that make access to Hardware very easy.

But now my Project contains more than 15 cpp and h files and I'd like to program interrupt service routines, and so on...


At university, I learned to program some Atmel MCUs with Eclipse, so CCS seems familiar to me.


So I'd like to have the ability to start a blank project with a "traditional" main.cpp instead of an .ino file with setup and loop, and port my code with all the Energia functions like "pinMode()", "Serial.print()", "udp.read()" that I used and like using.


I recently checked out the Energia import function of CCS, but I don't like it, as it gets really confusing, especially if I want to give my code to others, that never worked with Energia.


Now my question is: How should I set this up? Should I just include a folder from my Energia installation directory to the search path? If so, what is about things like the TI driverlib that is likely to be already included from an other directory - what happens if there are multiple instances of the same header and source file in my search path? And how does Energia choose the right version of every header and source file, matching my device? Can CCS do it the same way? A lot of questions ;)

Has anyone set up something like that before?

Link to post
Share on other sites

Energia just has the library once for each device, if you browse though the Energia install directory you'll notice that there is for example an msp430/libraries path.

Multiple headers with the same name are resolved in a simple way; the first matching path is used. So if I have msp430.h in C:\foo and in C:\bar, then CCS (or any other tool with search paths) will use C:\bar\msp430.h if my search path is C:\bar;C:\foo and will use C:\foo\msp430.h if my search path is C:\foo;C:\bar.


Now for using Energia libraries, a lot of them are dependent on scheduling done by Energia, for example Serial depends on the fact that it will be serviced alternating with the loop. Some things depend on micros() or millis() which in turn are running on the watchdog timer.

You could try using the main.cpp as is used under the hood in Energia, but I think you might end up with a lot of hassle.

You could consider reimplementing some libraries so that they do not depend on such mechanisms, though you'll probably end up calling the service handlers yourself.

Link to post
Share on other sites

Another solution is to keep the Energia framework and to use a better IDE, with all the modern amenities.


I'm using and I recommend

  • post-12238-0-03356100-1441803999.png embedXcode for Xcode for Mac OS X users,
  • post-12238-0-20909800-1441804007.png Visual Micro for Visual Studio for Windows users.

Both comes with two versions: one free with all the standard features, one paid for more advanced features like debugging.


You'll find pointers at Looking for a Better IDE.

Link to post
Share on other sites

Well, I already used embedXcode (I was the guy that had problems compiling projects containing the ethernet library) and like using this great plugin at home, as I'm a mac user. But the project I work on recently needs an IDE working with Windows as the second programer I work together with has no mac. And since I know Eclipse/CCS relatively good, it still seems to be the best Solution to use the Energia Import function in CCS.


I just didn't think of the dependency on timers and so on - in fact these are ressources I'd like to use too in my code.


So my conclusion is that I'll go on using Code Composer with the Import function first to work time effectively and will maybe try to reimplemt these functions in future if I find time for that. Maybe next year :D

Link to post
Share on other sites

Join the conversation

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

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...