Question

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.

Was it helpful?

Solution

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);
        }
    }    
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top