OzGrant 22 Posted November 4, 2016 Share Posted November 4, 2016 G'day, At the moment I change a #define that allows me to use different Libs depending on the board used. Is there a #define statement that allows this to happen automatically at compile time? This will allow me to use the same sketch regardless if its for a Tiva or another launch pad. Quote Link to post Share on other sites
LiviuM 43 Posted November 4, 2016 Share Posted November 4, 2016 Hi, you can use the for sure the uC name: #if defined(__TM4C1294NCPDT__) /*tivac LM4C1294 writes 4 locations at once;*/ In older Arduino IDE's I've used the board name as well, but not sure how the newer IDEs work: #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) Regards, Liviu LE Because of the "command line defines" (-D compiling option), I think in the last Energia (1.6.10E18) you can use "ENERGIA_board-name", with the "board-name" found in the boards.txt file. For my TivaC TM41294XL, the boards.txt shows: EK-TM4C1294XL.build.board=EK-TM4C1294XL and the compile option is -DENERGIA_EK-TM4C1294XL OzGrant 1 Quote Link to post Share on other sites
Fmilburn 445 Posted November 4, 2016 Share Posted November 4, 2016 See https://github.com/fmilburn3/if_Processor/blob/master/if_Processor.ino OzGrant 1 Quote Link to post Share on other sites
Rickta59 589 Posted November 4, 2016 Share Posted November 4, 2016 LE Because of the "command line defines" (-D compiling option), I think in the last Energia (1.6.10E18) you can use "ENERGIA_board-name", with the "board-name" found in the boards.txt file. For my TivaC TM41294XL, the boards.txt shows: EK-TM4C1294XL.build.board=EK-TM4C1294XL and the compile option is -DENERGIA_EK-TM4C1294XL In the latest version this has probably changed: https://github.com/energia/tivac-core/blob/master/boards.txt#L35 EK_TM4C1294XL -rick OzGrant 1 Quote Link to post Share on other sites
LiviuM 43 Posted November 4, 2016 Share Posted November 4, 2016 Hi Rick, Thanks for the correction, it seems I have an older version (1.0.2) for the tivac package. But the exactly name is not so important, it was just an example. Idea remains - one can use the board name from the boards.txt file in #ifdef tests. Best regards, Liviu Quote Link to post Share on other sites
OzGrant 22 Posted November 4, 2016 Author Share Posted November 4, 2016 Thanks for the answers. Grant 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.