energia / msp430-lg-core

15 stars 12 forks source link

Have a way to avoid enableXtal #26

Closed barawn closed 7 years ago

barawn commented 7 years ago

enableXtal is a pretty costly function - it runs at startup and if the crystal isn't present, it delays code execution for 2 seconds. It'd be really nice if there were a way to avoid it.

In my recent projects, what I've done is expose "enableXtal" in Energia.h, and give it a weak attribute in wiring.c. This allows me to override it in the main sketch with an empty function, which gets rid of the 2 second delay at startup, but examples that do depend on the crystal work perfectly fine.

RickKimball commented 7 years ago

I like this solution, any objection to this approach @robertinant ?

robertinant commented 7 years ago

I do to like this too!. No objections at all. This way advanced users will be able to control the clock sources as they see fit whereas novice users will still get the "auto" clock selection for low power modes and don't necessarily care about the 2 second delay at startup if the crystal is not present. Let's go for it and then document on energia.nu.

barawn commented 7 years ago

OK, I just submitted a pull request #39 with these changes.

robertinant commented 7 years ago

Pull request was merged. Closing issue.