Bit fields are perfect for this kind of hardware interface. If it were software only, a full byte for each thing isn't so wasteful on today's computers, and you might do it that way. But on an embedded device or if sending the byte as a command to hardware, use the bitfield.
You can also use vector<bool> which is specialized to use 1 bit per Boolean for most modern compilers, esp if you use multiples of 8 when you allocate it:
Thanks, that simplifies things. I am wondering about this other thing:
/* PID field values/state */
#define TD_DATA_PID 0 /* control pipe state for td_sie_done */
#define TD_STATUS_PID 2 /* control pipe state for td_sie_done */
#define TD_DONE_PID 4 /* control pipe state for td_sie_done */
#define TD_DELETE_PID 0xee /* pipe command for td_sie_done */
#define TD_SETUP_PID 0xd /* also used for control pipe state for tf_sie_done */
#define TD_IN_PID 0x9
#define TD_OUT_PID 0x1
#define TD_SOF_PID 0x5
#define TD_PREAMBLE_PID 0xc
#define TD_NAK_PID 0xa
#define TD_STALL_PID 0xe
#define TD_DATA0_PID 0x3
#define TD_DATA1_PID 0xb
Now please take note. All of the code above is actually declaring constants. However, there is a subtle difference. All the #define values are used standalone, they are not not logically ORed together to create a single constant. However, the constants created via enum actually name the different bits in a single byte and in this may maybe they can be used as bit mask or they can be logically ORed together. I don't know if C/C++ is supposed to allow logical operation on fields of an enaum, is it to?
I am wondering why the enum were also not just created using #define. What do you think?