typedef union
{
unsigned char ToByte;
struct P8Bit{
unsigned char bit0:1;
unsigned char bit1:1;
unsigned char bit2:1;
unsigned char bit3:1;
unsigned char bit4:1;
unsigned char bit5:1;
unsigned char bit6:1;
unsigned char bit7:1;
}bitn;
}BitAccess;
BitAccess var_0;
#define LED0 var_0.bitn.bit0
#define LED1 var_0.bitn.bit1
#define LED2 var_0.bitn.bit2
#define LED3 var_0.bitn.bit3
#define LED4 var_0.bitn.bit4
#define LED5 var_0.bitn.bit5
#define LED6 var_0.bitn.bit6
#define LED7 var_0.bitn.bit7
void main() {
var_0.ToByte=0;
LED0=1;
LED1=1;
LED2=1;
LED3=1;
LED4=1;
LED5=1;
LED6=1;
LED7=1;
}
参考范例 http://www.essemi.com/thread/28.html
|