Union/Struct/Bits
Posted: Wed Mar 21, 2018 5:18 am
In previous programming exploits I have used the following sample of code to manipulate individual bits in a byte-sized variable that would subsequently be written to a device (i2c):
union User_Switches_A
{
struct {
bool IN1_Sw :1; //
bool IN2_Sw :1; //
bool IN3_Sw :1; //
bool MON1_Sw :1; //
bool MON2_Sw :1; //
bool MON3_Sw :1; //
bool MUTE_L :1; //
bool MUTE_R :1; //
}Bits;
byte Byte;
} Switches_A;
The Xtime compiler does not like this. Is there any way to alter this to make it compatible with XC, or is there another method I can use to do the same task?
Thanks!
Dan
union User_Switches_A
{
struct {
bool IN1_Sw :1; //
bool IN2_Sw :1; //
bool IN3_Sw :1; //
bool MON1_Sw :1; //
bool MON2_Sw :1; //
bool MON3_Sw :1; //
bool MUTE_L :1; //
bool MUTE_R :1; //
}Bits;
byte Byte;
} Switches_A;
The Xtime compiler does not like this. Is there any way to alter this to make it compatible with XC, or is there another method I can use to do the same task?
Thanks!
Dan