I recently downloaded CodeWarrior to start on a project for a MC9S12XDP512. While I was looking through MC9S12XDP512.h, I came across this line (21322):
extern volatile DDRSSTR _DDRS @(REG_BASE + 0x0000024AUL);
I've never seen the @ character used in this way in C, and I haven't found a search engine that indexes '@', so I can't search for information. Is this a custom addition to CodeWarrior's C or preprocessor syntax?
解決済! 解決策の投稿を見る。
That code isn't valid C, it is written in the Codewarrior language. In C, you would have written:
#define DDRS (*(volatile DDRSSTR*)(REG_BASE + 0x0000024AUL))
That's just one of many non-standard things in the register map. They made this non-standard @ solution because they couldn't figure out how to provide debug information of registers otherwise.
My advise is to throw the default CW register maps in the garbage bin and write new ones in C.
That code isn't valid C, it is written in the Codewarrior language. In C, you would have written:
#define DDRS (*(volatile DDRSSTR*)(REG_BASE + 0x0000024AUL))
That's just one of many non-standard things in the register map. They made this non-standard @ solution because they couldn't figure out how to provide debug information of registers otherwise.
My advise is to throw the default CW register maps in the garbage bin and write new ones in C.
Thanks for the reply. I was worried this was the case. I don't suppose Freescale supplies a set of gcc friendly register maps?
Hello,
This construct is used to map a variable, in this case a hardware register, to a specific address. This usage is CW specific, and is extensively used within the device header files.
Regards,
Mac
taking a guess
when defining like this - - - - I believe that the @ means the address of the variable is being defined, not the contents of the variable. Could be wrong