I haven't been doing any Arduino programming lately. I'm not sure if this solves
the particular problem at hand, but it is something I've been using with my PIC24
programs. I moved it over into an Arduino sketch, where it compiles and seems
to work ok. Maybe someone can see if it works in a real Arduino program, maybe
it can be massaged into what the OP wants to do. ???
/*
test_struct sketch
*/
typedef struct {
union {
struct {
unsigned F15:1;
unsigned F14:1;
unsigned F13:1;
unsigned F12:1;
unsigned F11:1;
unsigned F10:1;
unsigned F9:1;
unsigned F8:1;
unsigned F7:1;
unsigned F6:1;
unsigned F5:1;
unsigned F4:1;
unsigned F3:1;
unsigned F2:1;
unsigned F1:1;
unsigned F0:1;
};
struct {
unsigned char hiflags;
unsigned char loflags;
};
};
} GFLAGS;
/**** General Use Flags ****/
GFLAGS SYSflags; // 16-bit flag struct.
#define _FEXIT (SYSflags.F0) // received exit signal.
#define _fECHO (SYSflags.F1) // echo enable flag.
#define _fU1 (SYSflags.F2) // redirect comms to UART1.
#define _fU2 (SYSflags.F3) // redirect comms to UART2.
#define _fRXD1 (SYSflags.F4) // U1 char has been received.
#define _fTXD1 (SYSflags.F5) // U1 char has been sent.
#define _fRXD2 (SYSflags.F6) // U2 char has been received.
#define _fTXD2 (SYSflags.F7) // U2 char has been sent.
#define _fCMDBUG (SYSflags.F15) // cmd debug enable.
void setup()
{
SYSflags.hiflags=0xE0;
_fCMDBUG=1;
}
void loop()
{
}