I am wanting to write to a register.
The register holds 1 byte of information. I wish to change bit 6 for argument's sake.
The way I am accomplishing this right now is to read the register, then do a set/clear.
This way I only change the bit I am interested in, and leave the rest untouched.
E.g.:
// Read register uint8_t reading = read_reg(0x00); // Set 6th bit if (wanting_to_set) { reading |= (1 << 6); } if (wanting_to_reset) { reading &= ~(1 << 6); } // Write back to register write_reg(0x00, reading); Is there a way I can set or reset the nth bit without knowing that the byte is? This way I can avoid having to read the register first.
