Problem writing bits inside a library

Hi i’m trying to manipulate a 32 bit variable inside a library.

I wrote this function:

uint32_t DebouncedEdgeDetector_16Bit::BitWrite(uint32_t Var, uint8_t Bit, bool Data)
{
    uint32_t bitmask = (1 << Bit);
    uint32_t data = Data << Bit;
    Var = (Var & bitmask) |  data;
    
    return Var;
}

I don’t know why but not even the bitmask is working, I tried printing it but it only prints 0.

I have an 8 bit and a 16 bit version of this functions and they do work, I can’t see what is wrong with the 32 bit function :frowning:

Cross post. Answer is in thread in the project guidance forum.

Thread locked.