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);
        }
    }    
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top