| poke_bchg | Function (Macro)

peekpoke.h

void poke_bchg (unsigned char *addr, short bit);

Inverts a bit at a memory address.

This macro inverts bit bit at memory address addr. It is useful if you do not want to store a whole byte at this address, but only need to invert the state of a single bit. As usual, the rightmost bit of a value is numbered 0, and the leftmost bit is 7 in this case. For example, let's assume the address addr contains the value 0b10011010, and you call this macro like this:

    poke_bchg (addr, 3);

Then the value will be 0b10010010 afterwards. Making the same call again will restore the previous value 0b10011010,
Note: Do not use poke_bchg for sending bits to I/O ports! Use pokeIO_bchg instead.