typedef struct{ bool bit1; bool bit2; bool bit3; bool bit4; bool bit5; bool bit6; bool bit7; bool bit8; }Coin_Machine_Start; //定义一个描述单字节8个bit的结构体 extern Coin_Machine_Start Coin_machine_Start;
Coin_Machine_Start Coin_machine_Start = { false, false, false, false, false, false, false, false, } ; //初始化结构体
void Coin_machine_start_Func(void) { static uint8_t com[1]; if(Coin_machine_Start.bit1 == true) { com[0] |= 0x01; }else{ com[0] &= 0xFE; } if(Coin_machine_Start.bit2 == true) { com[0] |= 0x02; }else{ com[0] &= 0xFD; } if(Coin_machine_Start.bit3 == true) { com[0] |= 0x04; }else{ com[0] &= 0xFB; } if(Coin_machine_Start.bit4 == true) { com[0] |= 0x08; }else{ com[0] &= 0xF7; } if(Coin_machine_Start.bit5 == true) { com[0] |= 0x10; }else{ com[0] &= 0xEF; } if(Coin_machine_Start.bit6 == true) { com[0] |= 0x20; }else{ com[0] &= 0xDF; } if(Coin_machine_Start.bit7 == true) { com[0] |= 0x40; }else{ com[0] &= 0xBF; } if(Coin_machine_Start.bit8 == true) { com[0] |= 0x80; }else{ com[0] &= 0x7F; } memcpy(&coin_start_buf[0],com,1); }