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.
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