现在有6个端口为按键输入,我想对它整体进行扫描,然后通过SWITCH语句进行判断,但我不知道如何把这6个端口“放在一起”,我想到了寄存器定义的方法,但是尝试后不行,请大家帮忙看下,用什么方法可以对6个输入口进行整体操作。
如下是仿照寄存器定义写的,是不这样不可以呀。- struct KEYSZ_BITS
- {
- Uint16 key1:1;
- Uint16 key2:1;
- Uint16 key3:1;
- Uint16 key4:1;
- Uint16 key5:1;
- Uint16 key6:1;
- Uint16 rsvd1:10;
- };
- struct KEYSZ_BITS bit;
- union KEYSZ_REG
- {
- Uint16 all;
- struct KEYSZ_BITS bit;
- }
- union KEYSZ_REG KEYSZ;
|