Confused by "if" statement in bootloader


Still learning. Trying to understand some bootloader code. I understand what the registers are, but I don't understand what is going on in the "if" statement. Is it comparing the value of two bytes, if they are equal returns true?

ch = MCUSR;
MCUSR = 0;

if ((ch & _BV(WDRF))) app_start();



No, this is a "bitwise AND" operator ("&"), typically used to isolate a particular bit of a register. In this case, you can read the whole segment as "if the WDRF bit in the MCUSR register was non-zero, start the application."

Thanks westfw!