??? 06/12/10 07:13 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#176610 - Like I said before.... Responding to: ???'s previous message |
Like I alluded to before....stop trying to make this so complicated.
For each specific MCU family that you decide to support you should actually find that there should be a complete .H file with _all_ if the SFR definitions for that family. You could include each of those with your code set and then have a conditional include statement sequence that uses a reference to a #define'ed MCU type number that selects the correct .H file to load for that MCU family. Put the MCU selection #define into a "target.h" file that you include into each source file at the top before all other #include's. You could decide to break the general rule of not having #include's inside of #include's. If so you could put the following style code into the target.h file: /* select the type of MCU you intend to use */ /* uncomment only one of the following #define's */ /* Note: If your MCU type is not shown in this selection list */ /* then see the user documentation as to how to add your type */ /* to this project. */ // #define SILABS_C8051F02x // #define ATMEL_AT82S5x #define NXP_P89V51RD2 // #define DALLAS_DS80C40x #ifdef SILABS_C8051F02x #include SILABS_C8051F02x.h #endif #ifdef ATMEL_AT82S5x #include ATMEL_AT82S5x.h #endif #ifdef NXP_P89V51RD2 #include NXP_P89V51RD2.h #endif #ifdef DALLAS_DS80C40x #include DALLAS_DS80C40x.h #endif In your source code modules wherever there is derivative specific code that accesses SFRs you include a set of conditionals just like those shown above but with the #include's replaced with the derivative dependent code sequence. Do _not_ fall into the trap that you need to keep as much code as common as possible. Instead you can include a whole separate initialization subroutine or SFR access subroutine within each derivative dependent section. When you make this layout like this it should be very easy for a customer/client/user of yours to follow what is going on and ,make the proper selection in the target.h file. And if they need to add a new MCU type you can provide easy instructions to show "add a conditional here and here and add a subroutine there. I can repeat that you can clearly delineate in your customer agreement documentation that the code comes pre-configured and tested for a particular range of MCUs and that instructions are provided for a DIY procedure to add additional MCUs. You can then offer to support adding additional types for those customers that are willing to pay a fee for you to provide that service. Michael Karas |