??? 12/06/04 17:57 Read: times |
#82635 - Jolly good! Responding to: ???'s previous message |
I said:
I've not tried this, but... Erik Malund said:
It works beautifully, I have used it Jolly good! however I did long ago choose using macro instead as a standard procedure. Using macro, rather than #include allow you to have macro parametres which gives you the opportunity to have a few variables or whatever that differ in the 2 cases. That'd be true. My one concern with recommending a macro here is that 'C' macros do have serious traps for the unwary, and are therefore not to be taken in hand unadvisedly, lightly, or wantonly... Of course, the #include approach could be "customised" with conditional compilation; eg, shared.c static void shared_fn( void ) { #ifdef ISR // your ISR-specific code here #endif #ifdef MAIN // your main-specific code here #endif // your general code here } isr.c #define ISR // enable ISR-specifics #include shared.c // Creates a *local* function void isr( void ) interrupt x using y { // your ISR code here shared_fn(); // Calls *local* function // more ISR code here } main.c #define MAIN // enable MAIN-specifics #include shared.c // Creates a *local* function void main( void ) { // your main code here shared_fn(); // Calls *local* function // more main code here } As I said, I've not done this in practice, so haven't investigated the pros & cons of the two approaches - that is left as an exercise for the reader... Of course, whichever way you go, we're dealing with the 'C' Preprocessor here; for any problems, see Andy's Handy Hint for Debugging Preprocessor Problems: http://www.8052.com/forum/read.phtml?id=29152 |
Topic | Author | Date |
89s52 function sharing. | 01/01/70 00:00 | |
Try This | 01/01/70 00:00 | |
emphasis | 01/01/70 00:00 | |
an idea... | 01/01/70 00:00 | |
Andy, I tried it | 01/01/70 00:00 | |
Jolly good! | 01/01/70 00:00 | |
Error | 01/01/70 00:00 | |
You need to work on it | 01/01/70 00:00 | |
reentrant ? | 01/01/70 00:00 | |
reentrant | 01/01/70 00:00 | |
non-reentrant | 01/01/70 00:00 | |
Wow | 01/01/70 00:00 | |
varaible sharing? | 01/01/70 00:00 | |
Variable sharing | 01/01/70 00:00 | |
Overflow | 01/01/70 00:00 | |
variables, main and ISR | 01/01/70 00:00 | |
Globals use more memory | 01/01/70 00:00 | |
Isn't that a global? | 01/01/70 00:00 | |
Globals, ISRs, main, & static![]() | 01/01/70 00:00 |