Jump to content
RichardVowles

Changing the main.cpp

Recommended Posts

I like Energia, particularly that it gives me a working mspgcc on the Mac - but the Arduino style of coding (setup + loop) seems incongruous in relation to the MSP430 chip - I'd prefer to be using sleeping and interrupts.

 

So... Is it OK to just change the main.cpp so it doesn't loop?

 

 

In the above code (presuming it gists properly) I mean take out the loop.

 

edit: ok so gist doesn't work? 

 

 


#include <Energia.h>

int main(void)

{

  init();

  setup();

  for (; ;-) {

    loop();

    if (serialEventRun) serialEventRun();

  }
 

  return 0;

}

Share this post


Link to post
Share on other sites

When including "main.c" as follows, can I include functions from another tab into main.c?

image.png.0d4fb9ce692ee02444a4c0ec76475efe.png

In my example, I would like to use a function from LED.output.h before the main setup file

In main.c

#include <Energia.h>
#include "LEDoutput.h"

int main(void)
{
  led_init(); // my function from LEDoutput.h
  init();
  setup();
  while (1) {
    loop();
  }

  return 0;
}

However I am getting the following error: main.c:(.init9+0x2): undefined reference to `led_init'.

Is my path to my custom library incorrect?

Thank you!

Edited by bluehash
[ADMIN] Added code tags.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×