|
|
View previous topic :: View next topic |
Author |
Message |
mutevaggil
Joined: 29 May 2008 Posts: 8
|
joining two different projects |
Posted: Mon Sep 22, 2008 5:29 am |
|
|
is it possible to join two different projects? is there any way about doing this?
i have two working project, i want to join them in a third project.
i tried to explain as shown below:
NOTE: all content of files in both projects (*.c, *.h) are different
(ignore that same names were used) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 22, 2008 2:16 pm |
|
|
Make a new project. In your new main project file (.c), use #ifdef, #else,
#endif to select the code which will be compiled for a particular version. |
|
|
mutevaggil
Joined: 29 May 2008 Posts: 8
|
pre processor |
Posted: Tue Sep 23, 2008 7:11 am |
|
|
if i am not wrong, these pre-proccessor instructions work only while compling.
i want user can change which project works. i mean, when i press Button A,
project1 will work, when i press button B, it will stop and project2 wil start to work.
|
|
|
Ttelmah Guest
|
|
Posted: Tue Sep 23, 2008 7:49 am |
|
|
The first (memory efficient) way, is to rewrite the two projects into one. Rename all functions with the same name, into different named versions, and name the 'main' routines, as perhaps 'main1', and 'main2'. Then just have a loader, which checks for the button, and runs either main1, or main2.
The second way, is to build the two projects separately. Use the #build directive, and #org to put them into different parts of the memory. Just as you do for a project that runs with a bootloader (look at the bootloader examples for how to compile the main routines). Then just as with the bootloader, you have your 'keyboard' code, where the bootloader normally sits, deciding which 'main' to use, and then jump into the correct target code.
The first is more efficient, since a lot of the 'library' code will be common to the two programs. The second is less work, provided there is enough memory to hold both copies.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|