Set Specific Bits in a 32-bit Register

 uint32_t mask = ((1U << len) - 1) << pos;
    reg |= mask;
    return reg;

 

Upvote
Downvote
Loading...

Input

0 4 3

Expected Output

112