Quote:
Originally Posted by Adam Y.
Yes. This is exactly what Im thinking off. Thank you. It's exponentially much easier to read that than having two structures whose only difference is the name.
The two structures are going to be the same but both structures have multiple registers defined. So my macro is going to have the register defined and then the specific bit of the register.
Code:
#define writeShadow(S,R) ECanaShadow.(S).bit.(R)
Unfortunately, its not working because the compiler is giving me an error that it's expecting a field name.
|
Macros are very literal, so try it without the ().
Code:
#define writeShadow(STRCT, BITN) ECanaShadow.STRCT.bit.BITN
Generally you always use () since you are usually doing math with them and the () keep the order of ops correct. But in this case I think they are messing up the variable name (you might want to print out a macro to test it). Also shouldn’t there be more to your statement than
Code:
ECanaShadow.STRCT.bit.BITN
like
Code:
ECanaShadow.STRCT.bit.BITN =
ECanaRegs.STRCT.bit.BITN