我想对28035定义一个16位的全局变量,比如 myti; struct MYTIS{ TI1:1; TI2:2; TI3:13;}; 最后想用成myti.bit.TI1;myti.bit.TI2;myti.all等,需要怎么做?麻烦哪位大神给个例子。谢谢!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我想对28035定义一个16位的全局变量,比如 myti; struct MYTIS{ TI1:1; TI2:2; TI3:13;}; 最后想用成myti.bit.TI1;myti.bit.TI2;myti.all等,需要怎么做?麻烦哪位大神给个例子。谢谢!
比如你的例子,在头文件中定义:
struct MYTIS{
unsigned TI1;
unsigned TI2;
.........
}
再加一个extern struct MYTIS mytis;
然后在调用的文件中包含这个头文件就可以了,调用时是mytis.TI1。
自己定义结构体变量,不需要像TI源文件中定义寄存器那样按位定义,也就是后面加一个“:1”等,TI的寄存器定义中间还有一层共用体的定义,bit和all,这个调用的时候是register.bit.TI1,或者register.all。