|
Re: Shadow Register Problem
Quote:
Originally Posted by The Lucas
Do you consider macros more or less readable than what you have?
A macro for that statement off the top of my heads is
Code:
#define writeShadow(S,R) while((S).CANMC.bit.CCR==0){(S).CANMC.all=(R).CANMC.all;};
Then you just say:
Code:
writeShadow(ECanaShadow,ECanaRegs)
I haven't tested that, but it should be close. I assume those are the structs that are going to change from statement to statement. Anyway it is a start if you like it.
|
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.
Quote:
|
I haven't tested that, but it should be close. I assume those are the structs that are going to change from statement to statement. Anyway it is a start if you like it.
|
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.
__________________
If either a public officer or any one else saw a person attempting to cross a bridge which had been ascertained to be unsafe, and there were no time to warn him of his danger, they might seize him and turn him back without any real infringement of his liberty; for liberty consists in doing what one desires, and he does not desire to fall into the river. -Mill
Last edited by Adam Y. : 26-02-2007 at 13:09.
|