energia / msp430-lg-core

15 stars 12 forks source link

Make enableXtal overridable to avoid 2-second delay when crystal not … #39

Closed barawn closed 7 years ago

barawn commented 7 years ago

…present.

RickKimball commented 7 years ago

I think the attribute is supposed to be on the declaration in the header file, not on the definition in the .c file

barawn commented 7 years ago

It does actually work like this, because wiring.c is what actually contains the object to link to - other object files don't need to know the reference is weak because they're just trying to link to something.

But I changed it to duplicate the way that it's done in HardwareSerial.h/.cpp, although I left off the extern declaration because declaring a function prototype external is completely redundant.

RickKimball commented 7 years ago

@barawn I realize you had it correct the first time.

Energia.h: extern "C" void enableXtal(void);

wiring.c void attribute((weak)) enableXtal(void);

void enableXtal(void) { ... all the code ... }

I did test the code and realized for the smaller G series chips, the enableXtal() function is being called twice. I'm pretty sure this wasn't the intent. This function is a ifdefed to death.

barawn commented 7 years ago

Ha! That's actually issue #10 . It was mistakenly reintroduced by commit 4732e353440e433477048ef66ef5feccde464b8d .

barawn commented 7 years ago

issue #10 should be fixed again here. I also changed the declaration to match your suggestion, except the extern "C" isn't required because it's already in an extern "C" block, and you really need the attribute (rather than just attribute).

Edit: I see what happened there, markdown confused me by eating the underscores.