I want to be able to keep a couple Bytes and the corresponding bit representation of the same value in the same memory location because it holds a register for an i2c sensor.
I thought I would define a type that is a union of uint16_t byte and struct of uint16_t ints distributed with a bit field to accomplish this.
// Result Configuration
typedef union SENSE_REG_CONFIG {
uint16_t Byte;
struct Bits {
uint16_t RN3 : 1;
uint16_t RN2 : 1;
uint16_t RN1 : 1;
uint16_t RN0 : 1;
uint16_t CT : 1;
uint16_t M1 : 1;
uint16_t M0 : 1;
uint16_t OVF : 1;
uint16_t CRF : 1;
uint16_t FH : 1;
uint16_t FL : 1;
uint16_t L : 1;
uint16_t POL : 1;
uint16_t ME : 1;
uint16_t FC1 : 1;
uint16_t FC0 : 1;
};
};
union SENSE_REG_CONFIG regist;
Serial.println(regist.Byte) //prints 0
--How do I correctly access/modify say bit L?