ok, i think i could do it on my own :)
void bitWrite(uint8_t &x, unsigned int n, bool b) {
if (n <= 7 && n >= 0) {
if (b) {
x |= (1u << n);
} else {
x &= ~(1u << n);
}
}
}
题
For a raspberry pi project, I am trying to change arduino code. Does anybody know a similar function of this?
http://arduino.cc/en/Reference/BitWrite#.U143R1eehRU
Thanks a lot.
解决方案
ok, i think i could do it on my own :)
void bitWrite(uint8_t &x, unsigned int n, bool b) {
if (n <= 7 && n >= 0) {
if (b) {
x |= (1u << n);
} else {
x &= ~(1u << n);
}
}
}